Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
December 2008
- 12 participants
- 201 discussions
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <jardonnet(a)lrde.epita.fr>
Add stuff for report.
* jardonnet/n_cmpt/tikz.hh: New. Generate tikz and various images.
* jardonnet/n_cmpt/tikz.cc: New.
tikz.cc | 63 +++++++++++++++
tikz.hh | 254 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 317 insertions(+)
Index: jardonnet/n_cmpt/tikz.hh
--- jardonnet/n_cmpt/tikz.hh (revision 0)
+++ jardonnet/n_cmpt/tikz.hh (revision 0)
@@ -0,0 +1,254 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_N_CMPT3_HH
+# define MLN_N_CMPT3_HH
+
+# include <mln/labeling/regional_minima.hh>
+# include <mln/core/alias/neighb2d.hh>
+# include <mln/util/set.hh>
+
+# include <mln/debug/println.hh>
+# include <mln/debug/iota.hh>
+
+# include <mln/accu/volume.hh>
+# include <mln/morpho/tree/data.hh>
+# include <mln/morpho/tree/compute_attribute_image.hh>
+
+# include <mln/level/paste.hh>
+
+namespace mln
+{
+
+ namespace n_cmpt
+ {
+
+ template < typename I >
+ void n_cmpt5(const I& (((((((ima))))))));
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ inline
+ mln_psite(I)
+ find_root(I& parent,
+ const mln_psite(I)& x)
+ {
+ if (parent(x) == x)
+ return x;
+ else
+ return parent(x) = find_root(parent, parent(x));
+ }
+
+ template < typename I, typename N>
+ I
+ n_cmpt3(const I& ima, const N& nbh,
+ unsigned lambda)
+ {
+ std::cout << "/ima/" << std::endl;
+ debug::println(ima);
+ io::tikz::save(ima, "ima.tex");
+
+ // compute volume image
+ //---------------------
+
+ typedef p_array<mln_psite(I)> S;
+ typedef mln_ch_value(I, value::int_u<16>) V;
+ typedef accu::volume<I> A;
+
+ S sp = level::sort_psites_decreasing(ima);
+ morpho::tree::data<I,S> t(ima, sp, nbh);
+
+ V volume(ima.domain());
+ level::paste(morpho::tree::compute_attribute_image(A(), t),
+ volume);
+
+ sp = level::sort_psites_increasing(volume);
+ std::cout << "/volume/" << std::endl;
+ debug::println(volume);
+ io::tikz::save(volume, "volume.tex");
+ io::pgm::save(volume, "volume.pgm");
+
+
+ // get /volume/ regional minima
+ //-----------------------------
+
+ unsigned label;
+ mln_ch_value(I, unsigned) min_v = labeling::regional_minima(volume, nbh, label);
+ std::cout << "/volume/ regional minima" << std::endl;
+ debug::println(min_v);
+
+ // number of minima
+ unsigned cmpts = label;
+ if (lambda > cmpts)
+ std::cout << "warning : lambda value is to hight." << std::endl;
+
+ std::cout << cmpts << std::endl;
+
+
+ // two pass algo
+ //--------------
+
+ // init fused image
+ mln_ch_value(I, bool) fused;
+ initialize(fused, volume);
+ mln::level::fill(fused, false);
+
+ // prepare union find
+ typedef mln_psite(V) P;
+
+ //data
+ mln_ch_value(V, accu::volume<V>) data(volume.domain());
+
+ //deja_vu
+ mln_ch_value(V, bool) deja_vu(volume.domain());
+ mln::level::fill(deja_vu, false);
+
+ //parent
+ mln_ch_value(V, P) parent(volume.domain());
+ {
+ mln_fwd_piter(S) p(sp);
+ for_all(p)
+ {
+ parent(p) = p;
+
+ // Mandatory since we propagate fused
+ if (min_v(p) != 0) // p in a reg min of the attribute image
+ fused(p) = true; // ok
+ }
+ }
+
+ // UNION FIND ON VOLUME
+ mln_fwd_piter(S) p(sp);
+ mln_niter(N) n(nbh, p);
+ for_all(p)
+ {
+ std::cout << p << std::endl;
+ //if (volume(p) > lambda)
+ // goto step2;
+ for_all(n)
+ {
+ if (volume.domain().has(n) && deja_vu(n))
+ {
+ //do_union(n, p);
+ P r = find_root(parent, n);
+ if (r != p)
+ {
+ std::cout << "neighb: " << n << std::endl;
+ std::cout << "v(r): " << volume(r) << " v(p): " << volume(p) << " f(p): " << fused(p) << std::endl;
+
+ //if (volume(r) != volume(p)) // r and p have different volumes
+ // This check was wrong.
+ // you just fused with a minima.
+ // then you fuse with a neighbor already fused that has the same volume as you
+ // a) 1 50 1
+ // 2 2 2
+ // we don't have ( volume(r) == volume(p) ) => not fused(r)
+ // even if r and p are not minima
+
+ // problem :
+ // - when fusing minima : same level, both fused. NOT DEC
+ // - when fusing cmpts (a) : same level, both fused. DEC
+
+ // One cmpt less if
+ if (fused(r) && min_v(p) == 0) // p is not a minima
+ if (fused(p)) // p already belong to a cmpt (fused for an another n)
+ if (cmpts >= lambda) // union is still allowed
+ {
+ cmpts--;
+ std::cout << "dec" << std::endl;
+ }
+
+ mln_invariant(fused(r) || volume(r) == volume(p));
+
+ // Union made if
+ if (cmpts >= lambda || // union is still allowed or
+ not fused(r) || // r not fused or
+ not fused(p) || // p not fused or
+ min_v(p) != 0) // p is a minima
+ {
+ std::cout << "fuse" << p << n << std::endl;
+ parent(r) = p;
+
+ // This test is mandatory. Sometimes (--_) points are fused
+ // tought none of these points belongs to a component (attached
+ // to a local minima). In this case fused(p) must not be true
+ // since it can be fused again without removing a component.
+ // looking if r is fused should be enought.
+ // This test force minima to be initialized fused.
+ if (fused(r))
+ fused(p) = true;
+
+
+ // If I try to fuse with something never fused I am on a plateau.
+ // not fused(r) => ( volume(r) == volume(p) )
+ mln_invariant(fused(r) || volume(r) == volume(p));
+ // fused(r) and ( volume(r) == volume(p) ) happen on minima plateau.
+
+ // fused(n) = true; // useless ? probably yes because when we
+ // want to know that we really fuse component, we look at
+ // fused(r) not n.
+ // fused(n) is not an invariant: --_. And it is ok (I think).
+ // We don't have to retro-propagate fused.
+
+ std::cerr << "volume " << volume(p) << " - " << cmpts << std::endl;
+ //debug::println(fused);
+ }
+ }
+ }
+ }
+ deja_vu(p) = true;
+ }
+
+ mln_ch_value(I,value::int_u<16>) iota(ima.domain());
+ debug::iota(iota);
+
+ std::cout << std::endl;
+ std::cout << "cmpts : " << cmpts << std::endl;
+
+ // second pass
+ I output(ima.domain());
+ {
+ mln_bkd_piter(S) p(sp);
+ for_all(p)
+ if (parent(p) == p) // p is root.
+ output(p) = iota(p);
+ else
+ output(p) = output(parent(p));
+ }
+
+ return output;
+ }
+
+ } // end of namespace n_cmpt
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif /* MLN_N_CMPT3_HH */
+
Index: jardonnet/n_cmpt/tikz.cc
--- jardonnet/n_cmpt/tikz.cc (revision 0)
+++ jardonnet/n_cmpt/tikz.cc (revision 0)
@@ -0,0 +1,63 @@
+
+#include <iostream>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/make/image.hh>
+#include <mln/core/alias/neighb1d.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/io/tikz/save.hh>
+
+#include <cmath>
+
+#include "tickz.hh"
+
+using namespace mln;
+using namespace mln::value;
+
+bool usage(int argc, char ** argv)
+{
+ if (argc != 3)
+ {
+ std::cout << argv[0] << " ima.pgm lambda" << std::endl;
+ return false;
+ }
+ return true;
+}
+
+int main(int argc, char ** argv)
+{
+ if (not usage(argc,argv))
+ return 1;
+
+ image2d<int_u8> ima;
+ io::pgm::load(ima, argv[1]);
+ unsigned lambda = atoi(argv[2]);
+
+ image2d<int_u8> cos_(6,6);
+ for (int i = 0; i <= 6; i++)
+ for (int j = 0; j <= 6; j++)
+ cos_(point2d(i,j)) = (sin(i) * cos(j) + 1)/2*255;
+ io::pgm::save(cos_, "cos.pgm");
+
+ int_u8 tree[5][5] =
+ {
+ {100, 160, 160, 100, 100},
+ {160, 220, 220, 100, 100},
+ {160, 160, 220, 100, 100},
+ {220, 160, 100, 100, 100},
+ {100, 160, 100, 160, 160},
+ };
+
+ io::tikz::save(make::image(tree), "tree.tex");
+
+ int_u8 tab[] = {2,3,1,0,2,3,4,5,1,1,0,5,6,8,7,1,1,2,3,4};
+ image1d<int_u8> ima1= make::image(tab);
+
+ n_cmpt::n_cmpt3(ima, c4(), lambda);
+}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2008-12-13 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Fix some bugs in reconstructions.
* garrigues/union_find/canvas/reconstruction_on_function.hh: .
* garrigues/union_find/reconstructions_on_function.cc: .
* garrigues/union_find/reconstructions_on_function.hh: .
* garrigues/union_find/reconstructions_on_set.cc: .
* garrigues/union_find/reconstructions_on_set.hh: .
* garrigues/union_find/reunion_avec_theo: .
---
canvas/reconstruction_on_function.hh | 35 ++++++++----
reconstructions_on_function.cc | 7 +-
reconstructions_on_function.hh | 97 ++++++++++++++++++++++++++---------
reconstructions_on_set.cc | 33 +++++++----
reconstructions_on_set.hh | 6 +-
reunion_avec_theo | 1
6 files changed, 129 insertions(+), 50 deletions(-)
Index: trunk/milena/sandbox/garrigues/union_find/reconstructions_on_set.cc
===================================================================
--- trunk/milena/sandbox/garrigues/union_find/reconstructions_on_set.cc (revision 3040)
+++ trunk/milena/sandbox/garrigues/union_find/reconstructions_on_set.cc (revision 3041)
@@ -32,6 +32,12 @@
# include <mln/io/pbm/load.hh>
# include <mln/io/pbm/save.hh>
+void usage(char** argv)
+{
+ std::cerr << "Usage: " << argv[0] << " (-dilation|-erosion) marker.pbm mask.pbm" << std::endl;
+ exit(1);
+}
+
int main(int argc, char** argv)
{
using namespace mln;
@@ -41,17 +47,22 @@
image2d<bool> mask;
image2d<bool> output;
- if (argc < 2)
- {
- std::cerr << "Usage: " << argv[0] << " marker.pbm mask.pbm" << std::endl;
- return 1;
- }
+ if (argc < 3)
+ usage(argv);
- io::pbm::load(marker, argv[1]);
- io::pbm::load(mask, argv[2]);
+ io::pbm::load(marker, argv[2]);
+ io::pbm::load(mask, argv[3]);
- io::pbm::save(reconstruction_on_set_by_dilation (marker, mask, c4()), "r1.pbm");
- io::pbm::save(reconstruction_on_set_by_dilation_alt(marker, mask, c4()), "r2.pbm");
- io::pbm::save(reconstruction_on_set_by_erosion (marker, mask, c4()), "r3.pbm");
- io::pbm::save(reconstruction_on_set_by_erosion_alt (marker, mask, c4()), "r4.pbm");
+ if (std::string(argv[1]) == "-dilation")
+ {
+ io::pbm::save(reconstruction_on_set_by_dilation (marker, mask, c4()), "r_dilation.pbm");
+ io::pbm::save(reconstruction_on_set_by_dilation_alt(marker, mask, c4()), "r_dilation_alt.pbm");
+ }
+ else if (std::string(argv[1]) == "-erosion")
+ {
+ io::pbm::save(reconstruction_on_set_by_erosion (marker, mask, c4()), "r_erosion.pbm");
+ io::pbm::save(reconstruction_on_set_by_erosion_alt (marker, mask, c4()), "r_erosion_alt.pbm");
+ }
+ else
+ usage(argv);
}
Index: trunk/milena/sandbox/garrigues/union_find/reconstructions_on_function.hh
===================================================================
--- trunk/milena/sandbox/garrigues/union_find/reconstructions_on_function.hh (revision 3040)
+++ trunk/milena/sandbox/garrigues/union_find/reconstructions_on_function.hh (revision 3041)
@@ -31,6 +31,7 @@
# include <mln/core/image/image2d.hh>
# include <mln/core/alias/neighb2d.hh>
+# include <mln/core/routine/clone.hh>
# include <mln/level/fill.hh>
# include <mln/level/compare.hh>
# include <mln/level/paste.hh>
@@ -38,6 +39,7 @@
# include <mln/literal/zero.hh>
# include <mln/math/max.hh>
# include <mln/math/min.hh>
+# include <mln/accu/max.hh>
# include "canvas/reconstruction_on_function.hh"
@@ -63,17 +65,8 @@
{
}
- bool is_active(const P& p) { return mask(p) >= output(p); }
- void set_default_output() { level::fill(output, literal::zero); }
- void init(const P& p) { output(p) = marker(p); }
+ bool is_active(const P& p) { return output(p) <= mask(p); }
void merge(const P& r, const P& p) { output(p) = math::max(output(p), output(r)); }
- void visit_ext_border(const P& n, const P& p) { (void) n; (void) p; }
-
- void set_output_value(const P& p)
- {
- if (!is_active(p))
- output(p) = mask(p);
- }
const I& marker; // F
const J& mask; // G
@@ -99,16 +92,7 @@
}
bool is_active(const P& p) { return mask(p) <= output(p); }
- void set_default_output() { level::fill(output, literal::zero); }
- void init(const P& p) { output(p) = marker(p); }
void merge(const P& r, const P& p) { output(p) = math::min(output(p), output(r)); }
- void visit_ext_border(const P& n, const P& p) { (void) n; (void) p; }
-
- void set_output_value(const P& p)
- {
- if (!is_active(p))
- output(p) = mask(p);
- }
const I& marker; // F
const J& mask; // G
@@ -134,6 +118,7 @@
mln_precondition(marker.has_data());
mln_precondition(mask.has_data());
mln_precondition(mask.domain() == marker.domain());
+ mln_precondition(marker <= mask);
mln_concrete(I) output;
initialize(output, marker);
@@ -142,7 +127,8 @@
F f(marker, mask, output);
canvas::morpho::reconstruction_on_function(nbh, f);
- mln_precondition(marker <= output && output <= mask);
+// mln_postcondition(marker <= output);
+// mln_postcondition(output <= mask);
trace::exiting("morpho::reconstruction_on_function_by_dilation");
return output;
@@ -155,7 +141,7 @@
const Image<J>& mask_,
const Neighborhood<N>& nbh_)
{
- trace::entering("morpho::reconstruction_on_function_by_dilation");
+ trace::entering("morpho::reconstruction_on_function_by_erosion");
const I& marker = exact(marker_);
const J& mask = exact(mask_);
@@ -164,6 +150,7 @@
mln_precondition(marker.has_data());
mln_precondition(mask.has_data());
mln_precondition(mask.domain() == marker.domain());
+ mln_precondition(marker >= mask);
mln_concrete(I) output;
initialize(output, marker);
@@ -172,12 +159,76 @@
F f(marker, mask, output);
canvas::morpho::reconstruction_on_function(nbh, f);
- mln_precondition(marker >= output && output >= mask);
+ mln_postcondition(marker >= output && output >= mask);
- trace::exiting("morpho::reconstruction_on_function_by_dilation");
+ trace::exiting("morpho::reconstruction_on_function_by_erosion");
return output;
}
+
+ template <typename I, typename J, typename N>
+ mln_concrete(I)
+ reconstruction_on_function_by_dilation_slow(const Image<I>& marker_,
+ const Image<J>& mask_,
+ const Neighborhood<N>& nbh_)
+ {
+ trace::entering("morpho::reconstruction_on_function_by_dilation_slow");
+
+
+ const I& marker = exact(marker_);
+ const J& mask = exact(mask_);
+ const N& nbh = exact(nbh_);
+
+ mln_precondition(marker.has_data());
+ mln_precondition(mask.has_data());
+ mln_precondition(mask.domain() == marker.domain());
+ mln_precondition(marker <= mask);
+
+ typedef mln_concrete(I) O;
+ O output = clone(marker);
+ O output1 = clone(marker);
+ O* cur = &output;
+ O* prev = &output1;
+
+ accu::max<mln_value(O)> max;
+
+ mln_piter(I) p(output.domain());
+ mln_niter(N) n(nbh, p);
+
+ bool modif = true;
+ unsigned i = 0;
+ while (modif)
+ {
+ modif = false;
+ for_all(p)
+ {
+ max.take_as_init((*prev)(p));
+ for_all(n)
+ max.take((*prev)(n));
+
+ (*cur)(p) = (*prev)(p);
+ if (max.to_result() == (*cur)(p) || (*cur)(p) == mask(p))
+ continue;
+
+ modif = true;
+ if (max.to_result() < mask(p))
+ (*cur)(p) = max.to_result();
+ else
+ (*cur)(p) = mask(p);
+ }
+
+ // swap
+ O* tmp = cur;
+ cur = prev;
+ prev = tmp;
+ }
+
+ mln_postcondition(marker <= (*cur));
+ mln_postcondition((*cur) <= mask);
+
+ trace::exiting("morpho::reconstruction_on_function_by_dilation_slow");
+ return output;
+ }
} // end of namespace mln.
Index: trunk/milena/sandbox/garrigues/union_find/reconstructions_on_function.cc
===================================================================
--- trunk/milena/sandbox/garrigues/union_find/reconstructions_on_function.cc (revision 3040)
+++ trunk/milena/sandbox/garrigues/union_find/reconstructions_on_function.cc (revision 3041)
@@ -43,7 +43,7 @@
{
using namespace mln;
- if (argc < 2)
+ if (argc < 3)
usage(argv);
typedef image2d<value::int_u8> I;
@@ -55,7 +55,10 @@
io::pgm::load(mask, argv[3]);
if (std::string(argv[1]) == "-dilation")
- io::pgm::save(reconstruction_on_function_by_dilation(marker, mask, c4()), "r_dilation.pgm");
+ {
+ io::pgm::save(reconstruction_on_function_by_dilation(marker, mask, c8()), "r_dilation.pgm");
+// io::pgm::save(reconstruction_on_function_by_dilation_slow(marker, mask, c8()), "r_dilation_ref.pgm");
+ }
else if (std::string(argv[1]) == "-erosion")
io::pgm::save(reconstruction_on_function_by_erosion (marker, mask, c4()), "r_erosion.pgm");
else
Index: trunk/milena/sandbox/garrigues/union_find/reconstructions_on_set.hh
===================================================================
--- trunk/milena/sandbox/garrigues/union_find/reconstructions_on_set.hh (revision 3040)
+++ trunk/milena/sandbox/garrigues/union_find/reconstructions_on_set.hh (revision 3041)
@@ -33,6 +33,7 @@
# include <mln/core/alias/neighb2d.hh>
# include <mln/level/fill.hh>
# include <mln/level/paste.hh>
+# include <mln/level/compare.hh>
# include "canvas/reconstruction_on_set.hh"
@@ -136,7 +137,7 @@
mln_precondition(exact(marker).has_data());
mln_precondition(exact(mask).has_data());
-
+ mln_precondition(exact(marker) <= exact(mask));
image2d<bool> output;
initialize(output, marker);
@@ -158,6 +159,7 @@
mln_precondition(exact(marker).has_data());
mln_precondition(exact(mask).has_data());
+ mln_precondition(exact(marker) <= exact(mask));
image2d<bool> output;
initialize(output, marker);
@@ -180,6 +182,7 @@
mln_precondition(exact(marker).has_data());
mln_precondition(exact(mask).has_data());
+ mln_precondition(exact(marker) <= exact(mask));
image2d<bool> output;
initialize(output, marker);
@@ -202,6 +205,7 @@
mln_precondition(exact(marker).has_data());
mln_precondition(exact(mask).has_data());
+ mln_precondition(exact(marker) <= exact(mask));
image2d<bool> output;
initialize(output, marker);
Index: trunk/milena/sandbox/garrigues/union_find/canvas/reconstruction_on_function.hh
===================================================================
--- trunk/milena/sandbox/garrigues/union_find/canvas/reconstruction_on_function.hh (revision 3040)
+++ trunk/milena/sandbox/garrigues/union_find/canvas/reconstruction_on_function.hh (revision 3041)
@@ -39,6 +39,7 @@
# include <mln/core/alias/neighb2d.hh>
# include <mln/io/pbm/save.hh>
+# include <mln/io/pgm/save.hh>
# include <mln/io/pbm/load.hh>
namespace mln
@@ -85,15 +86,10 @@
// Method of F required
typedef mln_site(I) P;
-
- void (F::*m1)() = & F::set_default_output;
+ bool (F::*m1)(const P&) = & F::is_active;
m1 = 0;
- bool (F::*m2)(const P&) = & F::is_active;
+ void (F::*m2)(const P&, const P&) = & F::merge;
m2 = 0;
- void (F::*m3)(const P&) = & F::init;
- m3 = 0;
- void (F::*m4)(const P&, const P&) = & F::merge;
- m4 = 0;
// Dynamic tests.
mln_precondition(f.mask.domain() == f.output.domain());
@@ -116,6 +112,7 @@
typedef typename F::I I;
typedef typename F::S S;
typedef mln_site(I) P;
+ typedef mln_value(I) V;
// Auxiliary data.
mln_ch_value(I, bool) deja_vu;
@@ -127,7 +124,7 @@
initialize(parent, f.mask);
mln::level::fill(deja_vu, false);
- f.set_default_output();
+ level::fill(f.output, f.marker);
}
// first pass
@@ -138,17 +135,22 @@
{
// Make set.
parent(p) = p;
- f.init(p);
for_all(n) if (f.mask.domain().has(n) && deja_vu(n))
{
//do_union(n, p);
P r = find_root(parent, n);
- if (r != p && f.is_active(r))
+ if (r != p)
+ if (f.mask(r) == f.mask(p) or f.is_active(r))
{
- f.merge(r, p);
parent(r) = p;
+ // f.merge(r, p);
+ if (f.output(r) > f.output(p))
+ f.output(p) = f.output(r); // increasing criterion
}
+ else
+ f.output(p) = mln_max(V);
+
}
deja_vu(p) = true;
}
@@ -158,7 +160,16 @@
{
mln_bkd_piter(S) p(f.s);
for_all(p)
- f.set_output_value(p);
+ {
+ if (parent(p) == p) // if p is a root.
+ {
+ if (f.output(p) == mln_max(V))
+ f.output(p) = f.mask(p);
+ }
+ else
+ f.output(p) = f.output(parent(p));
+
+ }
}
trace::exiting("canvas::morpho::reconstruction_on_function");
Index: trunk/milena/sandbox/garrigues/union_find/reunion_avec_theo
===================================================================
--- trunk/milena/sandbox/garrigues/union_find/reunion_avec_theo (revision 3040)
+++ trunk/milena/sandbox/garrigues/union_find/reunion_avec_theo (revision 3041)
@@ -13,7 +13,6 @@
si on est fast ou pas.
-
* Pour les opérateur auto duaux
Coder la reconstruction auto duale (Rapide).
1
0
Guillaume Lazzara wrote:
> ...
Arg I didn't even notice.
Congratulation for this amazing 3000th patch !
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <jardonnet(a)lrde.epita.fr>
Comment. Fix wrong fusing condition, dec condition.
* jardonnet/n_cmpt/n_cmpt5.cc: Comment. Change fusing/dec conditions.
* jardonnet/n_cmpt/n_cmpt5.hh: Remove old hack.
n_cmpt5.cc | 2 --
n_cmpt5.hh | 43 ++++++++++++++++++++++++++++++++++---------
2 files changed, 34 insertions(+), 11 deletions(-)
Index: jardonnet/n_cmpt/n_cmpt5.cc
--- jardonnet/n_cmpt/n_cmpt5.cc (revision 3039)
+++ jardonnet/n_cmpt/n_cmpt5.cc (working copy)
@@ -35,8 +35,6 @@
io::pgm::load(ima, argv[1]);
unsigned lambda = atoi(argv[2]);
- ima(point2d(0,3)) = 106;
-
int_u8 tab[] = {2,3,1,0,2,3,4,5,1,1,0,5,6,8,7,1,1,2,3,4};
image1d<int_u8> ima1= make::image(tab);
Index: jardonnet/n_cmpt/n_cmpt5.hh
--- jardonnet/n_cmpt/n_cmpt5.hh (revision 3039)
+++ jardonnet/n_cmpt/n_cmpt5.hh (working copy)
@@ -149,16 +149,40 @@
P r = find_root(parent, n);
if (r != p)
{
+ std::cout << "neighb: " << n << std::endl;
+ std::cout << "v(r): " << volume(r) << " v(p): " << volume(p) << " f(p): " << fused(p) << std::endl;
+
+ //if (volume(r) != volume(p)) // r and p have different volumes
+ // This check was wrong.
+ // you just fused with a minima.
+ // then you fuse with a neighbor already fused that has the same volume as you
+ // a) 1 50 1
+ // 2 2 2
+ // we don't have ( volume(r) == volume(p) ) => not fused(r)
+ // even if r and p are not minima
+
+ // problem :
+ // - when fusing minima : same level, both fused. NOT DEC
+ // - when fusing cmpts (a) : same level, both fused. DEC
+
// One cmpt less if
- if (volume(r) != volume(p)) // r and p have differerent volumes
+ if (fused(r) && min_v(p) == 0) // p is not a minima
if (fused(p)) // p already belong to a cmpt (fused for an another n)
- if (cmpts >= lambda) // union is still alowed
+ if (cmpts >= lambda) // union is still allowed
+ {
cmpts--;
+ std::cout << "dec" << std::endl;
+ }
- if (cmpts >= lambda ||
- volume(r) == volume(p) ||
- not fused(p))
+ mln_invariant(fused(r) || volume(r) == volume(p));
+
+ // Union made if
+ if (cmpts >= lambda || // union is still allowed or
+ not fused(r) || // r not fused or
+ not fused(p) || // p not fused or
+ min_v(p) != 0) // p is a minima
{
+ std::cout << "fuse" << p << n << std::endl;
parent(r) = p;
// This test is mandatory. Sometimes (--_) points are fused
@@ -170,6 +194,7 @@
if (fused(r))
fused(p) = true;
+
// If I try to fuse with something never fused I am on a plateau.
// not fused(r) => ( volume(r) == volume(p) )
mln_invariant(fused(r) || volume(r) == volume(p));
@@ -181,8 +206,8 @@
// fused(n) is not an invariant: --_. And it is ok (I think).
// We don't have to retro-propagate fused.
- //std::cout << "volume " << volume(p) << " - " << cmpts << std::endl;
- debug::println(fused);
+ std::cerr << "volume " << volume(p) << " - " << cmpts << std::endl;
+ //debug::println(fused);
}
}
}
@@ -190,7 +215,7 @@
deja_vu(p) = true;
}
- I iota(ima.domain());
+ mln_ch_value(I,value::int_u<16>) iota(ima.domain());
debug::iota(iota);
std::cout << std::endl;
@@ -202,7 +227,7 @@
mln_bkd_piter(S) p(sp);
for_all(p)
if (parent(p) == p) // p is root.
- output(p) = iota(p) * 10;
+ output(p) = iota(p);
else
output(p) = output(parent(p));
}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-12-12 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Make level::compare use test::predicate.
* mln/level/compare.hh: .
* mln/test/predicate.hh: Add a version which works on two images.
Add the concept of vv2b function.
* mln/fun/vv2b: New.
* mln/core/concept/function.hh: .
Add some vv2b functions.
* mln/fun/vv2b/eq.hh: New.
* mln/fun/vv2b/ge.hh: New.
* mln/fun/vv2b/gt.hh: New.
* mln/fun/vv2b/implies.hh: New.
* mln/fun/vv2b/le.hh: New.
* mln/fun/vv2b/lt.hh: New.
---
core/concept/function.hh | 36 ++++++++++++++++++++++
fun/vv2b/eq.hh | 75 +++++++++++++++++++++++++++++++++++++++++++++++
fun/vv2b/ge.hh | 75 +++++++++++++++++++++++++++++++++++++++++++++++
fun/vv2b/gt.hh | 75 +++++++++++++++++++++++++++++++++++++++++++++++
fun/vv2b/implies.hh | 75 +++++++++++++++++++++++++++++++++++++++++++++++
fun/vv2b/le.hh | 75 +++++++++++++++++++++++++++++++++++++++++++++++
fun/vv2b/lt.hh | 75 +++++++++++++++++++++++++++++++++++++++++++++++
level/compare.hh | 31 ++++++++++---------
test/predicate.hh | 62 ++++++++++++++++++++++++++++++++++++--
9 files changed, 560 insertions(+), 19 deletions(-)
Index: trunk/milena/mln/core/concept/function.hh
===================================================================
--- trunk/milena/mln/core/concept/function.hh (revision 3038)
+++ trunk/milena/mln/core/concept/function.hh (revision 3039)
@@ -52,6 +52,7 @@
template <typename E> struct Function_l2l;
template <typename E> struct Function_vv2v;
+ template <typename E> struct Function_vv2b;
/// Function category flag type.
template <>
@@ -324,6 +325,28 @@
Function_vv2v(const Function_vv2v&);
};
+ /*------------------------.
+ | Value, Value -> Boolean.|
+ `------------------------*/
+
+ template <>
+ struct Function_vv2b<void> { typedef Function<void> super; };
+
+ /// Base class for implementation of function-objects from
+ /// a couple of values to a boolean.
+ ///
+ /// The parameter \a E is the exact type.
+ ///
+ template <typename E>
+ struct Function_vv2b : public Function<E>
+ {
+ typedef bool result;
+ typedef Function_vv2b<void> category;
+ protected:
+ Function_vv2b();
+ Function_vv2b(const Function_vv2b&);
+ };
+
# ifndef MLN_INCLUDE_ONLY
@@ -483,6 +506,19 @@
{
}
+ template <typename E>
+ inline
+ Function_vv2b<E>::Function_vv2b()
+ {
+ }
+
+ template <typename E>
+ inline
+ Function_vv2b<E>::Function_vv2b(const Function_vv2b<E>& rhs)
+ : Function<E>(rhs)
+ {
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
Index: trunk/milena/mln/level/compare.hh
===================================================================
--- trunk/milena/mln/level/compare.hh (revision 3038)
+++ trunk/milena/mln/level/compare.hh (revision 3039)
@@ -34,6 +34,10 @@
*/
# include <mln/core/concept/image.hh>
+# include <mln/fun/vv2b/eq.hh>
+# include <mln/fun/vv2b/le.hh>
+# include <mln/fun/vv2b/lt.hh>
+# include <mln/test/predicate.hh>
namespace mln
@@ -82,42 +86,39 @@
inline
bool operator == (const Image<L>& lhs_, const Image<R>& rhs_)
{
+ typedef fun::vv2b::eq<mln_value(L), mln_value(R)> F;
+
const L& lhs = exact(lhs_);
const R& rhs = exact(rhs_);
mln_precondition(lhs.domain() == rhs.domain());
- mln_piter(L) p(lhs.domain());
- for_all(p)
- if (! (lhs(p) == rhs(p)))
- return false;
- return true;
+
+ return test::predicate(lhs_, rhs_, F());
}
template <typename L, typename R>
inline
bool operator < (const Image<L>& lhs_, const Image<R>& rhs_)
{
+ typedef fun::vv2b::lt<mln_value(L), mln_value(R)> F;
+
const L& lhs = exact(lhs_);
const R& rhs = exact(rhs_);
mln_precondition(lhs.domain() == rhs.domain());
- mln_piter(L) p(lhs.domain());
- for_all(p)
- if (! (lhs(p) < rhs(p)))
- return false;
- return true;
+
+ return test::predicate(lhs_, rhs_, F());
}
template <typename L, typename R> // required!
inline
bool operator <= (const Image<L>& lhs_, const Image<R>& rhs_)
{
+ typedef fun::vv2b::le<mln_value(L), mln_value(R)> F;
+
const L& lhs = exact(lhs_);
const R& rhs = exact(rhs_);
mln_precondition(lhs.domain() == rhs.domain());
- mln_piter(L) p(lhs.domain());
- for_all(p)
- if (! (lhs(p) <= rhs(p)))
- return false;
- return true;
+
+ return test::predicate(lhs_, rhs_, F());
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/test/predicate.hh
===================================================================
--- trunk/milena/mln/test/predicate.hh (revision 3038)
+++ trunk/milena/mln/test/predicate.hh (revision 3039)
@@ -54,6 +54,17 @@
bool predicate(const Image<I>& ima, const Function_v2b<F>& f);
+ /*! Test if all pixel values of \p lhs and \p rhs verify the
+ * predicate \p f.
+ *
+ * \param[in] lhs The image.
+ * \param[in] rhs The image.
+ * \param[in] f The predicate.
+ */
+ template <typename I, typename J, typename F>
+ bool predicate(const Image<I>& lhs, const Image<J>& rhs, const Function_v2b<F>& f);
+
+
/*! Test if all points of \p pset verify the predicate \p f.
*
* \param[in] pset The point set.
@@ -70,9 +81,8 @@
template <typename I, typename F>
inline
- bool predicate_(trait::image::speed::any, const I& ima_, const F& f)
+ bool predicate_(trait::image::speed::any, const I& ima, const F& f)
{
- const I& ima = exact(ima_);
mln_piter(I) p(ima.domain());
for_all(p)
if (! f(ima(p)))
@@ -82,9 +92,8 @@
template <typename I, typename F>
inline
- bool predicate_(trait::image::speed::fastest, const I& ima_, const F& f)
+ bool predicate_(trait::image::speed::fastest, const I& ima, const F& f)
{
- const I& ima = exact(ima_);
mln_pixter(const I) pxl(ima);
for_all(pxl)
if (! f(pxl.val()))
@@ -92,6 +101,33 @@
return true;
}
+ template <typename I, typename J, typename F>
+ inline
+ bool predicate_(trait::image::speed::any,
+ trait::image::speed::any,
+ const I& lhs, const J& rhs, const F& f)
+ {
+ mln_piter(I) p(lhs.domain());
+ for_all(p)
+ if (! f(lhs(p), rhs(p)))
+ return false;
+ return true;
+ }
+
+ template <typename I, typename J, typename F>
+ inline
+ bool predicate_(trait::image::speed::fastest,
+ trait::image::speed::fastest,
+ const I& lhs, const J& rhs, const F& f)
+ {
+ mln_pixter(const I) pxl1(lhs);
+ mln_pixter(const I) pxl2(rhs);
+ for_all_2(pxl1, pxl2)
+ if (! f(pxl1.val(), pxl2.val()))
+ return false;
+ return true;
+ }
+
template <typename S, typename F>
inline
bool predicate_(const Site_Set<S>& pset, const F& f)
@@ -117,6 +153,24 @@
exact(f));
}
+
+ template <typename I, typename J, typename F>
+ inline
+ bool predicate(const Image<I>& lhs_, const Image<J>& rhs_, const Function_vv2b<F>& f)
+ {
+ const I& lhs = exact(lhs_);
+ const J& rhs = exact(rhs_);
+
+ mln_precondition(lhs.has_data());
+ mln_precondition(rhs.has_data());
+ mln_precondition(lhs.domain() == rhs.domain());
+
+ return impl::predicate_(mln_trait_image_speed(I)(),
+ mln_trait_image_speed(J)(),
+ lhs, rhs,
+ exact(f));
+ }
+
template <typename S, typename F>
inline
bool predicate(const Site_Set<S>& pset, const Function_p2b<F>& f)
Index: trunk/milena/mln/fun/vv2b/implies.hh
===================================================================
--- trunk/milena/mln/fun/vv2b/implies.hh (revision 0)
+++ trunk/milena/mln/fun/vv2b/implies.hh (revision 3039)
@@ -0,0 +1,75 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_VV2B_IMPLIES_HH
+# define MLN_FUN_VV2B_IMPLIES_HH
+
+/// \file mln/fun/vv2b/implies.hh
+///
+/// Functor that computes "logical implies" between two values.
+
+# include <mln/core/concept/function.hh>
+# include <mln/trait/op/and.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace vv2b
+ {
+
+ /// Functor computing logical-implies between two values.
+ template <typename L, typename R = L>
+ struct implies : public Function_vv2b< implies<L,R> >
+ {
+ bool operator()(const L& v1, const R& v2) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename L, typename R>
+ inline
+ bool
+ implies<L,R>::operator()(const L& v1, const R& v2) const
+ {
+ return (! v1) || v2;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::vv2b
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_VV2B_IMPLIES_HH
Index: trunk/milena/mln/fun/vv2b/eq.hh
===================================================================
--- trunk/milena/mln/fun/vv2b/eq.hh (revision 0)
+++ trunk/milena/mln/fun/vv2b/eq.hh (revision 3039)
@@ -0,0 +1,75 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_VV2B_EQ_HH
+# define MLN_FUN_VV2B_EQ_HH
+
+/// \file mln/fun/vv2b/eq.hh
+///
+/// Functor that computes equal between two values.
+
+# include <mln/core/concept/function.hh>
+# include <mln/trait/op/and.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace vv2b
+ {
+
+ /// Functor computing equal between two values.
+ template <typename L, typename R = L>
+ struct eq : public Function_vv2b< eq<L,R> >
+ {
+ bool operator()(const L& v1, const R& v2) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename L, typename R>
+ inline
+ bool
+ eq<L,R>::operator()(const L& v1, const R& v2) const
+ {
+ return v1 == v2;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::vv2b
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_VV2B_EQ_HH
Index: trunk/milena/mln/fun/vv2b/gt.hh
===================================================================
--- trunk/milena/mln/fun/vv2b/gt.hh (revision 0)
+++ trunk/milena/mln/fun/vv2b/gt.hh (revision 3039)
@@ -0,0 +1,75 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_VV2B_GT_HH
+# define MLN_FUN_VV2B_GT_HH
+
+/// \file mln/fun/vv2b/gt.hh
+///
+/// Functor that computes "greater than" between two values.
+
+# include <mln/core/concept/function.hh>
+# include <mln/trait/op/and.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace vv2b
+ {
+
+ /// Functor computing "greater than" between two values.
+ template <typename L, typename R = L>
+ struct gt : public Function_vv2b< gt<L,R> >
+ {
+ bool operator()(const L& v1, const R& v2) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename L, typename R>
+ inline
+ bool
+ gt<L,R>::operator()(const L& v1, const R& v2) const
+ {
+ return v1 > v2;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::vv2b
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_VV2B_GT_HH
Index: trunk/milena/mln/fun/vv2b/ge.hh
===================================================================
--- trunk/milena/mln/fun/vv2b/ge.hh (revision 0)
+++ trunk/milena/mln/fun/vv2b/ge.hh (revision 3039)
@@ -0,0 +1,75 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_VV2B_GE_HH
+# define MLN_FUN_VV2B_GE_HH
+
+/// \file mln/fun/vv2b/ge.hh
+///
+/// Functor that computes "greater or equal than" between two values.
+
+# include <mln/core/concept/function.hh>
+# include <mln/trait/op/and.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace vv2b
+ {
+
+ /// Functor computing "greater or equal than" between two values.
+ template <typename L, typename R = L>
+ struct ge : public Function_vv2b< ge<L,R> >
+ {
+ bool operator()(const L& v1, const R& v2) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename L, typename R>
+ inline
+ bool
+ ge<L,R>::operator()(const L& v1, const R& v2) const
+ {
+ return v1 >= v2;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::vv2b
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_VV2B_GE_HH
Index: trunk/milena/mln/fun/vv2b/lt.hh
===================================================================
--- trunk/milena/mln/fun/vv2b/lt.hh (revision 0)
+++ trunk/milena/mln/fun/vv2b/lt.hh (revision 3039)
@@ -0,0 +1,75 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_VV2B_LT_HH
+# define MLN_FUN_VV2B_LT_HH
+
+/// \file mln/fun/vv2b/lt.hh
+///
+/// Functor that computes "lower than" between two values.
+
+# include <mln/core/concept/function.hh>
+# include <mln/trait/op/and.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace vv2b
+ {
+
+ /// Functor computing "lower than" between two values.
+ template <typename L, typename R = L>
+ struct lt : public Function_vv2b< lt<L,R> >
+ {
+ bool operator()(const L& v1, const R& v2) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename L, typename R>
+ inline
+ bool
+ lt<L,R>::operator()(const L& v1, const R& v2) const
+ {
+ return v1 < v2;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::vv2b
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_VV2B_LT_HH
Index: trunk/milena/mln/fun/vv2b/le.hh
===================================================================
--- trunk/milena/mln/fun/vv2b/le.hh (revision 0)
+++ trunk/milena/mln/fun/vv2b/le.hh (revision 3039)
@@ -0,0 +1,75 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_VV2B_LE_HH
+# define MLN_FUN_VV2B_LE_HH
+
+/// \file mln/fun/vv2b/le.hh
+///
+/// Functor that computes "lower or equal than" between two values.
+
+# include <mln/core/concept/function.hh>
+# include <mln/trait/op/and.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace vv2b
+ {
+
+ /// Functor computing "lower or equal than" between two values.
+ template <typename L, typename R = L>
+ struct le : public Function_vv2b< le<L,R> >
+ {
+ bool operator()(const L& v1, const R& v2) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename L, typename R>
+ inline
+ bool
+ le<L,R>::operator()(const L& v1, const R& v2) const
+ {
+ return v1 <= v2;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::vv2b
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_VV2B_LE_HH
1
0
* mln/core/image/graph_window_piter.hh,
* mln/core/internal/neighb_niter_impl.hh,
* mln/core/site_set/p_graph_piter.hh: add id().
* tests/core/image/graph_image.cc,
* tests/core/image/line_graph_image.cc: use id() instead of
element().id().
---
milena/ChangeLog | 12 ++++
milena/mln/core/image/graph_window_piter.hh | 37 +++++++++---
milena/mln/core/internal/neighb_niter_impl.hh | 10 +++
milena/mln/core/site_set/p_graph_piter.hh | 11 +++
milena/tests/core/image/graph_image.cc | 84 ++++++++++++------------
milena/tests/core/image/line_graph_image.cc | 80 ++++++++++++------------
6 files changed, 144 insertions(+), 90 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 60a03d4..75ed693 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,17 @@
2008-12-12 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add missing id() member in graph related piters.
+
+ * mln/core/image/graph_window_piter.hh,
+ * mln/core/internal/neighb_niter_impl.hh,
+ * mln/core/site_set/p_graph_piter.hh: add id().
+
+ * tests/core/image/graph_image.cc,
+ * tests/core/image/line_graph_image.cc: use id() instead of
+ element().id().
+
+2008-12-12 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add new macros mln_*ITER() to declare iterators.
* tests/core/other/category.cc,
diff --git a/milena/mln/core/image/graph_window_piter.hh b/milena/mln/core/image/graph_window_piter.hh
index e4186f3..86abb4d 100644
--- a/milena/mln/core/image/graph_window_piter.hh
+++ b/milena/mln/core/image/graph_window_piter.hh
@@ -91,6 +91,12 @@ namespace mln
/// Compute the current psite.
mln_psite(W) compute_p_() const;
+
+ /// Convert towards the graph element id.
+ operator unsigned() const;
+
+ /// Return the graph element id.
+ unsigned id() const;
/// \}
private:
@@ -151,14 +157,6 @@ namespace mln
}
template <typename S, typename W, typename I>
- inline
- mln_psite(W)
- graph_window_piter<S,W,I>::compute_p_() const
- {
- return mln_psite(S)(this->center().site_set(), iter_.id());
- }
-
- template <typename S, typename W, typename I>
template <typename Pref>
inline
void
@@ -170,12 +168,35 @@ namespace mln
template <typename S, typename W, typename I>
inline
+ mln_psite(W)
+ graph_window_piter<S,W,I>::compute_p_() const
+ {
+ return mln_psite(S)(this->center().site_set(), iter_.id());
+ }
+
+ template <typename S, typename W, typename I>
+ inline
const mln_graph_element(S)&
graph_window_piter<S, W, I>::element() const
{
return iter_;
}
+ template <typename S, typename W, typename I>
+ inline
+ graph_window_piter<S, W, I>::operator unsigned() const
+ {
+ return iter_.id();
+ }
+
+ template <typename S, typename W, typename I>
+ inline
+ unsigned
+ graph_window_piter<S, W, I>::id() const
+ {
+ return iter_.id();
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
diff --git a/milena/mln/core/internal/neighb_niter_impl.hh b/milena/mln/core/internal/neighb_niter_impl.hh
index aa0965d..d80789f 100644
--- a/milena/mln/core/internal/neighb_niter_impl.hh
+++ b/milena/mln/core/internal/neighb_niter_impl.hh
@@ -67,6 +67,16 @@ namespace mln
return internal::force_exact<E>(*this).compute_p_().element();
}
+ unsigned id() const
+ {
+ return internal::force_exact<E>(*this).compute_p_().id();
+ }
+
+ operator unsigned() const
+ {
+ return internal::force_exact<E>(*this).compute_p_().id();
+ }
+
};
diff --git a/milena/mln/core/site_set/p_graph_piter.hh b/milena/mln/core/site_set/p_graph_piter.hh
index d91a2cb..e6f4ce8 100644
--- a/milena/mln/core/site_set/p_graph_piter.hh
+++ b/milena/mln/core/site_set/p_graph_piter.hh
@@ -91,6 +91,9 @@ namespace mln
/// Convert towards the graph element id.
operator unsigned() const;
+ /// Return the graph element id.
+ unsigned id() const;
+
private:
/// Update the psite corresponding to this iterator.
@@ -199,6 +202,14 @@ namespace mln
template <typename S, typename I>
inline
+ unsigned
+ p_graph_piter<S,I>::id() const
+ {
+ return iter_.id();
+ }
+
+ template <typename S, typename I>
+ inline
void
p_graph_piter<S,I>::update_()
{
diff --git a/milena/tests/core/image/graph_image.cc b/milena/tests/core/image/graph_image.cc
index 2094a24..20e0961 100644
--- a/milena/tests/core/image/graph_image.cc
+++ b/milena/tests/core/image/graph_image.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright(C) 2007, 2008 EPITA Research and Development Laboratory(LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -46,20 +46,33 @@
#include <mln/debug/draw_graph.hh>
#include <mln/debug/println.hh>
+/* The graph is as follows:
+
+ 0 1 2 3 4
+ .-----------
+ |
+ 0 | 0 2
+ 1 | \ / |
+ 2 | 1 |
+ 3 | \ |
+ 4 | 3-4
+
+*/
// Expected neighbors for forward and backward iteration.
-static unsigned fwd[5][3] = { { 1, -1, -1 },
- { 0, 2, 3 },
- { 1, 4, -1 },
- { 1, 4, -1 },
- { 3, 2, -1 } };
+// -1 is an invalid id.
+static unsigned expected_fwd_nb[5][3] = { { 1, -1, -1 },
+ { 0, 2, 3 },
+ { 1, 4, -1 },
+ { 1, 4, -1 },
+ { 3, 2, -1 } };
-static unsigned bkd[5][3] = { { 1, -1, -1 },
- { 3, 2, 0 },
- { 4, 1, -1 },
- { 4, 1, -1 },
- { 2, 3, -1 } };
+static unsigned expected_bkd_nb[5][3] = { { 1, -1, -1 },
+ { 3, 2, 0 },
+ { 4, 1, -1 },
+ { 4, 1, -1 },
+ { 2, 3, -1 } };
int main()
@@ -70,19 +83,6 @@ int main()
| Graph. |
`--------*/
- /* The graph is as follows:
-
- 0 1 2 3 4
- .-----------
- |
- 0 | 0 2
- 1 | \ / |
- 2 | 1 |
- 3 | \ |
- 4 | 3-4
-
- */
-
// Points associated to vertices.
typedef fun::i2v::array<point2d> fsite_t;
fsite_t sites(5);
@@ -95,7 +95,7 @@ int main()
// Edges.
util::graph g;
// Populate the graph with vertices.
- for (unsigned i = 0; i < sites.size(); ++i)
+ for(unsigned i = 0; i < sites.size(); ++i)
g.add_vertex();
// Populate the graph with edges.
g.add_edge(0, 1);
@@ -120,11 +120,11 @@ int main()
// Graph values.
typedef fun::i2v::array<unsigned> viota_t;
viota_t iota(pv.nsites());
- for (unsigned i = 0; i < iota.size(); ++i)
+ for(unsigned i = 0; i < iota.size(); ++i)
iota(i) = 10 + i;
// Create graph image.
- mln_const_VAR(ima, (iota | pv));
+ mln_const_VAR(ima,(iota | pv));
{
// FIXME: Move this part to a special test case.
@@ -139,13 +139,13 @@ int main()
// Print the image.
/* FIXME: Unfortunately, displaying graph images is not easy right
- now (2008-02-05). We could use
+ now(2008-02-05). We could use
debug::println(ima);
but there's not specialization working for graph_image; the one
selected by the compiler is based on a 2-D bbox, and expects the
- interface of graph_image to work with points (not psites).
+ interface of graph_image to work with points(not psites).
Moreover, this implementation only shows *values*, not the graph
itslef.
@@ -169,7 +169,7 @@ int main()
// iteration over the domain of IMA.
mln_piter_(ima_t) p(ima.domain());
unsigned i = 10;
- for_all (p)
+ for_all(p)
mln_assertion(ima(p) == i++);
typedef graph_elt_window<util::graph, fsite_t> win_t;
@@ -178,12 +178,12 @@ int main()
{
// Window - Forward iteration
mln_qiter_(win_t) q(win, p);
- for_all (p)
+ for_all(p)
{
i = 0;
- for_all (q)
+ for_all(q)
{
- mln_assertion(fwd[p.element().id()][i] == q.element().id());
+ mln_assertion(expected_fwd_nb[p.id()][i] == q.id());
++i;
}
}
@@ -192,12 +192,12 @@ int main()
{
// Window - Backward iteration
mln_bkd_qiter_(win_t) q(win, p);
- for_all (p)
+ for_all(p)
{
i = 0;
- for_all (q)
+ for_all(q)
{
- mln_assertion(bkd[p.element().id()][i] == q.element().id());
+ mln_assertion(expected_bkd_nb[p.id()][i] == q.id());
++i;
}
}
@@ -209,12 +209,12 @@ int main()
// Neighborhood - Forward iteration
mln_niter_(neighb_t) n(neigh, p);
- for_all (p)
+ for_all(p)
{
i = 0;
- for_all (n)
+ for_all(n)
{
- mln_assertion(fwd[p.element().id()][i] == n.element().id());
+ mln_assertion(expected_fwd_nb[p.id()][i] == n.id());
++i;
}
}
@@ -223,12 +223,12 @@ int main()
{
// Neighborhood - Backward iteration
mln_bkd_niter_(neighb_t) n(neigh, p);
- for_all (p)
+ for_all(p)
{
i = 0;
- for_all (n)
+ for_all(n)
{
- mln_assertion(bkd[p.element().id()][i] == n.element().id());
+ mln_assertion(expected_bkd_nb[p.id()][i] == n.id());
++i;
}
}
diff --git a/milena/tests/core/image/line_graph_image.cc b/milena/tests/core/image/line_graph_image.cc
index 36a836f..e7008e7 100644
--- a/milena/tests/core/image/line_graph_image.cc
+++ b/milena/tests/core/image/line_graph_image.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright(C) 2007, 2008 EPITA Research and Development Laboratory(LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -44,19 +44,32 @@
#include <mln/core/var.hh>
+/* The graph and its corresponding line graph are as follows:
+
+ 0 1 2 3 4 0 1 2 3 4
+ .----------- .-----------
+ | |
+ 0 | 0 2 0 | * *
+ 1 | \ / | 1 | 0 1 |
+ 2 | 1 | 2 | * 4
+ 3 | \ | 3 | 2 |
+ 4 | 3-4 4 | *3*
+
+*/
+
// Expected neighbors for forward and backward iteration.
-static unsigned fwd[5][3] = { { 1, 2, -1 },
- { 0, 2, 4 },
- { 0, 1, 3 },
- { 2, 4, -1 },
- { 1, 3, -1 } };
+static unsigned expected_fwd_nbh[5][3] = { { 1, 2, -1 },
+ { 0, 2, 4 },
+ { 0, 1, 3 },
+ { 2, 4, -1 },
+ { 1, 3, -1 } };
-static unsigned bkd[5][3] = { { 2, 1, -1 },
- { 4, 2, 0 },
- { 3, 1, 0 },
- { 4, 2, -1 },
- { 3, 1, -1 } };
+static unsigned expected_bkd_nbh[5][3] = { { 2, 1, -1 },
+ { 4, 2, 0 },
+ { 3, 1, 0 },
+ { 4, 2, -1 },
+ { 3, 1, -1 } };
int main()
@@ -67,19 +80,6 @@ int main()
| Graph. |
`--------*/
- /* The graph and its corresponding line graph are as follows:
-
- 0 1 2 3 4 0 1 2 3 4
- .----------- .-----------
- | |
- 0 | 0 2 0 | * *
- 1 | \ / | 1 | 0 1 |
- 2 | 1 | 2 | * 4
- 3 | \ | 3 | 2 |
- 4 | 3-4 4 | *3*
-
- */
-
// Sites associated to edges.
typedef fun::i2v::array<point2d> fsite_t;
fsite_t sites(5);
@@ -91,7 +91,7 @@ int main()
util::graph g;
// Populate the graph with vertices.
- for (unsigned i = 0; i < sites.size(); ++i)
+ for(unsigned i = 0; i < sites.size(); ++i)
g.add_vertex();
// Populate the graph with edges.
g.add_edge(0, 1);
@@ -114,11 +114,11 @@ int main()
// Graph values.
typedef fun::i2v::array<unsigned> viota_t;
viota_t iota(pe.nsites());
- for (unsigned i = 0; i < iota.size(); ++i)
+ for(unsigned i = 0; i < iota.size(); ++i)
iota(i) = 10 + i;
// Create line graph image.
- mln_const_VAR(ima, (iota | pe));
+ mln_const_VAR(ima,(iota | pe));
/*------------.
| Iterators. |
@@ -130,7 +130,7 @@ int main()
// Manual iteration over the domain of IMA.
mln_piter_(ima_t) p(ima.domain());
unsigned i = 10;
- for_all (p)
+ for_all(p)
mln_assertion(ima(p) == i++);
typedef line_graph_elt_window<util::graph, fsite_t> win_t;
@@ -139,12 +139,12 @@ int main()
{
// Window - Forward iteration
mln_fwd_qiter_(win_t) q(win, p);
- for_all (p)
+ for_all(p)
{
i = 0;
- for_all (q)
+ for_all(q)
{
- mln_assertion(fwd[p.element().id()][i] == q.element().id());
+ mln_assertion(expected_fwd_nbh[p.id()][i] == q.id());
++i;
}
}
@@ -153,12 +153,12 @@ int main()
{
// Window - Backward iteration
mln_bkd_qiter_(win_t) q(win, p);
- for_all (p)
+ for_all(p)
{
i = 0;
- for_all (q)
+ for_all(q)
{
- mln_assertion(bkd[p.element().id()][i] == q.element().id());
+ mln_assertion(expected_bkd_nbh[p.id()][i] == q.id());
++i;
}
}
@@ -171,12 +171,12 @@ int main()
{
// Neighborhood - Forward iteration
mln_fwd_niter_(neighb_t) n(neigh, p);
- for_all (p)
+ for_all(p)
{
i = 0;
- for_all (n)
+ for_all(n)
{
- mln_assertion(fwd[p.element().id()][i] == n.element().id());
+ mln_assertion(expected_fwd_nbh[p.id()][i] == n.id());
++i;
}
}
@@ -185,12 +185,12 @@ int main()
{
// Neighborhood - Backward iteration
mln_bkd_niter_(neighb_t) n(neigh, p);
- for_all (p)
+ for_all(p)
{
i = 0;
- for_all (n)
+ for_all(n)
{
- mln_assertion(bkd[p.element().id()][i] == n.element().id());
+ mln_assertion(expected_bkd_nbh[p.id()][i] == n.id());
++i;
}
}
--
1.5.6.5
1
0
* tests/core/other/category.cc,
* mln/core/macros.hh: update doc.
* mln/core/var.hh: add new macros here.
* tests/core/image/graph_image.cc,
* tests/core/image/line_graph_image.cc: rename variables and fix
coding style.
* tests/core/other/Makefile.am,
* tests/core/other/var.cc: new test to check macros.
---
milena/ChangeLog | 12 ++
milena/mln/core/macros.hh | 7 +-
milena/mln/core/var.hh | 195 ++++++++++++++++++++++++++++++++++-
milena/tests/core/other/Makefile.am | 2 +
milena/tests/core/other/category.cc | 10 +-
milena/tests/core/other/var.cc | 139 +++++++++++++++++++++++++
6 files changed, 351 insertions(+), 14 deletions(-)
create mode 100644 milena/tests/core/other/var.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 0748651..60a03d4 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,15 @@
+2008-12-12 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Add new macros mln_*ITER() to declare iterators.
+
+ * tests/core/other/category.cc,
+ * mln/core/macros.hh: update doc.
+
+ * mln/core/var.hh: add new macros here.
+
+ * tests/core/other/Makefile.am,
+ * tests/core/other/var.cc: new test to check macros.
+
2008-12-11 Guillaume Lazzara <z(a)lrde.epita.fr>
Fix many various tests.
diff --git a/milena/mln/core/macros.hh b/milena/mln/core/macros.hh
index 16ce3fe..ba5702e 100644
--- a/milena/mln/core/macros.hh
+++ b/milena/mln/core/macros.hh
@@ -29,10 +29,9 @@
#ifndef MLN_CORE_MACROS_HH
# define MLN_CORE_MACROS_HH
-/*! \file mln/core/macros.hh
- *
- * \brief Definition of the set of Milena macros.
- */
+/// \file mln/core/macros.hh
+///
+/// Definition of the set of Milena macros.
# define mln_deduce(T, A1, A2) typename T::A1::A2
diff --git a/milena/mln/core/var.hh b/milena/mln/core/var.hh
index dfec471..0b40216 100644
--- a/milena/mln/core/var.hh
+++ b/milena/mln/core/var.hh
@@ -28,13 +28,18 @@
#ifndef MLN_CORE_VAR_HH
# define MLN_CORE_VAR_HH
-/*! \file mln/core/var.hh
- *
- * \brief Definition of the macro mln_VAR. Warning: that macro relies
- * on an extention of g++ (typeof) so it is NOT standard C++.
- */
+/// \file mln/core/var.hh
+///
+/// This file contains various macros to declare variables.
+///
+/// Warning: that macro relies on an extention of g++ (typeof) so it is
+/// NOT standard C++.
+# include <mln/core/macros.hh>
+/// Definition of the macro mln_VAR.
+/// Deduce the type of Expr, create a variable of that type and assign the
+/// result to it.
#define mln_VAR(Var, Expr) \
\
typeof(Expr) Var = Expr; \
@@ -46,4 +51,184 @@
typedef const typeof(Expr) Var##_t
+// mln_PITER
+
+/// Shortcuts to declare site iterators
+/// \{
+#define mln_PITER(p, obj) \
+ typedef typeof(obj) p##__obj_type; \
+ mln_piter(p##__obj_type) p(obj)
+
+#define mln_PITER_(p, obj) \
+ typedef typeof(obj) p##__obj_type; \
+ mln_piter_(p##__obj_type) p(obj)
+/// \}
+
+/// Shortcuts to declare site forward iterators
+/// \{
+#define mln_FWD_PITER(p, obj) \
+ typedef typeof(obj) p##__obj_type; \
+ mln_fwd_piter(p##__obj_type) p(obj)
+
+#define mln_FWD_PITER_(p, obj) \
+ typedef typeof(obj) p##__obj_type; \
+ mln_fwd_piter_(p##__obj_type) p(obj)
+/// \}
+
+/// Shortcuts to declare site backward iterators
+/// \{
+#define mln_BKD_PITER(p, obj) \
+ typedef typeof(obj) p##__obj_type; \
+ mln_bkd_piter(p##__obj_type) p(obj)
+
+#define mln_BKD_PITER_(p, obj) \
+ typedef typeof(obj) p##__obj_type; \
+ mln_bkd_piter_(p##__obj_type) p(obj)
+/// \}
+
+
+// mln_NITER
+
+/// Shortcuts to declare neighbor iterators
+/// \{
+#define mln_NITER(n, obj, p) \
+ typedef typeof(obj) n##__obj_type; \
+ mln_niter(n##__obj_type) n(obj, p)
+
+#define mln_NITER_(n, obj, p) \
+ typedef typeof(obj) n##__obj_type; \
+ mln_niter_(n##__obj_type) n(obj, p)
+/// \}
+
+/// Shortcuts to declare neighbor forward iterators
+/// \{
+#define mln_FWD_NITER(n, obj, p) \
+ typedef typeof(obj) n##__obj_type; \
+ mln_fwd_niter(n##__obj_type) n(obj, p)
+
+#define mln_FWD_NITER_(n, obj, p) \
+ typedef typeof(obj) n##__obj_type; \
+ mln_fwd_niter_(n##__obj_type) n(obj, p)
+/// \}
+
+/// Shortcuts to declare neighbor backward iterators
+/// \{
+#define mln_BKD_NITER(n, obj, p) \
+ typedef typeof(obj) n##__obj_type; \
+ mln_bkd_niter(n##__obj_type) n(obj, p)
+
+#define mln_BKD_NITER_(n, obj, p) \
+ typedef typeof(obj) n##__obj_type; \
+ mln_bkd_niter_(n##__obj_type) n(obj, p)
+/// \}
+
+
+// mln_QITER
+
+/// Shortcuts to declare neighbor iterators on windows
+/// \{
+#define mln_QITER(q, obj, p) \
+ typedef typeof(obj) q##__obj_type; \
+ mln_qiter(q##__obj_type) q(obj, p)
+
+#define mln_QITER_(q, obj, p) \
+ typedef typeof(obj) q##__obj_type; \
+ mln_qiter_(q##__obj_type) q(obj, p)
+/// \}
+
+/// Shortcuts to declare neighbor forward iterators on windows
+/// \{
+#define mln_FWD_QITER(q, obj, p) \
+ typedef typeof(obj) q##__obj_type; \
+ mln_fwd_qiter(q##__obj_type) q(obj, p)
+
+#define mln_FWD_QITER_(q, obj, p) \
+ typedef typeof(obj) q##__obj_type; \
+ mln_fwd_qiter_(q##__obj_type) q(obj, p)
+/// \}
+
+/// Shortcuts to declare neighbor backward iterators on windows
+/// \{
+#define mln_BKD_QITER(q, obj, p) \
+ typedef typeof(obj) q##__obj_type; \
+ mln_bkd_qiter(q##__obj_type) q(obj, p)
+
+#define mln_BKD_QITER_(q, obj, p) \
+ typedef typeof(obj) q##__obj_type; \
+ mln_bkd_qiter_(q##__obj_type) q(obj, p)
+/// \}
+
+
+// mln_EITER
+
+/// Shortcuts to declare element iterators
+/// \{
+#define mln_EITER(e, obj) \
+ typedef typeof(obj) e##__obj_type; \
+ mln_eiter(e##__obj_type) e(obj)
+
+#define mln_EITER_(e, obj) \
+ typedef typeof(obj) e##__obj_type; \
+ mln_eiter_(e##__obj_type) e(obj)
+/// \}
+
+/// Shortcuts to declare element forward iterators
+/// \{
+#define mln_FWD_EITER(e, obj) \
+ typedef typeof(obj) e##__obj_type; \
+ mln_fwd_eiter(e##__obj_type) e(obj)
+
+#define mln_FWD_EITER_(e, obj) \
+ typedef typeof(obj) e##__obj_type; \
+ mln_fwd_eiter_(e##__obj_type) e(obj)
+/// \}
+
+/// Shortcuts to declare element backward iterators
+/// \{
+#define mln_BKD_EITER(e, obj) \
+ typedef typeof(obj) e##__obj_type; \
+ mln_bkd_eiter(e##__obj_type) e(obj)
+
+#define mln_BKD_EITER_(e, obj) \
+ typedef typeof(obj) e##__obj_type; \
+ mln_bkd_eiter_(e##__obj_type) e(obj)
+/// \}
+
+
+// mln_VITER
+
+/// Shortcuts to declare value iterators
+/// \{
+#define mln_VITER(v, obj) \
+ typedef typeof(obj) v##__obj_type; \
+ mln_viter(v##__obj_type) v(obj)
+
+#define mln_VITER_(v, obj) \
+ typedef typeof(obj) v##__obj_type; \
+ mln_viter_(v##__obj_type) v(obj)
+/// \}
+
+/// Shortcuts to declare value forward iterators
+/// \{
+#define mln_FWD_VITER(v, obj) \
+ typedef typeof(obj) v##__obj_type; \
+ mln_fwd_viter(v##__obj_type) v(obj)
+
+#define mln_FWD_VITER_(v, obj) \
+ typedef typeof(obj) v##__obj_type; \
+ mln_fwd_viter_(v##__obj_type) v(obj)
+/// \}
+
+/// Shortcuts to declare value backward iterators
+/// \{
+#define mln_BKD_VITER(v, obj) \
+ typedef typeof(obj) v##__obj_type; \
+ mln_bkd_viter(v##__obj_type) v(obj)
+
+#define mln_BKD_VITER_(v, obj) \
+ typedef typeof(obj) v##__obj_type; \
+ mln_bkd_viter_(v##__obj_type) v(obj)
+/// \}
+
+
#endif // ! MLN_CORE_VAR_HH
diff --git a/milena/tests/core/other/Makefile.am b/milena/tests/core/other/Makefile.am
index e6f3633..018f1e6 100644
--- a/milena/tests/core/other/Makefile.am
+++ b/milena/tests/core/other/Makefile.am
@@ -22,6 +22,7 @@ check_PROGRAMS = \
pixter3d \
pixter3d_more \
point_set_compatibility \
+ var \
w_window
box_runstart_piter_SOURCES = box_runstart_piter.cc
@@ -42,6 +43,7 @@ pixter2d_more_SOURCES = pixter2d_more.cc
pixter3d_SOURCES = pixter3d.cc
pixter3d_more_SOURCES = pixter3d_more.cc
point_set_compatibility_SOURCES = point_set_compatibility.cc
+var_SOURCES = var.cc
w_window_SOURCES = w_window.cc
TESTS = $(check_PROGRAMS)
diff --git a/milena/tests/core/other/category.cc b/milena/tests/core/other/category.cc
index 12d2ac0..3edf612 100644
--- a/milena/tests/core/other/category.cc
+++ b/milena/tests/core/other/category.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,10 +26,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/core/other/category.cc
- *
- * \brief Tests on mln::category.
- */
+/// \file tests/core/other/category.cc
+///
+/// Tests on mln::category.
#include <mln/core/category.hh>
diff --git a/milena/tests/core/other/var.cc b/milena/tests/core/other/var.cc
new file mode 100644
index 0000000..6079142
--- /dev/null
+++ b/milena/tests/core/other/var.cc
@@ -0,0 +1,139 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// \file tests/core/other/var.cc
+///
+/// Tests all macros located in mln/core/var.hh
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/window2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/histo/data.hh>
+#include <mln/util/array.hh>
+
+#include <mln/core/var.hh>
+
+template <typename T>
+void test_template()
+{
+ using namespace mln;
+
+ image2d<T> ima(1,1);
+ neighb2d neighb;
+ window2d win;
+ {
+ mln_PITER(p, ima.domain());
+ mln_NITER(n, neighb, p);
+ mln_QITER(q, win, p);
+ }
+ {
+ mln_FWD_PITER(p, ima.domain());
+ mln_FWD_NITER(n, neighb, p);
+ mln_FWD_QITER(q, win, p);
+ }
+ {
+ mln_BKD_PITER(p, ima.domain());
+ mln_BKD_NITER(n, neighb, p);
+ mln_BKD_QITER(q, win, p);
+ }
+
+ util::array<point2d> arr;
+ {
+ mln_EITER(e, arr);
+ }
+ {
+ mln_FWD_EITER(e, arr);
+ }
+ {
+ mln_BKD_EITER(e, arr);
+ }
+
+ histo::data<bool> d;
+ {
+ mln_VITER(v, d.vset());
+ }
+ {
+ mln_FWD_VITER(v, d.vset());
+ }
+ {
+ mln_BKD_VITER(v, d.vset());
+ }
+
+}
+
+void test()
+{
+ using namespace mln;
+
+ image2d<int> ima(1,1);
+ neighb2d neighb;
+ window2d win;
+ {
+ mln_PITER_(p, ima.domain());
+ mln_NITER_(n, neighb, p);
+ mln_QITER_(q, win, p);
+ }
+ {
+ mln_FWD_PITER_(p, ima.domain());
+ mln_FWD_NITER_(n, neighb, p);
+ mln_FWD_QITER_(q, win, p);
+ }
+ {
+ mln_BKD_PITER_(p, ima.domain());
+ mln_BKD_NITER_(n, neighb, p);
+ mln_BKD_QITER_(q, win, p);
+ }
+
+ util::array<point2d> arr;
+ {
+ mln_EITER_(e, arr);
+ }
+ {
+ mln_FWD_EITER_(e, arr);
+ }
+ {
+ mln_BKD_EITER_(e, arr);
+ }
+
+ histo::data<bool> d;
+ {
+ mln_VITER_(v, d.vset());
+ }
+ {
+ mln_FWD_VITER_(v, d.vset());
+ }
+ {
+ mln_BKD_VITER_(v, d.vset());
+ }
+}
+
+int main()
+{
+ test();
+ test_template<int>();
+}
--
1.5.6.5
1
0
* tests/morpho/hit_or_miss.cc,
* mln/util/tree_to_image.hh,
* mln/topo/internal/complex_iterator_base.hh,
* mln/topo/internal/complex_relative_iterator_sequence.hh,
* mln/topo/algebraic_face.hh,
* mln/core/image/image2d.hh,
* mln/core/image/image2d_h.hh,
* mln/core/alias/complex_geometry.hh,
* mln/accu/count_adjacent_vertices.hh: update comments.
* tests/fun/x2x/rotation.cc,
* mln/value/internal/convert.hh,
* mln/topo/all.hh,
* mln/morpho/opening_area_on_vertices.hh,
* mln/registration/internal/rms.hh,
* mln/morpho/erosion.hh,
* mln/morpho/general.hh,
* mln/morpho/general.spe.hh,
* mln/morpho/closing_area_on_vertices.hh,
* mln/debug/println_with_border.hh,
* mln/fun/p2p/mirror.hh,
* mln/core/site_set/attic/p_complex_faces_piter.hh,
* mln/core/internal/neighb_niter_impl.hh,
* mln/core/image/complex_neighborhood_piter.hh,
* mln/convert/to.hh,
* mln/accu/land_basic.hh,
* mln/accu/lor.hh,
* mln/accu/lor_basic.hh,
* mln/binarization/includes.hh,
* mln/border/get.hh,
* mln/accu/land.hh: add missing/fix includes.
* mln/canvas/browsing/depth_first_search.hh: use template parameter G
instead of util::graph.
* mln/convert/from_to.hh: add a new overload from_to() for conversion
from a type T to itself.
* mln/core/clock_neighb.hh: add a missing typedef window and win()
member.
* mln/core/image/hexa.hh: remove duplicate method has() and try to fix
image properties.
* mln/core/image/hexa_piter.hh: update attribute name.
* mln/core/internal/piter_adaptor.hh: update change_target();
* mln/debug/iota.spe.hh: cleanup.
* mln/debug/println.spe.hh: remove wrong ifndef.
* mln/labeling/relabel.hh: fix infinite recursion.
* mln/metal/has_neighborhood.hh: remove. Not needed anymore.
* mln/morpho/hit_or_miss.hh: improve dispatch and fix a wrong
precondition.
* mln/morpho/line_gradient.hh: update with the new graph structure.
* mln/subsampling/gaussian_subsampling.hh: add missing coma.
* mln/topo/face_iter.hh,
* mln/topo/internal/complex_set_iterator_base.hh,
* mln/topo/internal/complex_relative_iterator_base.hh,
* mln/topo/adj_lower_face_iter.hh,
* mln/topo/adj_lower_higher_face_iter.hh,
* mln/topo/adj_higher_face_iter.hh: add missing forward declarations.
* mln/trait/neighborhood.hh: Fix wrong declaration order.
* tests/morpho/complex_image_wst.cc,
* tests/border/resize_image_if.cc,
* tests/border/get.cc: fix test.
* tests/border/resize_image3d_3.cc: write test.
* tests/core/image/Makefile.am: enable hexa and image2d_h tests.
* tests/core/image/hexa.cc,
* tests/core/image/image2d_h.cc: make the test compile.
* tests/labeling/relabel.cc: fix typo.
* tests/unit_test/build_unit_test.sh: do not compile headers
located in mln/concept/doc.
---
milena/ChangeLog | 93 ++++++++
milena/mln/accu/count_adjacent_vertices.hh | 1 +
milena/mln/accu/land.hh | 1 +
milena/mln/accu/land_basic.hh | 1 +
milena/mln/accu/lor.hh | 1 +
milena/mln/accu/lor_basic.hh | 1 +
milena/mln/binarization/includes.hh | 10 +-
milena/mln/border/get.hh | 11 +-
milena/mln/canvas/browsing/depth_first_search.hh | 9 +-
milena/mln/convert/from_to.hh | 13 +-
milena/mln/convert/to.hh | 1 +
milena/mln/core/alias/complex_geometry.hh | 3 +-
milena/mln/core/clock_neighb.hh | 35 +++-
.../mln/core/image/complex_neighborhood_piter.hh | 4 +-
milena/mln/core/image/hexa.hh | 35 +--
milena/mln/core/image/hexa_piter.hh | 36 ++--
milena/mln/core/image/image2d.hh | 2 +-
milena/mln/core/image/image2d_h.hh | 12 +-
milena/mln/core/internal/neighb_niter_impl.hh | 2 +
milena/mln/core/internal/piter_adaptor.hh | 31 ++--
.../core/site_set/attic/p_complex_faces_piter.hh | 10 +-
milena/mln/debug/iota.spe.hh | 20 +-
milena/mln/debug/println.spe.hh | 49 +++--
milena/mln/debug/println_with_border.hh | 17 +-
milena/mln/fun/p2p/mirror.hh | 7 +
milena/mln/labeling/relabel.hh | 2 +-
milena/mln/metal/has_neighborhood.hh | 53 -----
milena/mln/morpho/closing_area_on_vertices.hh | 15 +-
milena/mln/morpho/erosion.hh | 2 +-
milena/mln/morpho/general.hh | 8 +-
milena/mln/morpho/general.spe.hh | 5 +
milena/mln/morpho/hit_or_miss.hh | 239 ++++++++++++--------
milena/mln/morpho/line_gradient.hh | 71 +++---
milena/mln/morpho/opening_area_on_vertices.hh | 17 +-
milena/mln/registration/internal/rms.hh | 1 +
milena/mln/subsampling/gaussian_subsampling.hh | 2 +-
milena/mln/topo/adj_higher_face_iter.hh | 13 +-
milena/mln/topo/adj_lower_face_iter.hh | 19 ++-
milena/mln/topo/adj_lower_higher_face_iter.hh | 15 +-
milena/mln/topo/algebraic_face.hh | 14 +-
milena/mln/topo/all.hh | 41 ++--
milena/mln/topo/face_iter.hh | 10 +-
milena/mln/topo/internal/complex_iterator_base.hh | 8 +-
.../internal/complex_relative_iterator_base.hh | 15 +-
.../internal/complex_relative_iterator_sequence.hh | 5 +-
.../mln/topo/internal/complex_set_iterator_base.hh | 13 +-
milena/mln/trait/neighborhood.hh | 38 ++--
milena/mln/util/tree_to_image.hh | 47 ++--
milena/mln/value/internal/convert.hh | 11 +-
milena/tests/border/get.cc | 14 +-
milena/tests/border/resize_image3d_3.cc | 37 +--
milena/tests/border/resize_image_if.cc | 10 +-
milena/tests/core/image/Makefile.am | 8 +-
milena/tests/core/image/hexa.cc | 34 ++--
milena/tests/core/image/image2d_h.cc | 28 ++-
milena/tests/fun/x2x/rotation.cc | 2 +-
milena/tests/labeling/relabel.cc | 6 +-
milena/tests/morpho/complex_image_wst.cc | 29 ++--
milena/tests/morpho/hit_or_miss.cc | 14 +-
milena/tests/unit_test/build_unit_test.sh | 2 +-
60 files changed, 735 insertions(+), 518 deletions(-)
delete mode 100644 milena/mln/metal/has_neighborhood.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 926ad95..0748651 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,96 @@
+2008-12-11 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Fix many various tests.
+
+ * tests/morpho/hit_or_miss.cc,
+ * mln/util/tree_to_image.hh,
+ * mln/topo/internal/complex_iterator_base.hh,
+ * mln/topo/internal/complex_relative_iterator_sequence.hh,
+ * mln/topo/algebraic_face.hh,
+ * mln/core/image/image2d.hh,
+ * mln/core/image/image2d_h.hh,
+ * mln/core/alias/complex_geometry.hh,
+ * mln/accu/count_adjacent_vertices.hh: update comments.
+
+ * tests/fun/x2x/rotation.cc,
+ * mln/value/internal/convert.hh,
+ * mln/topo/all.hh,
+ * mln/morpho/opening_area_on_vertices.hh,
+ * mln/registration/internal/rms.hh,
+ * mln/morpho/erosion.hh,
+ * mln/morpho/general.hh,
+ * mln/morpho/general.spe.hh,
+ * mln/morpho/closing_area_on_vertices.hh,
+ * mln/debug/println_with_border.hh,
+ * mln/fun/p2p/mirror.hh,
+ * mln/core/site_set/attic/p_complex_faces_piter.hh,
+ * mln/core/internal/neighb_niter_impl.hh,
+ * mln/core/image/complex_neighborhood_piter.hh,
+ * mln/convert/to.hh,
+ * mln/accu/land_basic.hh,
+ * mln/accu/lor.hh,
+ * mln/accu/lor_basic.hh,
+ * mln/binarization/includes.hh,
+ * mln/border/get.hh,
+ * mln/accu/land.hh: add missing/fix includes.
+
+ * mln/canvas/browsing/depth_first_search.hh: use template parameter G
+ instead of util::graph.
+
+ * mln/convert/from_to.hh: add a new overload from_to() for conversion
+ from a type T to itself.
+
+ * mln/core/clock_neighb.hh: add a missing typedef window and win()
+ member.
+
+ * mln/core/image/hexa.hh: remove duplicate method has() and try to fix
+ image properties.
+
+ * mln/core/image/hexa_piter.hh: update attribute name.
+
+ * mln/core/internal/piter_adaptor.hh: update change_target();
+
+ * mln/debug/iota.spe.hh: cleanup.
+
+ * mln/debug/println.spe.hh: remove wrong ifndef.
+
+ * mln/labeling/relabel.hh: fix infinite recursion.
+
+ * mln/metal/has_neighborhood.hh: remove. Not needed anymore.
+
+
+ * mln/morpho/hit_or_miss.hh: improve dispatch and fix a wrong
+ precondition.
+
+ * mln/morpho/line_gradient.hh: update with the new graph structure.
+
+ * mln/subsampling/gaussian_subsampling.hh: add missing coma.
+
+ * mln/topo/face_iter.hh,
+ * mln/topo/internal/complex_set_iterator_base.hh,
+ * mln/topo/internal/complex_relative_iterator_base.hh,
+ * mln/topo/adj_lower_face_iter.hh,
+ * mln/topo/adj_lower_higher_face_iter.hh,
+ * mln/topo/adj_higher_face_iter.hh: add missing forward declarations.
+
+ * mln/trait/neighborhood.hh: Fix wrong declaration order.
+
+ * tests/morpho/complex_image_wst.cc,
+ * tests/border/resize_image_if.cc,
+ * tests/border/get.cc: fix test.
+
+ * tests/border/resize_image3d_3.cc: write test.
+
+ * tests/core/image/Makefile.am: enable hexa and image2d_h tests.
+
+ * tests/core/image/hexa.cc,
+ * tests/core/image/image2d_h.cc: make the test compile.
+
+ * tests/labeling/relabel.cc: fix typo.
+
+ * tests/unit_test/build_unit_test.sh: do not compile headers
+ located in mln/concept/doc.
+
2008-12-12 Ugo Jardonnet <jardonnet(a)lrde.epita.fr>
Strengthen unit_test. Beautify file generation.
diff --git a/milena/mln/accu/count_adjacent_vertices.hh b/milena/mln/accu/count_adjacent_vertices.hh
index 164a150..382e509 100644
--- a/milena/mln/accu/count_adjacent_vertices.hh
+++ b/milena/mln/accu/count_adjacent_vertices.hh
@@ -30,6 +30,7 @@
# define MLN_ACCU_COUNT_ADJACENT_VERTICES_HH
/// \file mln/accu/count_adjacent_vertices.hh
+///
/// Define an accumulator that counts the vertices adjacent to a
/// set of p_edges psites.
diff --git a/milena/mln/accu/land.hh b/milena/mln/accu/land.hh
index 1b3058e..80a1701 100644
--- a/milena/mln/accu/land.hh
+++ b/milena/mln/accu/land.hh
@@ -35,6 +35,7 @@
///
/// \todo Have land be parameterized.
+# include <mln/core/concept/meta_accumulator.hh>
# include <mln/accu/internal/base.hh>
diff --git a/milena/mln/accu/land_basic.hh b/milena/mln/accu/land_basic.hh
index 831ff4b..ea4a886 100644
--- a/milena/mln/accu/land_basic.hh
+++ b/milena/mln/accu/land_basic.hh
@@ -35,6 +35,7 @@
///
/// \todo Have land_basic be parameterized.
+# include <mln/core/concept/meta_accumulator.hh>
# include <mln/accu/internal/base.hh>
diff --git a/milena/mln/accu/lor.hh b/milena/mln/accu/lor.hh
index 2e74d63..11411d5 100644
--- a/milena/mln/accu/lor.hh
+++ b/milena/mln/accu/lor.hh
@@ -35,6 +35,7 @@
///
/// \todo Have lor be parameterized.
+# include <mln/core/concept/meta_accumulator.hh>
# include <mln/accu/internal/base.hh>
diff --git a/milena/mln/accu/lor_basic.hh b/milena/mln/accu/lor_basic.hh
index 39a9864..896bb39 100644
--- a/milena/mln/accu/lor_basic.hh
+++ b/milena/mln/accu/lor_basic.hh
@@ -35,6 +35,7 @@
///
/// \todo Have lor_basic be parameterized.
+# include <mln/core/concept/meta_accumulator.hh>
# include <mln/accu/internal/base.hh>
diff --git a/milena/mln/binarization/includes.hh b/milena/mln/binarization/includes.hh
index ac01dfb..c191f7d 100644
--- a/milena/mln/binarization/includes.hh
+++ b/milena/mln/binarization/includes.hh
@@ -1,4 +1,5 @@
// Copyright (C) 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,16 +29,13 @@
#ifndef MLN_BINARIZATION_INCLUDES_HH
# define MLN_BINARIZATION_INCLUDES_HH
-/*! \file mln/binarization/includes.hh
- *
- * \brief Basic list of includes for all files in mln/binarization/.
- */
+/// \file mln/binarization/includes.hh
+///
+/// Basic list of includes for all files in mln/binarization/.
# include <mln/core/concept/image.hh>
# include <mln/core/concept/window.hh>
# include <mln/core/concept/neighborhood.hh>
-# include <mln/metal/has_neighborhood.hh>
-
#endif // ! MLN_BINARIZATION_INCLUDES_HH
diff --git a/milena/mln/border/get.hh b/milena/mln/border/get.hh
index 4a6642b..9d752fa 100644
--- a/milena/mln/border/get.hh
+++ b/milena/mln/border/get.hh
@@ -29,13 +29,12 @@
#ifndef MLN_BORDER_GET_HH
# define MLN_BORDER_GET_HH
-/*! \file mln/border/get.hh
- *
- * \brief Define function that returns the real border thickness of image.
- */
+/// \file mln/border/get.hh
+///
+/// Define function that returns the real border thickness of image.
# include <mln/trait/images.hh>
-
+# include <mln/trace/all.hh>
namespace mln
{
@@ -72,7 +71,7 @@ namespace mln
unsigned get_(trait::image::ext_domain::some, trait::image::category::morpher,
const I& ima)
{
- return border::get( *ima.delegatee_() );
+ return border::get(*ima.delegatee_());
}
diff --git a/milena/mln/canvas/browsing/depth_first_search.hh b/milena/mln/canvas/browsing/depth_first_search.hh
index 716be86..a8d840e 100644
--- a/milena/mln/canvas/browsing/depth_first_search.hh
+++ b/milena/mln/canvas/browsing/depth_first_search.hh
@@ -62,7 +62,12 @@
**
*/
+# include <queue>
+# include <mln/core/concept/iterator.hh>
+# include <mln/core/concept/browsing.hh>
# include <mln/core/concept/graph.hh>
+# include <mln/util/vertex.hh>
+
namespace mln
{
@@ -96,7 +101,7 @@ namespace mln
f.init(g);
- mln_vertex_iter(util::graph) v(g);
+ mln_vertex_iter(G) v(g);
for_all(v)
if (f.to_be_treated(v.id()))
{
@@ -105,7 +110,7 @@ namespace mln
f.update_treated(v.id());
while (!queue.empty())
{
- util::vertex<util::graph> current_v = g.vertex(queue.front());
+ util::vertex<G> current_v = g.vertex(queue.front());
queue.pop();
for (unsigned nv = 0; nv < current_v.nmax_nbh_vertices(); ++nv)
if (f.to_be_queued(current_v.ith_nbh_vertex(nv)))
diff --git a/milena/mln/convert/from_to.hh b/milena/mln/convert/from_to.hh
index 877ac7a..1c4761d 100644
--- a/milena/mln/convert/from_to.hh
+++ b/milena/mln/convert/from_to.hh
@@ -63,8 +63,11 @@ namespace mln
template <typename T>
void
- from_to(const float& from, Object<T>& to);
+ from_to(const T& from, T& to);
+ template <typename T>
+ void
+ from_to(const float& from, Object<T>& to);
template <typename T>
void
@@ -87,6 +90,14 @@ namespace mln
mlc_abort(F)::check();
}
+ // T -> T
+ template <typename T>
+ inline
+ void
+ from_to(const T& from, T& to)
+ {
+ to = from;
+ }
// Image -> Site_Set.
template <typename I, typename S>
diff --git a/milena/mln/convert/to.hh b/milena/mln/convert/to.hh
index 9d1ae7d..154084a 100644
--- a/milena/mln/convert/to.hh
+++ b/milena/mln/convert/to.hh
@@ -37,6 +37,7 @@
# include <mln/core/routine/exact.hh>
# include <mln/metal/equal.hh>
# include <mln/trace/all.hh>
+# include <mln/convert/from_to.hh>
# include <mln/convert/from_to.hxx>
diff --git a/milena/mln/core/alias/complex_geometry.hh b/milena/mln/core/alias/complex_geometry.hh
index 3bde2d4..d4e3a75 100644
--- a/milena/mln/core/alias/complex_geometry.hh
+++ b/milena/mln/core/alias/complex_geometry.hh
@@ -29,7 +29,8 @@
# define MLN_CORE_ALIAS_COMPLEX_GEOMETRY_HH
/// \file mln/core/alias/complex_geometry.hh
-/// \brief Definition of mln::geom::complex_geometry aliases.
+///
+/// Definition of mln::geom::complex_geometry aliases.
# include <mln/geom/complex_geometry.hh>
# include <mln/core/alias/point3df.hh>
diff --git a/milena/mln/core/clock_neighb.hh b/milena/mln/core/clock_neighb.hh
index 1e18a8c..be0245c 100644
--- a/milena/mln/core/clock_neighb.hh
+++ b/milena/mln/core/clock_neighb.hh
@@ -35,13 +35,14 @@
# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/window.hh>
# include <mln/core/dpoint.hh>
# include <mln/core/site_set/p_array.hh>
namespace mln
{
- // fwd decls
+ // forward declarations
template <typename D> class dpsites_fwd_piter;
template <typename D> class dpsites_bkd_piter;
@@ -60,6 +61,9 @@ namespace mln
/// Site associated type.
typedef mln_psite(D) site;
+ /// Window associated type.
+ typedef window<dpsite> window;
+
/// Site_Iterator type to browse the psites of a generic
/// neighborhood w.r.t. the ordering of delta-psites.
///
@@ -93,11 +97,15 @@ namespace mln
///
clock_neighb<D>& append(const D& dp);
/// \}
- const std::vector<D>& vect() const
- {
- return vec_;
- }
+ /// Return the dpsites of this neighborhood.
+ const std::vector<D>& vect() const;
+
+ /// Return the corresponding window.
+ /// FIXME: not in constant time!
+ mln::window<D> win() const;
+
+ private:
std::vector<D> vec_;
};
@@ -119,7 +127,24 @@ namespace mln
return *this;
}
+ template <typename D>
+ inline
+ const std::vector<D>&
+ clock_neighb<D>::vect() const
+ {
+ return vec_;
+ }
+ template <typename D>
+ inline
+ window<D>
+ clock_neighb<D>::win() const
+ {
+ window<D> result;
+ for (unsigned i = 0; i < vec_.size(); ++i)
+ result.insert(vec_[i]);
+ return result;
+ }
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
diff --git a/milena/mln/core/image/complex_neighborhood_piter.hh b/milena/mln/core/image/complex_neighborhood_piter.hh
index 4cbf7ab..6c44649 100644
--- a/milena/mln/core/image/complex_neighborhood_piter.hh
+++ b/milena/mln/core/image/complex_neighborhood_piter.hh
@@ -29,8 +29,10 @@
# define MLN_CORE_IMAGE_COMPLEX_NEIGHBORHOOD_PITER_HH
/// \file mln/core/image/complex_neighborhood_piter.hh
-/// \brief Definition of a site iterator on a complex neighborhood.
+///
+/// Definition of a site iterator on a complex neighborhood.
+# include <mln/core/concept/neighborhood.hh>
# include <mln/core/internal/site_relative_iterator_base.hh>
// FIXME: These might be factor-able, both between fwd/bkd and nbh/win.
diff --git a/milena/mln/core/image/hexa.hh b/milena/mln/core/image/hexa.hh
index 3b113ea..433907b 100644
--- a/milena/mln/core/image/hexa.hh
+++ b/milena/mln/core/image/hexa.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -30,11 +31,10 @@
# define MLN_CORE_IMAGE_HEXA_HH
-/*! \file mln/core/image/hexa.hh
- *
- * \brief Definition of a morpher that makes hexagonal the mesh of an
- * image.
- */
+/// \file mln/core/image/hexa.hh
+///
+/// Definition of a morpher that makes hexagonal the mesh of an
+/// image.
# include <mln/core/internal/image_domain_morpher.hh>
# include <mln/core/alias/point2d_h.hh>
@@ -65,7 +65,7 @@ namespace mln
namespace trait
{
-
+ /// FIXME: use the right properties.
template <typename I>
struct image_< hexa<I> > : default_image_morpher< I, mln_value(I),
hexa<I> >
@@ -77,14 +77,14 @@ namespace mln
typedef trait::image::category::domain_morpher category;
+ typedef mln_trait_image_pw_io(I) pw_io; // un-write when I const
+ typedef mln_trait_image_dimension(I) dimension;
- typedef mln_trait_image_border(I) border; // have a border only if I does.
-
- typedef mln_trait_image_io_from_(I) io; // un-write when I const
-
- typedef mln_trait_image_data_from_(I) data;
+ // Extended domain
+ typedef mln_trait_image_ext_domain(I) ext_domain; // have a border only if I does.
+ typedef mln_trait_image_ext_value(I) ext_value;
+ typedef mln_trait_image_ext_io(I) ext_io; // un-write when I const
- typedef trait::image::support::regular support;
// typedef mlc_if( I_data_are_linear_,
// trait::data::stored, // if linear then just stored
// I_data_ ) data; // otherwise like I
@@ -157,7 +157,6 @@ namespace mln
/// Test if \p p belongs to the image domain.
bool has(const psite& p) const;
- bool has(const psite& p) const;
/// Read-only access of pixel value at hexa point site \p p.
rvalue operator()(const point2d_h& p) const;
@@ -267,14 +266,6 @@ namespace mln
}
- template <typename I>
- inline
- bool
- hexa<I>::has(const psite& p) const
- {
- return this->has(p);
- }
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
diff --git a/milena/mln/core/image/hexa_piter.hh b/milena/mln/core/image/hexa_piter.hh
index ad6f36f..222c1e5 100644
--- a/milena/mln/core/image/hexa_piter.hh
+++ b/milena/mln/core/image/hexa_piter.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_CORE_IMAGE_HEXA_PITER_HH
# define MLN_CORE_IMAGE_HEXA_PITER_HH
-/*! \file mln/core/image/hexa_piter.hh
- *
- * \brief Definition of iterators on hexagonal points.
- */
+/// \file mln/core/image/hexa_piter.hh
+///
+/// Definition of iterators on hexagonal points.
# include <mln/core/internal/piter_adaptor.hh>
@@ -42,13 +42,13 @@
namespace mln
{
- /*! \brief A generic forward iterator on points of subsets.
- *
- * Parameter \c S is a point set type; parameter F is a function
- * from point to Boolean.
- *
- * \see mln::hexa
- */
+ /// A generic forward iterator on points of subsets.
+ ///
+ /// Parameter \c S is a point set type; parameter F is a function
+ /// from point to Boolean.
+ ///
+ /// \see mln::hexa
+ ///
template <typename S>
class hexa_fwd_piter_
: public internal::piter_adaptor_< mln_fwd_piter(S),
@@ -111,9 +111,9 @@ namespace mln
void
hexa_fwd_piter_<S>::start()
{
- this->piter_.start();
- p_[0] = this->piter_[0];
- p_[1] = this->piter_[1];
+ this->pi_.start();
+ p_[0] = this->pi_[0];
+ p_[1] = this->pi_[1];
}
template <typename S>
@@ -121,9 +121,9 @@ namespace mln
void
hexa_fwd_piter_<S>::next_()
{
- this->piter_.next();
- p_[0] = this->piter_[0] * 2;
- p_[1] = this->piter_[1] * 2 + this->piter_[0] % 2;
+ this->pi_.next();
+ p_[0] = this->pi_[0] * 2;
+ p_[1] = this->pi_[1] * 2 + this->pi_[0] % 2;
}
template <typename S>
diff --git a/milena/mln/core/image/image2d.hh b/milena/mln/core/image/image2d.hh
index b58dfed..7528a51 100644
--- a/milena/mln/core/image/image2d.hh
+++ b/milena/mln/core/image/image2d.hh
@@ -30,7 +30,7 @@
# define MLN_CORE_IMAGE_IMAGE2D_HH
/// \file mln/core/image/image2d.hh
-/// \brief Definition of the basic mln::image2d class.
+/// Definition of the basic mln::image2d class.
///
/// \todo Re-activate include at EOF when make::image2d is up again.
diff --git a/milena/mln/core/image/image2d_h.hh b/milena/mln/core/image/image2d_h.hh
index e733bc9..f2ba145 100644
--- a/milena/mln/core/image/image2d_h.hh
+++ b/milena/mln/core/image/image2d_h.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,11 +29,10 @@
#ifndef MLN_CORE_IMAGE_IMAGE2D_H_HH
# define MLN_CORE_IMAGE_IMAGE2D_H_HH
-/*! \file mln/core/image/image2d_h.hh
- *
- * \brief Definition of an alias for a 2d image based on an hexagonal
- * mesh.
- */
+/// \file mln/core/image/image2d_h.hh
+///
+/// Definition of an alias for a 2d image based on an hexagonal
+/// mesh.
# include <mln/core/image/image2d.hh>
# include <mln/core/image/hexa.hh>
diff --git a/milena/mln/core/internal/neighb_niter_impl.hh b/milena/mln/core/internal/neighb_niter_impl.hh
index 868e1f8..aa0965d 100644
--- a/milena/mln/core/internal/neighb_niter_impl.hh
+++ b/milena/mln/core/internal/neighb_niter_impl.hh
@@ -32,6 +32,8 @@
///
/// Optional implementation for neigbh_niter.
+# include <mln/core/macros.hh>
+# include <mln/core/internal/force_exact.hh>
namespace mln
{
diff --git a/milena/mln/core/internal/piter_adaptor.hh b/milena/mln/core/internal/piter_adaptor.hh
index a2467dc..5c8e7be 100644
--- a/milena/mln/core/internal/piter_adaptor.hh
+++ b/milena/mln/core/internal/piter_adaptor.hh
@@ -1,4 +1,5 @@
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,15 +29,14 @@
#ifndef MLN_CORE_INTERNAL_PITER_ADAPTOR_HH
# define MLN_CORE_INTERNAL_PITER_ADAPTOR_HH
-/*! \file mln/core/internal/piter_adaptor.hh
- *
- * \brief Definition of iterators on points of boxes.
- *
- * \todo Rename as site_iterator_adaptor_base.
- *
- * \todo Distinguish between adaptors of site_set_iterator,
- * site_relative_iterator, etc. (?)
- */
+/// \file mln/core/internal/piter_adaptor.hh
+///
+/// \brief Definition of iterators on points of boxes.
+///
+/// \todo Rename as site_iterator_adaptor_base.
+///
+/// \todo Distinguish between adaptors of site_set_iterator,
+/// site_relative_iterator, etc. (?)
# include <mln/core/internal/site_iterator_base.hh>
@@ -47,11 +47,11 @@ namespace mln
namespace internal
{
- /*! A base class for point iterator adaptors.
- *
- * Parameter \c Pi is the type of the point iterator adaptee;
- * parameter E is the exact type.
- */
+ /// A base class for point iterator adaptors.
+ ///
+ /// Parameter \c Pi is the type of the point iterator adaptee;
+ /// parameter E is the exact type.
+ ///
template <typename Pi, typename S, typename E>
class piter_adaptor_ : public internal::site_iterator_base< S, E >
{
@@ -78,7 +78,7 @@ namespace mln
/// Hook to the current location.
const mln_psite(S)& p_hook_() const;
- /// Change the site set targeted by this iterator.
+ /// Change the site set targeted by this iterator.
void change_target(const S& s);
/// Change the site set targeted by pi_. This default impl is a
@@ -166,6 +166,7 @@ namespace mln
void
piter_adaptor_<Pi,S,E>::pi_change_target_(const S& s)
{
+ this->pi_.change_target(s);
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/site_set/attic/p_complex_faces_piter.hh b/milena/mln/core/site_set/attic/p_complex_faces_piter.hh
index 936b10e..8c66788 100644
--- a/milena/mln/core/site_set/attic/p_complex_faces_piter.hh
+++ b/milena/mln/core/site_set/attic/p_complex_faces_piter.hh
@@ -37,7 +37,7 @@
# include <mln/core/site_set/p_complex.hh>
# include <mln/core/internal/p_complex_piter_base.hh>
-# include <mln/topo/attic/complex_faces_iter.hh>
+# include <mln/topo/attic/faces_iter.hh>
/* FIXME: p_complex_faces_fwd_piter_ and p_complex_faces_bkd_piter_
are really long names: find something shorter. */
@@ -61,13 +61,13 @@ namespace mln
/// mln::p_complex<D, P>.
template <unsigned N, unsigned D, typename P>
class p_complex_faces_fwd_piter_
- : public internal::p_complex_piter_base_< topo::complex_faces_fwd_iter_<N, D>,
+ : public internal::p_complex_piter_base_< topo::faces_fwd_iter_<N, D>,
p_complex<D, P>,
P,
p_complex_faces_fwd_piter_<N, D, P> >
{
typedef p_complex_faces_fwd_piter_<N, D, P> self_;
- typedef internal::p_complex_piter_base_< topo::complex_faces_fwd_iter_<N, D>,
+ typedef internal::p_complex_piter_base_< topo::faces_fwd_iter_<N, D>,
p_complex<D, P>,
P,
self_ > super_;
@@ -91,13 +91,13 @@ namespace mln
class p_complex_faces_bkd_piter_
/* FIXME: Rename internal::p_complex_piter_base_ to something else,
as it is also used for p_faces piters! */
- : public internal::p_complex_piter_base_< topo::complex_faces_bkd_iter_<N, D>,
+ : public internal::p_complex_piter_base_< topo::faces_bkd_iter_<N, D>,
p_complex<D, P>,
P,
p_complex_faces_bkd_piter_<N, D, P> >
{
typedef p_complex_faces_bkd_piter_<N, D, P> self_;
- typedef internal::p_complex_piter_base_< topo::complex_faces_bkd_iter_<N, D>,
+ typedef internal::p_complex_piter_base_< topo::faces_bkd_iter_<N, D>,
p_complex<D, P>,
P,
self_ > super_;
diff --git a/milena/mln/debug/iota.spe.hh b/milena/mln/debug/iota.spe.hh
index ea52cf4..d0d4a9b 100644
--- a/milena/mln/debug/iota.spe.hh
+++ b/milena/mln/debug/iota.spe.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_DEBUG_IOTA_SPE_HH
# define MLN_DEBUG_IOTA_SPE_HH
-/*! \file mln/debug/iota.spe.hh
- *
- * \brief Specializations for mln::debug::iota.
- */
+/// \file mln/debug/iota.spe.hh
+///
+/// Specializations for mln::debug::iota.
# ifndef MLN_DEBUG_IOTA_HH
# error "Forbidden inclusion of *.spe.hh"
@@ -46,12 +46,16 @@ namespace mln
namespace debug
{
-# ifndef MLN_INCLUDE_ONLY
namespace impl
{
template <typename I>
+ void iota(trait::image::speed::fastest, I& input);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
inline
void
iota(trait::image::speed::fastest, I& input)
@@ -62,10 +66,10 @@ namespace mln
p.val() = ++i % mln_max(mln_value(I));
}
- } // end of namespace mln::debug::impl
-
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::debug::impl
+
} // end of namespace mln::debug
} // end of namespace mln
diff --git a/milena/mln/debug/println.spe.hh b/milena/mln/debug/println.spe.hh
index 7e8ebc7..3d1a188 100644
--- a/milena/mln/debug/println.spe.hh
+++ b/milena/mln/debug/println.spe.hh
@@ -1,4 +1,5 @@
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,12 +29,11 @@
#ifndef MLN_DEBUG_PRINTLN_SPE_HH
# define MLN_DEBUG_PRINTLN_SPE_HH
-/*! \file mln/debug/println.spe.hh
- *
- * \brief Specializations for mln::debug::println.
- *
- * \todo Clean-up code.
- */
+/// \file mln/debug/println.spe.hh
+///
+/// Specializations for mln::debug::println.
+///
+/// \todo Clean-up code.
# ifndef MLN_DEBUG_PRINTLN_HH
# error "Forbidden inclusion of *.spe.hh"
@@ -47,19 +47,35 @@
# include <mln/level/fill.hh>
# include <mln/accu/max.hh>
+//FIXME: do not include all these headers
+# include <mln/core/alias/box2d.hh>
+# include <mln/core/alias/box2d_h.hh>
+# include <mln/core/alias/box3d.hh>
namespace mln
{
+ // Forward declaration.
+ template <typename I> class hexa;
namespace debug
{
-# ifndef MLN_INCLUDE_ONLY
-
namespace impl
{
-# ifdef MLN_CORE_SITE_SET_BOX2D_HH
+ void println(const box2d& b, const image2d<char>& input);
+
+ template <typename I>
+ void println(const box2d& b, const I& input);
+
+ template <typename I>
+ void println(const box2d_h& b, const hexa<I>& input);
+
+ template <typename I>
+ void println(const box3d& b, const I& input);
+
+
+# ifndef MLN_INCLUDE_ONLY
// 2D versions.
@@ -112,16 +128,12 @@ namespace mln
std::cout << std::endl;
}
-# endif // MLN_CORE_SITE_SET_BOX2D_HH
-
-# ifdef MLN_CORE_IMAGE_IMAGE2D_H_HH
-
// Hexa version.
template <typename I>
void
println(const box2d_h& b, const hexa<I>& input)
{
- typename hexa<I>::fwd_piter p(input.domain());
+ mln_piter(hexa<I>) p(input.domain());
int c = 1;
int r = 1;
@@ -147,11 +159,6 @@ namespace mln
std::cout << std::endl;
}
-# endif // MLN_CORE_IMAGE_IMAGE2D_H_HH
-
-
-# ifdef MLN_CORE_SITE_SET_BOX3D_HH
-
// 3D version.
template <typename I>
void
@@ -183,12 +190,10 @@ namespace mln
}
}
-# endif // MLN_CORE_SITE_SET_BOX3D_HH
+# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::debug::impl
-# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln::debug
} // end of namespace mln
diff --git a/milena/mln/debug/println_with_border.hh b/milena/mln/debug/println_with_border.hh
index 52ff01b..589f703 100644
--- a/milena/mln/debug/println_with_border.hh
+++ b/milena/mln/debug/println_with_border.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,18 +29,18 @@
#ifndef MLN_DEBUG_PRINTLN_WITH_BORDER_HH
# define MLN_DEBUG_PRINTLN_WITH_BORDER_HH
-/*! \file mln/debug/println_with_border.hh
- *
- * \brief Print an image on the standard output with its border.
- */
+/// \file mln/debug/println_with_border.hh
+///
+/// Print an image on the standard output with its border.
# include <mln/core/concept/image.hh>
# include <mln/core/concept/window.hh>
-# include <mln/debug/format.hh>
-
# include <mln/core/alias/box2d.hh>
# include <mln/core/alias/box3d.hh>
+# include <mln/geom/bbox.hh>
+
+# include <mln/debug/format.hh>
// Specializations are in:
# include <mln/debug/println_with_border.spe.hh>
@@ -65,7 +66,7 @@ namespace mln
void
println_with_border(const S&, const I& input)
{
- for (size_t i = 0; i < input.nelements(); i++)
+ for (size_t i = 0; i < input.nelements(); i++)
std::cout << format(input.buffer()[i]) << ' ';
std::cout << std::endl;
}
diff --git a/milena/mln/fun/p2p/mirror.hh b/milena/mln/fun/p2p/mirror.hh
index 5c0519c..88b1211 100644
--- a/milena/mln/fun/p2p/mirror.hh
+++ b/milena/mln/fun/p2p/mirror.hh
@@ -1,4 +1,5 @@
// Copyright (C) 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,6 +29,12 @@
#ifndef MLN_FUN_P2P_MIRROR_HH
# define MLN_FUN_P2P_MIRROR_HH
+/// \file mln/fun/p2p/mirror.hh
+///
+/// FIXME: doc
+
+# include <mln/core/concept/function.hh>
+
namespace mln
{
diff --git a/milena/mln/labeling/relabel.hh b/milena/mln/labeling/relabel.hh
index d906a38..551da6d 100644
--- a/milena/mln/labeling/relabel.hh
+++ b/milena/mln/labeling/relabel.hh
@@ -156,7 +156,7 @@ namespace mln
typedef fun::l2l::relabel<mln_value(I)> fl2l_t;
fl2l_t fl2l = make::relabelfun(fl2b, nlabels, new_nlabels);
- mln_concrete(I) output = relabel(label, nlabels, new_nlabels, fl2b);
+ mln_concrete(I) output = labeling::relabel(label, nlabels, new_nlabels, fl2l);
trace::exiting("labeling::relabel");
return output;
diff --git a/milena/mln/metal/has_neighborhood.hh b/milena/mln/metal/has_neighborhood.hh
deleted file mode 100644
index 627db43..0000000
--- a/milena/mln/metal/has_neighborhood.hh
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#ifndef MLN_METAL_HAS_NEIGHBORHOOD_HH
-# define MLN_METAL_HAS_NEIGHBORHOOD_HH
-
-# include <mln/neighb/get.hh>
-
-namespace mln
-{
-
- namespace metal
- {
-
- template <typename I>
- struct has_neighborhood
- {
- static void check()
- {
- // Ensure the image has a `neighb' property.
- typedef mln_neighb(I) neighb;
- }
- };
-
- } // end of namespace mln::metal
-
-} // end of namespace mln
-
-#endif // ! MLN_METAL_HAS_NEIGHBORHOOD_HH
diff --git a/milena/mln/morpho/closing_area_on_vertices.hh b/milena/mln/morpho/closing_area_on_vertices.hh
index 6cd9a10..7af8e6e 100644
--- a/milena/mln/morpho/closing_area_on_vertices.hh
+++ b/milena/mln/morpho/closing_area_on_vertices.hh
@@ -31,10 +31,10 @@
/// \file mln/morpho/closing_area.hh
///
-/// \brief Morphological area closing on a line graph image computing
+/// Morphological area closing on a line graph image computing
/// the area in terms of adjacent vertices.
-# include <mln/core/image/line_graph_image.hh>
+# include <mln/core/site_set/p_edges.hh>
# include <mln/morpho/closing_attribute.hh>
# include <mln/accu/count_adjacent_vertices.hh>
@@ -47,22 +47,23 @@ namespace mln
/// Morphological area closing on a mln::line_graph_image computing
/// the area in terms of adjacent vertices.
- template <typename P, typename V, typename N, typename O>
- void closing_area_on_vertices(const line_graph_image<P, V>& input,
+ template <typename P2V, typename G, typename V2P, typename N, typename O>
+ void closing_area_on_vertices(const pw::image<P2V, p_edges<G, V2P> >& input,
const Neighborhood<N>& nbh,
unsigned lambda, Image<O>& output);
# ifndef MLN_INCLUDE_ONLY
- template <typename P, typename V, typename N, typename O>
+ template <typename P2V, typename G, typename V2P, typename N, typename O>
inline
- void closing_area_on_vertices(const line_graph_image<P, V>& input,
+ void closing_area_on_vertices(const pw::image<P2V, p_edges<G, V2P> >& input,
const Neighborhood<N>& nbh,
unsigned lambda, Image<O>& output)
{
mln_precondition(exact(output).domain() == exact(input).domain());
- typedef accu::count_adjacent_vertices<P, V> attribute_t;
+ typedef p_edges<G, V2P> pe_t;
+ typedef accu::count_adjacent_vertices<P2V, pe_t> attribute_t;
// FIXME: Change sig of closing_attribute!
closing_attribute<attribute_t>(input, nbh, lambda, output);
}
diff --git a/milena/mln/morpho/erosion.hh b/milena/mln/morpho/erosion.hh
index 4f750fe..053e320 100644
--- a/milena/mln/morpho/erosion.hh
+++ b/milena/mln/morpho/erosion.hh
@@ -35,8 +35,8 @@
///
/// \todo The overloads are hidden and I don't know why!
-# include <mln/morpho/includes.hh>
# include <mln/morpho/general.hh>
+# include <mln/morpho/includes.hh>
# include <mln/accu/land.hh>
# include <mln/accu/land_basic.hh>
# include <mln/accu/min.hh>
diff --git a/milena/mln/morpho/general.hh b/milena/mln/morpho/general.hh
index 72ab05d..31905f0 100644
--- a/milena/mln/morpho/general.hh
+++ b/milena/mln/morpho/general.hh
@@ -36,13 +36,17 @@
/// \todo Have infimum and supremum for value types, apart from
/// morphology!
-# include <mln/morpho/includes.hh>
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/window.hh>
+# include <mln/core/concept/neighborhood.hh>
+
+# include <mln/extension/adjust_fill.hh>
+# include <mln/accu/transform.hh>
// Specializations are in:
# include <mln/morpho/general.spe.hh>
-
# define mln_morpho_select_accu(I, S, F) \
typename mln::metal::if_< mln::metal::is< mln_trait_image_kind(I), \
trait::image::kind::binary >, \
diff --git a/milena/mln/morpho/general.spe.hh b/milena/mln/morpho/general.spe.hh
index 784c88c..0ce2112 100644
--- a/milena/mln/morpho/general.spe.hh
+++ b/milena/mln/morpho/general.spe.hh
@@ -39,6 +39,11 @@
# include <mln/win/octagon2d.hh>
# include <mln/win/rectangle2d.hh>
+# include <mln/accu/transform_directional.hh>
+# include <mln/accu/transform_snake.hh>
+# include <mln/accu/transform_stop.hh>
+# include <mln/accu/transform_diagonal.hh>
+
# include <mln/accu/min_h.hh>
# include <mln/accu/line.hh>
diff --git a/milena/mln/morpho/hit_or_miss.hh b/milena/mln/morpho/hit_or_miss.hh
index 38bb1d5..55f08ac 100644
--- a/milena/mln/morpho/hit_or_miss.hh
+++ b/milena/mln/morpho/hit_or_miss.hh
@@ -58,8 +58,8 @@ namespace mln
*/
template <typename I, typename Wh, typename Wm>
mln_concrete(I)
- hit_or_miss(const Image<I>& input,
- const Window<Wh>& win_hit, const Window<Wm>& win_miss);
+ hit_or_miss(const Image<I>& input,
+ const Window<Wh>& win_hit, const Window<Wm>& win_miss);
/// Morphological hit-or-miss opening.
@@ -68,8 +68,8 @@ namespace mln
*/
template <typename I, typename Wh, typename Wm>
mln_concrete(I)
- hit_or_miss_opening(const Image<I>& input,
- const Window<Wh>& win_hit, const Window<Wm>& win_miss);
+ hit_or_miss_opening(const Image<I>& input,
+ const Window<Wh>& win_hit, const Window<Wm>& win_miss);
/// Morphological hit-or-miss opening of the background.
@@ -78,8 +78,8 @@ namespace mln
*/
template <typename I, typename Wh, typename Wm>
mln_concrete(I)
- hit_or_miss_background_opening(const Image<I>& input,
- const Window<Wh>& win_hit, const Window<Wm>& win_miss);
+ hit_or_miss_background_opening(const Image<I>& input,
+ const Window<Wh>& win_hit, const Window<Wm>& win_miss);
/// Morphological hit-or-miss closing.
@@ -88,8 +88,8 @@ namespace mln
*/
template <typename I, typename Wh, typename Wm>
mln_concrete(I)
- hit_or_miss_closing(const Image<I>& input,
- const Window<Wh>& win_hit, const Window<Wm>& win_miss);
+ hit_or_miss_closing(const Image<I>& input,
+ const Window<Wh>& win_hit, const Window<Wm>& win_miss);
/// Morphological hit-or-miss closing of the background.
@@ -98,8 +98,8 @@ namespace mln
*/
template <typename I, typename Wh, typename Wm>
mln_concrete(I)
- hit_or_miss_background_closing(const Image<I>& input,
- const Window<Wh>& win_hit, const Window<Wm>& win_miss);
+ hit_or_miss_background_closing(const Image<I>& input,
+ const Window<Wh>& win_hit, const Window<Wm>& win_miss);
@@ -123,7 +123,6 @@ namespace mln
// Tests.
mln_precondition(input.has_data());
- mln_precondition(win_hit.is_centered());
mln_precondition((win_hit && win_miss).is_empty());
// Avoid warnings.
@@ -138,111 +137,155 @@ namespace mln
namespace impl
{
-
- // Preconditions.
+ // On sets.
template <typename I, typename Wh, typename Wm>
inline
- void hit_or_miss_preconditions_(const Image<I>& input_,
- const Window<Wh>& win_hit_,
- const Window<Wm>& win_miss_)
+ mln_concrete(I)
+ hit_or_miss_logic(const Image<I>& input,
+ const Window<Wh>& win_hit,
+ const Window<Wm>& win_miss)
{
- const I& input = exact(input_);
- const Wh& win_hit = exact(win_hit_);
- const Wm& win_miss = exact(win_miss_);
- mln_precondition(input.has_data());
- mln_precondition((win_hit && win_miss).is_empty());
+ trace::entering("morpho::impl::hit_or_miss_logic");
+ internal::hit_or_miss_tests(input, win_hit, win_miss);
+
+ mln_concrete(I) output = logical::and_(erosion(input, win_hit),
+ erosion(complementation(input),
+ win_miss));
+
+ trace::exiting("morpho::impl::hit_or_miss_logic");
+ return output;
}
- // On sets.
- template <typename I, typename Wh, typename Wm>
- inline
- mln_concrete(I)
- hit_or_miss_(trait::image::kind::logic,
- const I& input,
- const Wh& win_hit, const Wm& win_miss)
+ namespace generic
{
- return logical::and_(erosion(input, win_hit),
- erosion(complementation(input), win_miss));
- }
+ // On functions.
- // On functions.
+ template <typename I, typename Wh, typename Wm>
+ inline
+ mln_concrete(I)
+ hit_or_miss(const Image<I>& input_,
+ const Window<Wh>& win_hit_,
+ const Window<Wm>& win_miss_)
+ {
+ trace::entering("morpho::impl::generic::hit_or_miss");
+ internal::hit_or_miss_tests(input_, win_hit_, win_miss_);
- template <typename I, typename Wh, typename Wm>
- inline
- mln_concrete(I)
- hit_or_miss_(trait::image::kind::any,
- const I& input,
- const Wh& win_hit, const Wm& win_miss)
- {
- typedef mln_value(I) V;
- mln_value(I) zero_V = literal::zero;
+ const I& input = exact(input_);
+ const Wh& win_hit = exact(win_hit_);
+ const Wm& win_miss = exact(win_miss_);
+
+ typedef mln_value(I) V;
+ mln_value(I) zero_V = literal::zero;
- mln_concrete(I) output;
- initialize(output, input);
+ mln_concrete(I) output;
+ initialize(output, input);
- if (constrained_hit_or_miss) // CHMT.
+ if (constrained_hit_or_miss) // CHMT.
{
if (win_hit.is_centered())
- {
- mln_concrete(I)
- ero_fg = erosion(input, win_hit),
- dil_bg = dilation(input, win_miss);
- level::fill(output,
- fun::p2v::ternary(pw::value(input) == pw::value(ero_fg)
- && pw::value(dil_bg) < pw::value(input),
- fun::cast<V>(pw::value(input) - pw::value(dil_bg)),
- pw::cst(zero_V)));
- }
+ {
+ mln_concrete(I)
+ ero_fg = erosion(input, win_hit),
+ dil_bg = dilation(input, win_miss);
+ level::fill(output,
+ fun::p2v::ternary(pw::value(input) == pw::value(ero_fg)
+ && pw::value(dil_bg) < pw::value(input),
+ fun::cast<V>(pw::value(input) - pw::value(dil_bg)),
+ pw::cst(zero_V)));
+ }
else if (win_miss.is_centered())
- {
- mln_concrete(I)
- ero_bg = erosion(input, win_miss),
- dil_fg = dilation(input, win_hit);
- level::fill(output,
- fun::p2v::ternary(pw::value(input) == pw::value(dil_fg)
- && pw::value(ero_bg) > pw::value(input),
- fun::cast<V>(pw::value(ero_bg) - pw::value(input)),
- pw::cst(zero_V)));
- }
+ {
+ mln_concrete(I)
+ ero_bg = erosion(input, win_miss),
+ dil_fg = dilation(input, win_hit);
+ level::fill(output,
+ fun::p2v::ternary(pw::value(input) == pw::value(dil_fg)
+ && pw::value(ero_bg) > pw::value(input),
+ fun::cast<V>(pw::value(ero_bg) - pw::value(input)),
+ pw::cst(zero_V)));
+ }
else
level::fill(output, zero_V);
}
- else // Unconstrained: UHMT.
+ else // Unconstrained: UHMT.
{
mln_concrete(I)
ero = erosion(input, win_hit),
dil = dilation(input, win_miss);
level::fill(output,
fun::p2v::ternary(pw::value(dil) < pw::value(ero),
- fun::cast<V>(pw::value(ero) - pw::value(dil)),
- pw::cst(zero_V)));
+ fun::cast<V>(pw::value(ero) - pw::value(dil)),
+ pw::cst(zero_V)));
}
- return output;
- }
+ trace::exiting("morpho::impl::generic::hit_or_miss");
+ return output;
+ }
+ } // end of namespace mln::morpho::impl::generic
} // end of mln::morpho::impl
+ namespace internal
+ {
+
+ template <typename I, typename Wh, typename Wm>
+ inline
+ mln_concrete(I)
+ hit_or_miss_dispatch(trait::image::kind::any,
+ const Image<I>& input,
+ const Window<Wh>& win_hit,
+ const Window<Wm>& win_miss)
+ {
+ return impl::generic::hit_or_miss(input, win_hit, win_miss);
+ }
+
+ template <typename I, typename Wh, typename Wm>
+ inline
+ mln_concrete(I)
+ hit_or_miss_dispatch(trait::image::kind::logic,
+ const Image<I>& input,
+ const Window<Wh>& win_hit,
+ const Window<Wm>& win_miss)
+ {
+ return impl::hit_or_miss_logic(input, win_hit, win_miss);
+ }
+
+
+ template <typename I, typename Wh, typename Wm>
+ inline
+ mln_concrete(I)
+ hit_or_miss_dispatch(const Image<I>& input,
+ const Window<Wh>& win_hit,
+ const Window<Wm>& win_miss)
+ {
+ return hit_or_miss_dispatch(mln_trait_image_kind(I)(),
+ exact(input),
+ exact(win_hit),
+ exact(win_miss));
+ }
+
+ } // end of namespace mln::morpho::internal
+
template <typename I, typename Wh, typename Wm>
inline
mln_concrete(I)
- hit_or_miss(const Image<I>& input,
- const Window<Wh>& win_hit, const Window<Wm>& win_miss)
+ hit_or_miss(const Image<I>& input,
+ const Window<Wh>& win_hit,
+ const Window<Wm>& win_miss)
{
trace::entering("morpho::hit_or_miss");
internal::hit_or_miss_tests(input, win_hit, win_miss);
- mln_concrete(I) output = impl::hit_or_miss_(mln_trait_image_kind(I)(),
- exact(input),
- exact(win_hit), exact(win_miss));
-
+ mln_concrete(I) output = internal::hit_or_miss_dispatch(input,
+ win_hit,
+ win_miss);
trace::exiting("morpho::hit_or_miss");
return output;
}
@@ -251,14 +294,17 @@ namespace mln
template <typename I, typename Wh, typename Wm>
inline
mln_concrete(I)
- hit_or_miss_opening(const Image<I>& input,
- const Window<Wh>& win_hit, const Window<Wm>& win_miss)
+ hit_or_miss_opening(const Image<I>& input,
+ const Window<Wh>& win_hit,
+ const Window<Wm>& win_miss)
{
trace::entering("morpho::hit_or_miss_opening");
internal::hit_or_miss_tests(input, win_hit, win_miss);
- mln_concrete(I) output = dilation( hit_or_miss(input, win_hit, win_miss),
- win::sym(win_hit) );
+ mln_concrete(I) output = dilation(internal::hit_or_miss_dispatch(input,
+ win_hit,
+ win_miss),
+ win::sym(win_hit));
trace::exiting("morpho::hit_or_miss_opening");
return output;
@@ -268,16 +314,21 @@ namespace mln
template <typename I, typename Wh, typename Wm>
inline
mln_concrete(I)
- hit_or_miss_background_opening(const Image<I>& input,
- const Window<Wh>& win_hit, const Window<Wm>& win_miss)
+ hit_or_miss_background_opening(const Image<I>& input,
+ const Window<Wh>& win_hit,
+ const Window<Wm>& win_miss)
{
trace::entering("morpho::hit_or_miss_background_opening");
internal::hit_or_miss_tests(input, win_hit, win_miss);
- mln_concrete(I) output = hit_or_miss_opening(complementation(input), win_miss, win_hit);
+ mln_concrete(I) output = hit_or_miss_opening(complementation(input),
+ win_miss,
+ win_hit);
- mln_postcondition( dilation( hit_or_miss(input, win_hit, win_miss),
- win::sym(win_miss) ) == output);
+ mln_postcondition(dilation(internal::hit_or_miss_dispatch(input,
+ win_hit,
+ win_miss),
+ win::sym(win_miss)) == output);
trace::exiting("morpho::hit_or_miss_background_opening");
return output;
}
@@ -286,14 +337,16 @@ namespace mln
template <typename I, typename Wh, typename Wm>
inline
mln_concrete(I)
- hit_or_miss_closing(const Image<I>& input,
- const Window<Wh>& win_hit, const Window<Wm>& win_miss)
+ hit_or_miss_closing(const Image<I>& input,
+ const Window<Wh>& win_hit,
+ const Window<Wm>& win_miss)
{
trace::entering("morpho::hit_or_miss_closing");
internal::hit_or_miss_tests(input, win_hit, win_miss);
- mln_concrete(I) output = complementation( hit_or_miss_opening( complementation(input),
- win_hit, win_miss ) );
+ mln_concrete(I) output =
+ complementation(hit_or_miss_opening(complementation(input),
+ win_hit, win_miss));
// FIXME: Postcondition.
trace::exiting("morpho::hit_or_miss_closing");
@@ -304,16 +357,18 @@ namespace mln
template <typename I, typename Wh, typename Wm>
inline
mln_concrete(I)
- hit_or_miss_background_closing(const Image<I>& input,
- const Window<Wh>& win_hit, const Window<Wm>& win_miss)
+ hit_or_miss_background_closing(const Image<I>& input,
+ const Window<Wh>& win_hit,
+ const Window<Wm>& win_miss)
{
trace::entering("morpho::hit_or_miss_background_closing");
internal::hit_or_miss_tests(input, win_hit, win_miss);
mln_concrete(I) output = hit_or_miss_closing(input, win_miss, win_hit);
- mln_postcondition( complementation( hit_or_miss_background_opening( complementation(input),
- win_hit, win_miss ) ) == output );
+ mln_postcondition(complementation(hit_or_miss_background_opening(
+ complementation(input),
+ win_hit, win_miss)) == output);
trace::exiting("morpho::hit_or_miss_background_closing");
return output;
}
diff --git a/milena/mln/morpho/line_gradient.hh b/milena/mln/morpho/line_gradient.hh
index f9b32b2..1d0128a 100644
--- a/milena/mln/morpho/line_gradient.hh
+++ b/milena/mln/morpho/line_gradient.hh
@@ -1,4 +1,5 @@
// Copyright (C) 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -29,7 +30,8 @@
# define MLN_MORPHO_LINE_GRADIENT_HH
/// \file mln/morpho/line_gradient.hh
-/// \brief Conversions to mln::line_graph_image.
+///
+/// Conversions to mln::line_graph_image.
# include <functional>
@@ -42,7 +44,11 @@
# include <mln/core/image/image2d.hh>
# include <mln/core/alias/window2d.hh>
-# include <mln/core/image/line_graph_image.hh>
+
+# include <mln/core/site_set/p_edges.hh>
+
+# include <mln/util/graph.hh>
+# include <mln/util/site_pair.hh>
// FIXME: Generalize to other (input) images as well (image1d,
// image3d, etc.).
@@ -53,68 +59,67 @@ namespace mln
namespace morpho
{
- /// \brief Create a line graph image representing the gradient
+ /// Create a line graph image representing the gradient
/// norm of a mln::image2d.
/* FIXME: Currently, the adjacency is set to 4-c and cannot be
changed. */
- template <typename T>
- mln::line_graph_image<mln::point2d, T>
- line_gradient(const mln::image2d<T>& ima);
+ template <typename F, typename S>
+ mln::pw::image<F, S>
+ line_gradient(const mln::image2d<mln_result(F)>& ima);
# ifndef MLN_INCLUDE_ONLY
- template <typename T>
- mln::line_graph_image<mln::point2d, T>
- line_gradient(const mln::image2d<T>& ima)
+ template <typename F, typename S>
+ mln::pw::image<F, S>
+ line_gradient(const mln::image2d<mln_result(F)>& ima)
{
// FIXME: Precondition: Ensure the image is scalar.
- typedef T value_t;
+ typedef mln_result(F) value_t;
- util::graph<mln::point2d> g;
-
- // Points.
- /* FIXME: The need for such a structure during the conversion
- exhibits the lack of a service from util::graph (or a another,
- missing tool) regarding the retrieval of vertices' ids from
- points. */
- std::map< mln::point2d, util::vertex_id, util::ord<point2d> > points;
+ util::graph g;
// Vertices.
- std::vector<value_t> vertex_values;
+ image2d<unsigned> vpsite(ima.domain());
+ fun::i2v::array<mln::point2d> fv2p(ima.domain().nsites());
+ fun::i2v::array<value_t> vertex_values(ima.domain().nsites());
+
mln_fwd_piter(image2d<value_t>) p(ima.domain());
for_all (p)
{
- util::vertex_id id = g.add_vertex (p);
- vertex_values.push_back (ima(p));
- points[p] = id;
+ g.add_vertex();
+ unsigned id = g.v_nmax() - 1;
+ vpsite[p] = id;
+ fv2p(id) = p;
}
// Edges.
// FIXME: The creation of this window should be generic.
window2d next_c4_win;
next_c4_win.insert(0, 1).insert(1, 0);
- std::vector<value_t> edge_values;
- mln_fwd_qiter_(window2d) q(next_c4_win, p);
+ typedef fun::i2v::array<value_t> edge_values_t;
+ typedef fun::i2v::array< util::site_pair<point2d> > edge_sites_t;
+ edge_values_t edge_values;
+ edge_sites_t edge_sites;
+ mln_fwd_qiter_(window2d) q(next_c4_win, p);
for_all (p)
for_all (q)
if (ima.domain().has(q))
{
- util::edge_id id = g.add_edge(points[p], points[q]);
- // Avoid a warning about an undefined variable when NDEBUG
- // is not defined.
- (void) id;
+ g.add_edge(vpsite(p), vpsite(q));
// The computed value is a norm of the gradient between P and Q.
- edge_values.push_back(math::abs(ima(p) - ima(q)));
- mln_assertion(id != mln_max(util::edge_id::equiv));
+ unsigned edge_id = edge_values.size();
+ edge_values.resize(edge_values.size() + 1);
+ edge_values(edge_id) = math::abs(ima(p) - ima(q));
}
// Line graph point set.
- p_line_graph<mln::point2d> plg(g);
+ typedef p_edges<util::graph, edge_sites_t> pe_t;
+ pe_t plg(g, edge_sites);
// Line graph image.
- typedef line_graph_image<mln::point2d, value_t> ima_t;
- ima_t lg_ima(plg, vertex_values, edge_values);
+ typedef pw::image<edge_values_t, pe_t> ima_t;
+ ima_t lg_ima = (edge_values | plg);
return lg_ima;
}
diff --git a/milena/mln/morpho/opening_area_on_vertices.hh b/milena/mln/morpho/opening_area_on_vertices.hh
index d6e7234..b8e420e 100644
--- a/milena/mln/morpho/opening_area_on_vertices.hh
+++ b/milena/mln/morpho/opening_area_on_vertices.hh
@@ -30,10 +30,12 @@
# define MLN_MORPHO_OPENING_AREA_ON_VERTICES_HH
/// \file mln/morpho/opening_area_on_vertices.hh
-/// \brief Morphological area opening on a line graph image computing
+///
+/// Morphological area opening on a line graph image computing
/// the area in terms of adjacent vertices.
-# include <mln/core/image/line_graph_image.hh>
+# include <mln/pw/image.hh>
+# include <mln/core/site_set/p_edges.hh>
# include <mln/morpho/opening_attribute.hh>
# include <mln/accu/count_adjacent_vertices.hh>
@@ -46,22 +48,23 @@ namespace mln
/// Morphological area opening on a mln::line_graph_image computing
/// the area in terms of adjacent vertices.
- template <typename P, typename V, typename N, typename O>
- void opening_area_on_vertices(const line_graph_image<P, V>& input,
+ template <typename P2V, typename G, typename V2P, typename N, typename O>
+ void opening_area_on_vertices(const pw::image<P2V, p_edges<G, V2P> >& input,
const Neighborhood<N>& nbh,
unsigned lambda, Image<O>& output);
# ifndef MLN_INCLUDE_ONLY
- template <typename P, typename V, typename N, typename O>
+ template <typename P2V, typename G, typename V2P, typename N, typename O>
inline
- void opening_area_on_vertices(const line_graph_image<P, V>& input,
+ void opening_area_on_vertices(const pw::image<P2V, p_edges<G, V2P> >& input,
const Neighborhood<N>& nbh,
unsigned lambda, Image<O>& output)
{
mln_precondition(exact(output).domain() == exact(input).domain());
- typedef accu::count_adjacent_vertices<P, V> attribute_t;
+ typedef p_edges<G, V2P> pe_t;
+ typedef accu::count_adjacent_vertices<P2V, pe_t> attribute_t;
// FIXME: Change sig of opening_attribute!
opening_attribute<attribute_t>(input, nbh, lambda, output);
}
diff --git a/milena/mln/registration/internal/rms.hh b/milena/mln/registration/internal/rms.hh
index f5b8579..375ff79 100644
--- a/milena/mln/registration/internal/rms.hh
+++ b/milena/mln/registration/internal/rms.hh
@@ -28,6 +28,7 @@
#ifndef MLN_REGISTRATION_INTERNAL_RMS_HH
# define MLN_REGISTRATION_INTERNAL_RMS_HH
+# include <mln/norm/l2.hh>
# include <mln/core/site_set/p_array.hh>
namespace mln
diff --git a/milena/mln/subsampling/gaussian_subsampling.hh b/milena/mln/subsampling/gaussian_subsampling.hh
index b4aa2e0..4e20a1b 100644
--- a/milena/mln/subsampling/gaussian_subsampling.hh
+++ b/milena/mln/subsampling/gaussian_subsampling.hh
@@ -52,7 +52,7 @@ namespace mln
template <typename I>
inline
mln_concrete(I)
- gaussian_subsampling(const Image<I>& input, float sigma
+ gaussian_subsampling(const Image<I>& input, float sigma,
const mln_dpsite(I)& first_p,
const mln_deduce(I, site, coord)& gap);
diff --git a/milena/mln/topo/adj_higher_face_iter.hh b/milena/mln/topo/adj_higher_face_iter.hh
index e51d678..0cac258 100644
--- a/milena/mln/topo/adj_higher_face_iter.hh
+++ b/milena/mln/topo/adj_higher_face_iter.hh
@@ -29,7 +29,8 @@
# define MLN_TOPO_ADJ_HIGHER_FACE_ITER_HH
/// \file mln/topo/adj_higher_face_iter.hh
-/// \brief Definition of forward and backward iterators on the
+///
+/// Definition of forward and backward iterators on the
/// adjacent (n+1)-faces of a (reference) n-face in a complex.
# include <mln/topo/internal/complex_relative_iterator_base.hh>
@@ -42,9 +43,17 @@ namespace mln
namespace topo
{
- // Forward declaration.
+ // Forward declarations.
template <unsigned D> class complex;
+ namespace internal
+ {
+
+ template <typename F, typename E>
+ class complex_iterator_base;
+
+ } // end of namespace mln::topo::internal
+
/*------------------------------------.
| topo::adj_higher_face_fwd_iter<D>. |
diff --git a/milena/mln/topo/adj_lower_face_iter.hh b/milena/mln/topo/adj_lower_face_iter.hh
index 88cc8f2..23bcc36 100644
--- a/milena/mln/topo/adj_lower_face_iter.hh
+++ b/milena/mln/topo/adj_lower_face_iter.hh
@@ -29,7 +29,7 @@
# define MLN_TOPO_ADJ_LOWER_FACE_ITER_HH
/// \file mln/topo/adj_lower_face_iter.hh
-/// \brief Definition of forward and backward iterators on the
+/// Definition of forward and backward iterators on the
/// adjacent (n-1)-faces of a (reference) n-face in a complex.
# include <mln/topo/internal/complex_relative_iterator_base.hh>
@@ -42,15 +42,26 @@ namespace mln
namespace topo
{
- // Forward declaration.
+ // Forward declarations.
template <unsigned D> class complex;
+ namespace internal
+ {
+
+ template <typename C, typename F, typename E>
+ class forward_complex_relative_iterator_base;
+
+ template <typename C, typename F, typename E>
+ class backward_complex_relative_iterator_base;
+
+ } // end of namespace mln::topo::internal
+
/*-----------------------------------.
| topo::adj_lower_face_fwd_iter<D>. |
`-----------------------------------*/
- /// \brief Forward iterator on all the adjacent (n-1)-faces of the
+ /// Forward iterator on all the adjacent (n-1)-faces of the
/// n-face of an mln::complex<D>.
///
/// \arg \p D The dimension of the complex this iterator belongs to.
@@ -83,7 +94,7 @@ namespace mln
| topo::adj_lower_face_bkd_iter<D>. |
`-----------------------------------*/
- /// \brief Backward iterator on all the adjacent (n-1)-faces of the
+ /// Backward iterator on all the adjacent (n-1)-faces of the
/// n-face of an mln::complex<D>.
///
/// \arg \p D The dimension of the complex this iterator belongs to.
diff --git a/milena/mln/topo/adj_lower_higher_face_iter.hh b/milena/mln/topo/adj_lower_higher_face_iter.hh
index dcd11c2..f3c28c3 100644
--- a/milena/mln/topo/adj_lower_higher_face_iter.hh
+++ b/milena/mln/topo/adj_lower_higher_face_iter.hh
@@ -29,7 +29,8 @@
# define MLN_TOPO_ADJ_LOWER_HIGHER_FACE_ITER_HH
/// \file mln/topo/adj_lower_higher_face_iter.hh
-/// \brief Definition of forward and backward iterators on all the
+///
+/// Definition of forward and backward iterators on all the
/// adjacent (n-1)-faces and (n+1)-faces of a (reference) n-face in a
/// complex.
@@ -47,12 +48,20 @@ namespace mln
// Forward declaration.
template <unsigned D> class complex;
+ namespace internal
+ {
+
+ template <typename I1, typename I2, typename E>
+ class complex_relative_iterator_sequence;
+
+ } // end of namespace mln::topo::internal
+
/*------------------------------------------.
| topo::adj_lower_higher_face_fwd_iter<D>. |
`------------------------------------------*/
- /// \brief Forward iterator on all the adjacent (n-1)-faces and
+ /// Forward iterator on all the adjacent (n-1)-faces and
/// (n+1)-faces of the n-face of an mln::complex<D>.
///
/// \arg \p D The dimension of the complex this iterator belongs to.
@@ -83,7 +92,7 @@ namespace mln
| topo::adj_lower_higher_face_bkd_iter<D>. |
`------------------------------------------*/
- /// \brief Forward iterator on all the adjacent (n-1)-faces and
+ /// Forward iterator on all the adjacent (n-1)-faces and
/// (n+1)-faces of the n-face of an mln::complex<D>.
///
/// \arg \p D The dimension of the complex this iterator belongs to.
diff --git a/milena/mln/topo/algebraic_face.hh b/milena/mln/topo/algebraic_face.hh
index 1c666ac..03768f8 100644
--- a/milena/mln/topo/algebraic_face.hh
+++ b/milena/mln/topo/algebraic_face.hh
@@ -29,9 +29,11 @@
# define MLN_TOPO_ALGEBRAIC_FACE_HH
/// \file mln/topo/algebraic_face.hh
-/// \brief Algebraic face of a complex.
+///
+/// Algebraic face of a complex.
#include <mln/topo/face.hh>
+#include <mln/topo/algebraic_n_face.hh>
namespace mln
@@ -44,13 +46,13 @@ namespace mln
template <unsigned D> class complex;
template <unsigned N, unsigned D> class n_face;
template <unsigned N, unsigned D> class face_data;
-
+
/*-------.
| Face. |
`-------*/
- /// \brief Algebraic face handle in a complex; the face dimension
+ /// Algebraic face handle in a complex; the face dimension
/// is dynamic.
///
/// Contrary to an mln::topo::algebraic_n_face, the dimension of an
@@ -111,7 +113,7 @@ namespace mln
/// Comparison of two instances of mln::topo::algebraic_face.
/// \{
- /// \brief Is \a lhs equal to \a rhs?
+ /// Is \a lhs equal to \a rhs?
///
/// \pre Arguments \a lhs and \a rhs must belong to the same
/// mln::topo::complex.
@@ -119,7 +121,7 @@ namespace mln
bool operator==(const algebraic_face<D>& lhs,
const algebraic_face<D>& rhs);
- /// \brief Is \a lhs different from \a rhs?
+ /// Is \a lhs different from \a rhs?
///
/// \pre Arguments \a lhs and \a rhs must belong to the same
/// mln::topo::complex.
@@ -127,7 +129,7 @@ namespace mln
bool operator!=(const algebraic_face<D>& lhs,
const algebraic_face<D>& rhs);
- /// \brief Is \a lhs ``less'' than \a rhs?
+ /// Is \a lhs ``less'' than \a rhs?
///
/// This comparison is required by algorithms sorting algebraic
/// face handles.
diff --git a/milena/mln/topo/all.hh b/milena/mln/topo/all.hh
index 2d06897..8f61744 100644
--- a/milena/mln/topo/all.hh
+++ b/milena/mln/topo/all.hh
@@ -1,4 +1,5 @@
// Copyright (C) 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_TOPO_ALL_HH
# define MLN_TOPO_ALL_HH
-/*! \file mln/topo/all.hh
- *
- * \brief File that includes all "point-wise" expression tools.
- */
+/// \file mln/topo/all.hh
+///
+/// File that includes all topology related algorithms.
namespace mln
@@ -42,22 +42,21 @@ namespace mln
} // end of namespace mln
-
-# include <mln/core/topo/adj_higher_dim_connected_n_face_iter.hh>
-# include <mln/core/topo/adj_higher_face_iter.hh>
-# include <mln/core/topo/adj_lower_dim_connected_n_face_iter.hh>
-# include <mln/core/topo/adj_lower_face_iter.hh>
-# include <mln/core/topo/adj_lower_higher_face_iter.hh>
-# include <mln/core/topo/center_only_iter.hh>
-# include <mln/core/topo/centered_iter_adapter.hh>
-# include <mln/core/topo/complex.hh>
-# include <mln/core/topo/complex_iterators.hh>
-# include <mln/core/topo/face.hh>
-# include <mln/core/topo/face_data.hh>
-# include <mln/core/topo/face_iter.hh>
-# include <mln/core/topo/n_face.hh>
-# include <mln/core/topo/n_face_iter.hh>
-# include <mln/core/topo/n_faces_set.hh>
-# include <mln/core/topo/static_n_face_iter>
+# include <mln/topo/attic/faces_iter.hh>
+# include <mln/topo/adj_higher_dim_connected_n_face_iter.hh>
+# include <mln/topo/adj_higher_face_iter.hh>
+# include <mln/topo/adj_lower_dim_connected_n_face_iter.hh>
+# include <mln/topo/adj_lower_face_iter.hh>
+# include <mln/topo/adj_lower_higher_face_iter.hh>
+# include <mln/topo/center_only_iter.hh>
+# include <mln/topo/centered_iter_adapter.hh>
+# include <mln/topo/complex.hh>
+# include <mln/topo/complex_iterators.hh>
+# include <mln/topo/face.hh>
+# include <mln/topo/face_data.hh>
+# include <mln/topo/face_iter.hh>
+# include <mln/topo/n_face.hh>
+# include <mln/topo/n_face_iter.hh>
+# include <mln/topo/n_faces_set.hh>
#endif // ! MLN_TOPO_ALL_HH
diff --git a/milena/mln/topo/face_iter.hh b/milena/mln/topo/face_iter.hh
index 4030594..a9b2665 100644
--- a/milena/mln/topo/face_iter.hh
+++ b/milena/mln/topo/face_iter.hh
@@ -45,9 +45,17 @@ namespace mln
namespace topo
{
- // Forward declaration.
+ // Forward declarations.
template <unsigned D> class complex;
+ namespace internal
+ {
+
+ template <typename F, typename E>
+ class complex_set_iterator_base;
+
+ } // end of namespace mln::topo::internal
+
/*-------------------------.
| topo::face_fwd_iter<D>. |
diff --git a/milena/mln/topo/internal/complex_iterator_base.hh b/milena/mln/topo/internal/complex_iterator_base.hh
index ceb86f3..cd98fba 100644
--- a/milena/mln/topo/internal/complex_iterator_base.hh
+++ b/milena/mln/topo/internal/complex_iterator_base.hh
@@ -21,7 +21,7 @@
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
-// License.
+// License.
// reasons why the executable file might be covered by the GNU General
// Public License.
@@ -29,7 +29,7 @@
# define MLN_TOPO_INTERNAL_COMPLEX_ITERATOR_BASE_HH
/** \file mln/topo/internal/complex_iterator_base.hh
- \brief Definition of an implementation (factoring) class for
+ Definition of an implementation (factoring) class for
iterators on complexes.
Concrete iterators should inherit either from
@@ -69,7 +69,7 @@ namespace mln
namespace internal
{
- /// \brief Factoring class for iterators on mln::complex.
+ /// Factoring class for iterators on mln::complex.
///
/// \arg \p F The type of the face handle.
/// \arg \p E The type exact type of the iterator.
@@ -82,7 +82,7 @@ namespace mln
/// The type of the iterated faces.
typedef F face;
- /// \brief Conversion.
+ /// Conversion.
///
/// Return a reference to the corresponding face handle.
/// \{
diff --git a/milena/mln/topo/internal/complex_relative_iterator_base.hh b/milena/mln/topo/internal/complex_relative_iterator_base.hh
index 4925952..c795043 100644
--- a/milena/mln/topo/internal/complex_relative_iterator_base.hh
+++ b/milena/mln/topo/internal/complex_relative_iterator_base.hh
@@ -21,7 +21,7 @@
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
-// License.
+// License.
// reasons why the executable file might be covered by the GNU General
// Public License.
@@ -29,7 +29,7 @@
# define MLN_TOPO_INTERNAL_COMPLEX_RELATIVE_ITERATOR_BASE_HH
/** \file mln/topo/internal/complex_relative_iterator_base.hh
- \brief Definition of an implementation (factoring) class for
+ Definition of an implementation (factoring) class for
iterators on mln::complex.
The hierarchy of classes in this file is as follows
@@ -68,11 +68,16 @@ namespace mln
namespace internal
{
+ // Forward declaration.
+ template <typename F, typename E>
+ class complex_iterator_base;
+
+
/*----------------------------------------------------------.
| topo::internal::complex_relative_iterator_base<C, F, E>. |
`----------------------------------------------------------*/
- /// \brief Factoring class for relative iterators on mln::complex.
+ /// Factoring class for relative iterators on mln::complex.
///
/// \arg \p C The type of the center face handle.
/// \arg \p F The type of the face handle.
@@ -124,7 +129,7 @@ namespace mln
| topo::internal::forward_complex_relative_iterator_base<C, F, E>. |
`------------------------------------------------------------------*/
- /// \brief Factoring class for forward relative iterators on
+ /// Factoring class for forward relative iterators on
/// mln::complex.
///
/// \arg \p C The type of the center face handle.
@@ -175,7 +180,7 @@ namespace mln
| topo::internal::backward_complex_relative_iterator_base<C, F, E>. |
`-------------------------------------------------------------------*/
- /// \brief Factoring class for backward relative iterators on
+ /// Factoring class for backward relative iterators on
/// mln::complex.
///
/// \arg \p C The type of the center face handle.
diff --git a/milena/mln/topo/internal/complex_relative_iterator_sequence.hh b/milena/mln/topo/internal/complex_relative_iterator_sequence.hh
index 57b4843..c3574d0 100644
--- a/milena/mln/topo/internal/complex_relative_iterator_sequence.hh
+++ b/milena/mln/topo/internal/complex_relative_iterator_sequence.hh
@@ -29,7 +29,8 @@
# define MLN_TOPO_INTERNAL_COMPLEX_RELATIVE_ITERATOR_SEQUENCE_HH
/// \file mln/topo/internal/complex_relative_iterator_sequence.hh
-/// \brief Definition of a meta complex relative iterator using two
+///
+/// Definition of a meta complex relative iterator using two
/// complex relative iterators sequentially.
# include <iosfwd>
@@ -48,7 +49,7 @@ namespace mln
namespace internal
{
- /// \brief A meta relative iterator on the faces of a complex
+ /// A meta relative iterator on the faces of a complex
/// using two complex relative iterators sequentially.
///
/// The first relative iterator is used, and when it becomes
diff --git a/milena/mln/topo/internal/complex_set_iterator_base.hh b/milena/mln/topo/internal/complex_set_iterator_base.hh
index c04f5cd..231cb8a 100644
--- a/milena/mln/topo/internal/complex_set_iterator_base.hh
+++ b/milena/mln/topo/internal/complex_set_iterator_base.hh
@@ -21,7 +21,7 @@
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
-// License.
+// License.
// reasons why the executable file might be covered by the GNU General
// Public License.
@@ -29,7 +29,8 @@
# define MLN_TOPO_INTERNAL_COMPLEX_SET_ITERATOR_BASE_HH
/// \file mln/topo/internal/complex_set_iterator_base.hh
-/// \brief Definition of an implementation (factoring) class for
+///
+/// Definition of an implementation (factoring) class for
/// (set) iterators on faces of a complex.
# include <mln/topo/internal/complex_iterator_base.hh>
@@ -43,7 +44,13 @@ namespace mln
namespace internal
{
- /// \brief Factoring class for (set) iterators on mln::complex.
+
+ // Forward declaration.
+ template <typename F, typename E>
+ class complex_iterator_base;
+
+
+ /// Factoring class for (set) iterators on mln::complex.
///
/// \arg \p F The type of the face handle.
/// \arg \p E The type exact type of the iterator.
diff --git a/milena/mln/trait/neighborhood.hh b/milena/mln/trait/neighborhood.hh
index 56db0c9..1c605b5 100644
--- a/milena/mln/trait/neighborhood.hh
+++ b/milena/mln/trait/neighborhood.hh
@@ -29,7 +29,8 @@
# define MLN_TRAIT_NEIGHBORHOOD_HH
/// \file mln/trait/neighborhood.hh
-/// \brief Some base trait types for neighborhood types.
+///
+/// Some base trait types for neighborhood types.
# include <string>
@@ -52,23 +53,6 @@ namespace mln
// Forward declaration.
struct undef;
- struct undefined_neighborhood
- {
- typedef undef kind;
- };
-
-
- struct default_neighborhood : undefined_neighborhood
- {
- typedef trait::neighborhood::kind::generic kind;
- };
-
-
- template <typename V>
- struct neighborhood : default_neighborhood
- {
- };
-
/*----------------.
| Traits values. |
@@ -106,6 +90,24 @@ namespace mln
}
+
+ struct undefined_neighborhood_
+ {
+ typedef undef kind;
+ };
+
+
+ struct default_neighborhood_ : undefined_neighborhood_
+ {
+ typedef trait::neighborhood::kind::generic kind;
+ };
+
+
+ template <typename V>
+ struct neighborhood_ : default_neighborhood_
+ {
+ };
+
} // end of namespace mln::trait
} // end of namespace mln
diff --git a/milena/mln/util/tree_to_image.hh b/milena/mln/util/tree_to_image.hh
index 21004fd..40b31ae 100644
--- a/milena/mln/util/tree_to_image.hh
+++ b/milena/mln/util/tree_to_image.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,13 +29,10 @@
#ifndef MLN_UTIL_TREE_TO_IMAGE_HH
# define MLN_UTIL_TREE_TO_IMAGE_HH
-/*!
- * \file mln/util/tree_to_image.hh
- *
- * \brief Definition of function which transform a tree into an
- * image.
- *
- */
+/// \file mln/util/tree_to_image.hh
+///
+/// Definition of function which transform a tree into an
+/// image.
# include <mln/core/concept/image.hh>
# include <mln/util/tree.hh>
@@ -47,33 +45,30 @@ namespace mln
namespace util
{
- /*! \brief Convert a tree into an image.
- *
- * \param[in] tree The tree to convert.
- * \param[out] output_ The image containing tree informations.
- *
- */
+ /// Convert a tree into an image.
+ ///
+ /// \param[in] tree The tree to convert.
+ /// \param[out] output_ The image containing tree informations.
+ ///
template <typename T, typename I>
void
tree_to_image (tree<T>& tree, Image<I>& output_);
- /*! Display a tree.
- *
- * \param[in] ima_ The domain of output image.
- * \param[in] tree The tree to display.
- *
- */
+ /// Display a tree.
+ ///
+ /// \param[in] ima_ The domain of output image.
+ /// \param[in] tree The tree to display.
+ ///
template <typename I, typename J>
void
display_tree(const Image<J>& ima_, tree<I>& tree);
- /*! Display an arborescence from \p tree_node.
- *
- * \param[in] ima_ The domain of output image.
- * \param[in] tree_node The root tree_node to display.
- *
- */
+ /// Display an arborescence from \p tree_node.
+ ///
+ /// \param[in] ima_ The domain of output image.
+ /// \param[in] tree_node The root tree_node to display.
+ ///
template <typename I, typename J>
void
display_branch(const Image<J>& ima_, tree_node<I>* tree_node);
diff --git a/milena/mln/value/internal/convert.hh b/milena/mln/value/internal/convert.hh
index fc5b50f..0d3c1c4 100644
--- a/milena/mln/value/internal/convert.hh
+++ b/milena/mln/value/internal/convert.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,11 +29,11 @@
#ifndef MLN_VALUE_INTERNAL_CONVERT_HH
# define MLN_VALUE_INTERNAL_CONVERT_HH
-/*! \file mln/value/internal/convert.hh
- *
- * \brief Define a conversion between an index and an iterable value.
- */
+/// \file mln/value/internal/convert.hh
+///
+/// Define a conversion between an index and an iterable value.
+# include <mln/core/contract.hh>
# include <mln/trait/value_.hh>
diff --git a/milena/tests/border/get.cc b/milena/tests/border/get.cc
index 88d552a..9cc6602 100644
--- a/milena/tests/border/get.cc
+++ b/milena/tests/border/get.cc
@@ -66,17 +66,17 @@ int main()
I ima(3,3, 51);
mln_assertion(border::get(ima) == 51);
- mln_assertion( ima.has(point2d(2,2)) == true );
+ mln_assertion(ima.has(point2d(2,2)) == true);
sub_image<I, box2d> sub(ima, b);
- mln_assertion( sub.has (point2d(2,2)) == false &&
- sub.has(point2d(2,2)) == false );
+ mln_assertion(sub.has(point2d(2,2)) == false &&
+ sub.has(point2d(2,2)) == false);
mln_assertion(border::get(sub) == 0);
image_if<I, f_box2d_t> imaif(ima, f_b);
- mln_assertion( imaif.has (point2d(2,2)) == false &&
- ima.has(point2d(2,2)) == true );
- mln_assertion(border::get(imaif) == 51);
+ mln_assertion(imaif.has(point2d(2,2)) == false &&
+ ima.has(point2d(2,2)) == true);
+ mln_assertion(border::get(imaif) == 0);
- mln_assertion(border::get( (ima | b) | f_b ) == 0);
+ mln_assertion(border::get((ima | b) | f_b) == 0);
}
diff --git a/milena/tests/border/resize_image3d_3.cc b/milena/tests/border/resize_image3d_3.cc
index 409d11d..1a94b9c 100644
--- a/milena/tests/border/resize_image3d_3.cc
+++ b/milena/tests/border/resize_image3d_3.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,10 +26,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/border/resize_image3d_3.cc
- *
- * \brief Tests on mln::border::resize.
- */
+/// \file tests/border/resize_image3d_3.cc
+///
+/// Tests on mln::border::resize.
#include <mln/core/image/image3d.hh>
@@ -41,33 +41,22 @@
using namespace mln;
-int
-main (void)
+int main ()
{
unsigned border = 3;
unsigned new_border = 1;
- std::cout << std::endl
- << "Test 3d resize"
- << std::endl
- << std::endl;
image3d<value::int_u8> ima(1, 3, 2, border);
level::fill (ima, 2);
border::fill(ima, 8);
- std::cout << "before resize ("
- << border
- << ")"
- << std::endl;
- debug::println_with_border(ima);
- std::cout << std::endl;
-
+ mln_assertion(ima.has(point3d(-3, -3, -3)) == true);
+ mln_assertion(ima.has(point3d(-4, -4, -4)) == false);
border::resize (ima, new_border);
- std::cout << "after resize ("
- << new_border
- << ")"
- << std::endl;
- debug::println_with_border(ima);
- std::cout << std::endl;
+ mln_assertion(ima.border() == new_border);
+ mln_assertion(ima.has(point3d(-1, -1, -1)) == true);
+ mln_assertion(ima.has(point3d(-1, -2, -1)) == false);
+ mln_assertion(ima.has(point3d(-3, -3, -3)) == false);
+ mln_assertion(ima.has(point3d(-4, -4, -4)) == false);
}
diff --git a/milena/tests/border/resize_image_if.cc b/milena/tests/border/resize_image_if.cc
index 5b738d3..4ed8522 100644
--- a/milena/tests/border/resize_image_if.cc
+++ b/milena/tests/border/resize_image_if.cc
@@ -66,15 +66,15 @@ int main()
I ima(3,3, border);
mln_assertion(border::get(ima) == border);
- mln_assertion( ima.has(point2d(2,2)) == true );
+ mln_assertion(ima.has(point2d(2,2)) == true);
my_box2d f_b(b);
image_if<I, my_box2d> imaif(ima, f_b);
- mln_assertion( imaif.has(point2d(2,2)) == false &&
- ima.has(point2d(2,2)) == true );
+ mln_assertion(imaif.has(point2d(2,2)) == false &&
+ ima.has(point2d(2,2)) == true);
- mln_assertion(border::get(imaif) == border);
+ mln_assertion(border::get(imaif) == 0);
border::resize (imaif, new_border);
- mln_assertion(border::get(imaif) == new_border);
+ mln_assertion(border::get(imaif) == 0);
}
diff --git a/milena/tests/core/image/Makefile.am b/milena/tests/core/image/Makefile.am
index 7d60304..a28dc4e 100644
--- a/milena/tests/core/image/Makefile.am
+++ b/milena/tests/core/image/Makefile.am
@@ -9,11 +9,11 @@ check_PROGRAMS = \
complex_image \
decorated_image \
flat_image \
-## hexa \
+ hexa \
graph_image \
image1d \
image2d \
-## image2d_h \
+ image2d_h \
image3d \
image_if \
interpolated \
@@ -36,10 +36,10 @@ complex_image_SOURCES = complex_image.cc
decorated_image_SOURCES = decorated_image.cc
graph_image_SOURCES = graph_image.cc
flat_image_SOURCES = flat_image.cc
-##hexa_SOURCES = hexa.cc
+hexa_SOURCES = hexa.cc
image1d_SOURCES = image1d.cc
image2d_SOURCES = image2d.cc
-##image2d_h_SOURCES = image2d_h.cc
+image2d_h_SOURCES = image2d_h.cc
image3d_SOURCES = image3d.cc
image_if_SOURCES = image_if.cc
interpolated_SOURCES = interpolated.cc
diff --git a/milena/tests/core/image/hexa.cc b/milena/tests/core/image/hexa.cc
index 7bd7c3a..cd157b4 100644
--- a/milena/tests/core/image/hexa.cc
+++ b/milena/tests/core/image/hexa.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,18 +26,18 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/core/image/hexa.cc
- *
- * \brief Tests on mln::hexa
- */
+/// \file tests/core/image/hexa.cc
+///
+/// Tests on mln::hexa
+
#include <mln/core/image/image2d.hh>
#include <mln/core/image/hexa.hh>
-
#include <mln/value/int_u8.hh>
-#include <mln/trait/image/print.hh>
#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+//FIXME: Write a real test!!
int main()
{
@@ -45,15 +46,18 @@ int main()
typedef image2d<int_u8> I;
- I ima(3,3);
- hexa<I> h(ima);
+ I ima(3,4);
+
+ // FIXME!! The values differs from the test core/image/hexa which
+ // may be a bug! debug::iota does not seem to behave correctly.
debug::iota(ima);
- trait::image::print(h, std::cout);
+ debug::println(ima);
+ hexa<I> h(ima);
+
+ debug::println(h);
- hexa<I>::fwd_piter p(h.domain());
+// mln_piter_(hexa<I>) p(h.domain());
- for_all(p)
- {
- std::cout << p << "->" << h(p) << std::endl;
- }
+// for_all(p)
+// std::cout << p << " -> " << h(p) << std::endl;
}
diff --git a/milena/tests/core/image/image2d_h.cc b/milena/tests/core/image/image2d_h.cc
index f2d0e2e..53f2690 100644
--- a/milena/tests/core/image/image2d_h.cc
+++ b/milena/tests/core/image/image2d_h.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,31 +26,32 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/core/image/image2d_h.cc
- *
- * \brief Tests on mln::image2d_h
- */
+/// \file tests/core/image/image2d_h.cc
+///
+/// Tests on mln::image2d_h
#include <mln/core/image/image2d_h.hh>
-
-#include <mln/value/int_u16.hh>
-#include <mln/trait/image/print.hh>
+#include <mln/value/int_u8.hh>
#include <mln/debug/iota.hh>
#include <mln/debug/println.hh>
+//FIXME: Write a real test!!
int main()
{
using namespace mln;
- using value::int_u16;
-
- image2d_h<int_u16> h(50,50);
+ using value::int_u8;
- debug::println(h);
+ image2d_h<int_u8> h(3, 8);
+ // FIXME!! The values differs from the test core/image/hexa which
+ // may be a bug! debug::iota does not seem to behave correctly.
debug::iota(h);
debug::println(h);
- trait::image::print(h, std::cout);
+// mln_piter_(image2d_h<int_u8>) p(h.domain());
+
+// for_all(p)
+// std::cout << p << " - > " << h(p) << std::endl;
}
diff --git a/milena/tests/fun/x2x/rotation.cc b/milena/tests/fun/x2x/rotation.cc
index bce3137..7835ac9 100644
--- a/milena/tests/fun/x2x/rotation.cc
+++ b/milena/tests/fun/x2x/rotation.cc
@@ -31,7 +31,7 @@
///
#include <iostream>
-#include <mln/fun/x2v/rotation.hh>
+#include <mln/fun/x2x/rotation.hh>
#include <mln/core/image/image2d.hh>
#include <mln/value/int_u8.hh>
#include <mln/io/pgm/load.hh>
diff --git a/milena/tests/labeling/relabel.cc b/milena/tests/labeling/relabel.cc
index ac1f612..3ffd9c3 100644
--- a/milena/tests/labeling/relabel.cc
+++ b/milena/tests/labeling/relabel.cc
@@ -37,7 +37,7 @@
#include <mln/debug/println.hh>
-struct not_to_removed : public mln::Function_l2b< not_to_removed >
+struct not_to_remove : public mln::Function_l2b< not_to_remove >
{
bool operator()(const mln::value::label_16& l) const
{
@@ -76,7 +76,7 @@ int main()
image2d<label_16> lbl2 = labeling::relabel(lbl,
nlabels,
new_nlabels,
- not_to_removed());
+ not_to_remove());
mln_assertion(new_nlabels == 2u);
mln_piter_(image2d<label_16>) p(lbl2.domain());
for_all(p)
@@ -87,7 +87,7 @@ int main()
label_16 new_nlabels;
labeling::relabel_inplace(lbl,
nlabels,
- not_to_removed());
+ not_to_remove());
mln_assertion(nlabels == 2u);
mln_piter_(image2d<label_16>) p(lbl.domain());
for_all(p)
diff --git a/milena/tests/morpho/complex_image_wst.cc b/milena/tests/morpho/complex_image_wst.cc
index f6aab30..a1e7cf6 100644
--- a/milena/tests/morpho/complex_image_wst.cc
+++ b/milena/tests/morpho/complex_image_wst.cc
@@ -26,7 +26,8 @@
// Public License.
/// \file tests/morpho/complex_image_swt.cc
-/// \brief Testing Meyer's Watershed Transform on mln::complex_image.
+///
+/// Testing Meyer's Watershed Transform on mln::complex_image.
#include <iostream>
#include <fstream>
@@ -38,23 +39,24 @@
#include <mln/literal/black.hh>
#include <mln/literal/white.hh>
+#include <mln/core/concept/function.hh>
#include <mln/core/alias/point2d.hh>
-
#include <mln/core/site_set/p_faces.hh>
#include <mln/core/image/complex_image.hh>
-
// FIXME: Include these elsewhere? (In complex_image.hh?)
#include <mln/core/image/complex_neighborhoods.hh>
#include <mln/core/image/complex_neighborhood_piter.hh>
-#include <mln/debug/iota.hh>
#include <mln/level/fill.hh>
+
#include <mln/norm/l2.hh>
#include <mln/morpho/closing_area.hh>
#include <mln/morpho/meyer_wst.hh>
-#include <mln/core/concept/function.hh>
+#include <mln/convert/to.hh>
+
+#include <mln/debug/iota.hh>
// FIXME: To be put elsewhere (from milena/sandbox/geraud/wst_edge.cc).
struct colorize : mln::Function_v2v< colorize >
@@ -92,12 +94,12 @@ int main()
c 0 1 2 3
r .------------------------
| v0 e3 v3
- 0 | o-----------o v0----e3----v3
- | / \ / / \ /
- | / \ / / \ /
- 1 | e0 / e1 / e4 e0 e1 e4
- | / \ / / \ /
- | / \ / / \ /
+ 0 | o-----------o v0----e3----v3
+ | / \ / / \ /
+ | / \ / / \ /
+ 1 | e0 / e1 / e4 e0 e1 e4
+ | / \ / / \ /
+ | / \ / / \ /
2 | o-----------o v1----e2----v2
| v1 e2 v2
@@ -168,7 +170,7 @@ int main()
v.next();
mln_invariant(!v.is_valid());
- dist_ima(e) = 10 * norm::l2_distance(p1.to_vec(), p2.to_vec());
+ dist_ima(e) = convert::to<unsigned>(10 * norm::l2_distance(p1.to_vec(), p2.to_vec()));
}
// Initialize 0-faces to a dummy value, to prevent the watershed from
// finding minima on 0-faces.
@@ -195,8 +197,7 @@ int main()
`-----------------*/
// Currently, does nothing (lambda = 1).
- dist_ima_t closed_dist_ima (dist_ima.domain());
- morpho::closing_area(dist_ima, nbh, 1, closed_dist_ima);
+ dist_ima_t closed_dist_ima = morpho::closing_area(dist_ima, nbh, 1);
/*------.
| WST. |
diff --git a/milena/tests/morpho/hit_or_miss.cc b/milena/tests/morpho/hit_or_miss.cc
index 9b975ae..3ac2226 100644
--- a/milena/tests/morpho/hit_or_miss.cc
+++ b/milena/tests/morpho/hit_or_miss.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,10 +26,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/morpho/hit_or_miss.cc
- *
- * \brief Test on mln::morpho::hit_or_miss.
- */
+/// \file tests/morpho/hit_or_miss.cc
+///
+/// Test on mln::morpho::hit_or_miss.
#include <mln/core/image/image2d.hh>
#include <mln/value/int_u8.hh>
@@ -66,7 +66,7 @@ int main()
0, 0, 1, 1, 1,
0, 0, 1, 1, 1 };
window2d win_hit_ = convert::to<window2d>(hit);
- mln_precondition(win_hit_ == win_hit);
+ mln_assertion(win_hit_ == win_hit);
bool miss[] = { 1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
@@ -74,7 +74,7 @@ int main()
1, 1, 0, 0, 0,
1, 1, 0, 0, 0 };
window2d win_miss_ = convert::to<window2d>(miss);
- mln_precondition(win_miss_ == win_miss);
+ mln_assertion(win_miss_ == win_miss);
}
border::thickness = 2;
diff --git a/milena/tests/unit_test/build_unit_test.sh b/milena/tests/unit_test/build_unit_test.sh
index 2eb3974..d08a0a6 100755
--- a/milena/tests/unit_test/build_unit_test.sh
+++ b/milena/tests/unit_test/build_unit_test.sh
@@ -4,7 +4,7 @@ if [ $# -ne 1 ]; then
echo "Usage: $0 <mln_path>"
fi
-HEADERS=`find $1 -name "*.hh" | grep -vE "*.spe.hh" | grep -v "mln/core/doc" | sed -e 's/.*\/mln\/\(.*\)/mln\/\1/g' | sed 's/\.\.\/\.\.\///g'`
+HEADERS=`find $1 -name "*.hh" | grep -vE "*.spe.hh" | grep -v "mln/core/concept/doc" | sed -e 's/.*\/mln\/\(.*\)/mln\/\1/g' | sed 's/\.\.\/\.\.\///g'`
rm -f Makefile.am
rm -f *.hh *.cc
--
1.5.6.5
1
0
12 Dec '08
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2008-12-12 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Add a pseudo report of a discution with theo on my seminar.
* garrigues/union_find/reunion_avec_theo: New.
---
reunion_avec_theo | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
Index: trunk/milena/sandbox/garrigues/union_find/reunion_avec_theo
===================================================================
--- trunk/milena/sandbox/garrigues/union_find/reunion_avec_theo (revision 0)
+++ trunk/milena/sandbox/garrigues/union_find/reunion_avec_theo (revision 3035)
@@ -0,0 +1,24 @@
+Verifier les resultats bizarres.
+
+1/ Ajouter le test d'inclusion pour les reconstruction_on_set
+ -> regarder si level compare utilise test/predicate
+ -> sinon le faire, et fastestiser test/predicate
+ -> level compare specialisation pour les boolean? test d'implication??
+
+Comment Specialiser les canvas pour les images fastest?
+Rendre le canvas indépedant de la gestion du bord.
+Faire passer les initialisation du bord au canvas
+
+Attention! les initialisation des images doivent savoir
+si on est fast ou pas.
+
+
+
+* Pour les opérateur auto duaux
+
+Coder la reconstruction auto duale (Rapide).
+
+Un peu plus chaud: les deux autres opérateur du papier (some levelings et
+inf-semilatice approach).
+Difficultée: comment coder le canvas sachant qu'on doit pouvoir paser un op
+(et son dual aussi car l'algo a besoin des deux).
1
0
12 Dec '08
Ugo Jardonnet wrote:
> https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
>
>
> Index: ChangeLog
> from Ugo Jardonnet <jardonnet(a)lrde.epita.fr>
>
> Comment, beautify, strengthen n_cmpt5.
>
> * jardonnet/n_cmpt/n_cmpt5.hh: Comment. Add assertions.
> ...
c'est du très très bon résultat :-)
1
0