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
- 9625 discussions
cleanup-2008 2283: Add some morphological reconstruction algorithms in sandbox.
by Thierry Geraud 17 Sep '08
by Thierry Geraud 17 Sep '08
17 Sep '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add some morphological reconstruction algorithms in sandbox.
* sandbox/geraud/Rd: New directory.
* sandbox/geraud/Rd/hybrid.hh,
* sandbox/geraud/Rd/queue_based.hh,
* sandbox/geraud/Rd/parallel.cc,
* sandbox/geraud/Rd/parallel_wo.cc,
* sandbox/geraud/Rd/union_find.hh,
* sandbox/geraud/Rd/parallel.hh,
* sandbox/geraud/Rd/diff.cc,
* sandbox/geraud/Rd/sequential_bench.cc,
* sandbox/geraud/Rd/sequential.cc,
* sandbox/geraud/Rd/utils.hh,
* sandbox/geraud/Rd/deco.cc,
* sandbox/geraud/Rd/hybrid.cc,
* sandbox/geraud/Rd/queue_based.cc,
* sandbox/geraud/Rd/sequential_bench.hh,
* sandbox/geraud/Rd/min.cc,
* sandbox/geraud/Rd/sequential.hh,
* sandbox/geraud/Rd/debase.union_find.hh,
* sandbox/geraud/Rd/union_find.cc,
* sandbox/geraud/Rd/svg.queue_based.hh: New files.
debase.union_find.hh | 165 +++++++++++++++++++++++++++++++
deco.cc | 71 +++++++++++++
diff.cc | 28 +++++
hybrid.cc | 51 +++++++++
hybrid.hh | 123 +++++++++++++++++++++++
min.cc | 42 +++++++
parallel.cc | 51 +++++++++
parallel.hh | 93 +++++++++++++++++
parallel_wo.cc | 46 ++++++++
queue_based.cc | 49 +++++++++
queue_based.hh | 129 ++++++++++++++++++++++++
sequential.cc | 51 +++++++++
sequential.hh | 96 ++++++++++++++++++
sequential_bench.cc | 51 +++++++++
sequential_bench.hh | 100 +++++++++++++++++++
svg.queue_based.hh | 118 ++++++++++++++++++++++
union_find.cc | 50 +++++++++
union_find.hh | 173 ++++++++++++++++++++++++++++++++
utils.hh | 268 +++++++++++++++++++++++++++++++++++++++++++++++++++
19 files changed, 1755 insertions(+)
Index: sandbox/geraud/Rd/hybrid.hh
--- sandbox/geraud/Rd/hybrid.hh (revision 0)
+++ sandbox/geraud/Rd/hybrid.hh (revision 0)
@@ -0,0 +1,123 @@
+// Copyright (C) 2007 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_MORPHO_RD_HYBRID_HH
+# define MLN_MORPHO_RD_HYBRID_HH
+
+# include <queue>
+# include "utils.hh"
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace Rd
+ {
+
+
+ template <typename I, typename N>
+ I hybrid(const I& f, const I& g, const N& nbh,
+ bool echo = false)
+ {
+ typedef mln_point(I) point;
+ std::queue<point> q;
+
+ f.name_it("f");
+ g.name_it("g");
+
+ // initialisation
+ I o(f.domain());
+ o.name_it("o");
+ level::paste(f, o);
+ // WAS: I o = clone(f);
+
+ unsigned n_init_pushs = 0, n_body_pushs = 0, n_pops = 0;
+
+ // sequence
+ {
+ mln_bkd_piter(I) p(f.domain());
+ for_all(p)
+ o(p) = min( max_Nminus(o, p,nbh), g(p) );
+ }
+ {
+ mln_fwd_piter(I) p(f.domain());
+ mln_niter(N) n(nbh, p);
+ for_all(p)
+ {
+ o(p) = min( max_Nplus(o, p,nbh), g(p) );
+ for_all(n) if (f.has(n) and n < p) // N+
+ if (o(n) < o(p) and o(n) < g(n))
+ {
+ q.push(p);
+ ++n_init_pushs;
+ }
+ }
+ }
+
+ // propagation
+ {
+ point p;
+ mln_niter(N) n(nbh, p);
+ while (not q.empty())
+ {
+ p = q.front();
+ if (echo) std::cout << std::endl << "pop " << p << " :";
+ q.pop();
+ ++n_pops;
+ for_all(n) if (f.has(n))
+ if (o(n) < o(p) and o(n) != g(n))
+ {
+ o(n) = min(o(p), g(n));
+ if (echo) std::cout << " push " << n;
+ q.push(n);
+ ++n_body_pushs;
+ }
+ }
+ if (echo) std::cout << std::endl;
+ }
+
+
+ std::cout << "n_init_pushs = " << n_init_pushs << std::endl
+ << "n_body_pushs = " << n_body_pushs << std::endl
+ << "n_pops = " << n_pops << std::endl;
+
+ print_counts();
+
+ return o;
+ }
+
+ } // end of namespace mln::morpho::Rd
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_RD_HYBRID_HH
Index: sandbox/geraud/Rd/queue_based.hh
--- sandbox/geraud/Rd/queue_based.hh (revision 0)
+++ sandbox/geraud/Rd/queue_based.hh (revision 0)
@@ -0,0 +1,129 @@
+// Copyright (C) 2007 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_MORPHO_RD_QUEUE_BASED_HH
+# define MLN_MORPHO_RD_QUEUE_BASED_HH
+
+# include <queue>
+# include "utils.hh"
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace Rd
+ {
+
+ template <typename I, typename N>
+ I queue_based(const I& f, const I& g, const N& nbh,
+ bool echo = false)
+ {
+
+ mln_ch_value(I, bool) que(f.domain());
+ level::fill(que, false);
+
+
+ if (echo) std::cout << std::endl;
+
+ f.name_it("f");
+ g.name_it("g");
+
+ typedef mln_point(I) point;
+ std::queue<point> q;
+ I o;
+ o.name_it("o");
+
+ unsigned n_init_pushs = 0, n_body_pushs = 0, n_pops = 0;
+
+ // initialisation
+ {
+ o = regional_maxima(f, nbh);
+ // p in M <=> o(p) != 0
+ if (echo) debug::println(o);
+
+ mln_piter(I) p(f.domain());
+ mln_niter(N) n(nbh, p);
+
+ for_all(p) if (o(p) != 0) // p in M
+ for_all(n) if (f.has(n) and o(n) == 0) // n not in M
+ {
+ q.push(p);
+ que(p) = true;
+ ++n_init_pushs;
+ break;
+ }
+ }
+
+ // propagation
+ {
+ point p;
+ mln_niter(N) n(nbh, p);
+ while (not q.empty())
+ {
+ p = q.front();
+ if (echo) std::cout << std::endl << "pop " << p << " :";
+ q.pop();
+ que(p) = false;
+ ++n_pops;
+ for_all(n) if (f.has(n))
+ {
+ if (o(n) < o(p) and o(n) != g(n))
+ {
+ o(n) = min(o(p), g(n));
+ if (echo) std::cout << " push " << n;
+ if (que(n) == false)
+ {
+ q.push(n);
+ que(n) = true;
+ ++n_body_pushs;
+ }
+ }
+ }
+ }
+ if (echo) std::cout << std::endl;
+ }
+
+ std::cout << "n_init_pushs = " << n_init_pushs << std::endl
+ << "n_body_pushs = " << n_body_pushs << std::endl
+ << "n_pops = " << n_pops << std::endl;
+
+ print_counts();
+
+ return o;
+ }
+
+ } // end of namespace mln::morpho::Rd
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_RD_QUEUE_BASED_HH
Index: sandbox/geraud/Rd/parallel.cc
--- sandbox/geraud/Rd/parallel.cc (revision 0)
+++ sandbox/geraud/Rd/parallel.cc (revision 0)
@@ -0,0 +1,51 @@
+#include <iostream>
+
+#include <mln/core/image2d.hh>
+#include <mln/core/neighb2d.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/debug/println.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include "parallel.hh"
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " f.pgm g.pgm c output.pgm" << std::endl
+ << "reconstruction by dilation (parallel version; may 2007)" << std::endl
+ << "f = marker (to be dilated)" << std::endl
+ << "g = mask (constraint >= f)" << std::endl
+ << "c: 4 or 8" << std::endl;
+ exit(1);
+}
+
+
+int main(int argc, char* argv[])
+{
+ if (argc != 5)
+ usage(argv);
+
+ using namespace mln;
+ using value::int_u8;
+
+ typedef image2d<int_u8> I;
+
+ int c = atoi(argv[3]);
+ if (c != 4 and c != 8)
+ usage(argv);
+
+ I f = io::pgm::load<int_u8>(argv[1]);
+ I g = io::pgm::load<int_u8>(argv[2]);
+
+ if (not (f <= g))
+ {
+ std::cerr << "pb" << std::endl;
+ return 1;
+ }
+
+ io::pgm::save(morpho::Rd::parallel(f, g,
+ (c == 4 ? c4() : c8())),
+ argv[4]);
+}
Index: sandbox/geraud/Rd/parallel_wo.cc
--- sandbox/geraud/Rd/parallel_wo.cc (revision 0)
+++ sandbox/geraud/Rd/parallel_wo.cc (revision 0)
@@ -0,0 +1,46 @@
+#include <iostream>
+
+#include <mln/core/image2d.hh>
+#include <mln/core/neighb2d.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/debug/println.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include "parallel.hh"
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " f.pgm g.pgm c output.pgm" << std::endl
+ << "reconstruction by dilation (parallel version; may 2007)" << std::endl
+ << "f = marker (to be dilated)" << std::endl
+ << "g = mask (constraint >= f)" << std::endl
+ << "c: 4 or 8" << std::endl;
+ exit(1);
+}
+
+
+int main(int argc, char* argv[])
+{
+ if (argc != 5)
+ usage(argv);
+
+ using namespace mln;
+ using value::int_u8;
+
+ typedef image2d<int_u8> I;
+
+ int c = atoi(argv[3]);
+ if (c != 4 and c != 8)
+ usage(argv);
+
+ I f = io::pgm::load<int_u8>(argv[1]);
+ I g = io::pgm::load<int_u8>(argv[2]);
+
+ io::pgm::save(morpho::Rd::parallel(f, g,
+ (c == 4 ? c4() : c8()),
+ false),
+ argv[4]);
+}
Index: sandbox/geraud/Rd/union_find.hh
--- sandbox/geraud/Rd/union_find.hh (revision 0)
+++ sandbox/geraud/Rd/union_find.hh (revision 0)
@@ -0,0 +1,173 @@
+// Copyright (C) 2007 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_MORPHO_RD_UNION_FIND_HH
+# define MLN_MORPHO_RD_UNION_FIND_HH
+
+# include "utils.hh"
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace Rd
+ {
+
+
+ template <typename I, typename N>
+ struct union_find_t
+ {
+ typedef mln_point(I) point;
+ typedef mln_value(I) value;
+
+ // in:
+ const I f, g;
+ N nbh;
+
+ // out:
+ I o;
+
+ // aux:
+ std::vector<point> S;
+ // was: I data;
+ mln_ch_value(I, bool) isproc;
+ mln_ch_value(I, point) parent;
+
+ union_find_t(const I& f, const I& g, const N& nbh)
+ : f(f), g(g), nbh(nbh)
+ {
+ f.name_it("f");
+ g.name_it("g");
+ initialize(o, f);
+ o.name_it("o");
+ initialize(parent, f);
+ parent.name_it("parent");
+ initialize(isproc, f);
+ isproc.name_it("isproc");
+ // was: initialize(data, f);
+
+ // init
+
+ level::fill(isproc, false);
+ S = histo_reverse_sort(g);
+ level::paste(f, o); // new: replace make_set(p) { data(p) = f(p) }
+
+ // first pass
+
+ for (unsigned i = 0; i < S.size(); ++i)
+ {
+ point p = S[i];
+
+ make_set(p);
+ mln_niter(N) n(nbh, p);
+ for_all(n)
+ {
+ if (f.has(n))
+ mln_invariant(isproc(n) == is_proc(n, p));
+ if (f.has(n) and isproc(n))
+ do_union(n, p);
+ }
+ isproc(p) = true;
+ }
+
+ // second pass
+
+ for (int i = S.size() - 1; i >= 0; --i)
+ {
+ point p = S[i];
+ if (parent(p) == p)
+ if (o(p) == mln_max(value))
+ o(p) = g(p);
+ else
+ o(p) = o(parent(p));
+ }
+
+ print_counts();
+
+ }
+
+ bool is_proc(const point& n, const point& p) const
+ {
+ return g(n) > g(p) or (g(n) == g(p) and n < p);
+ }
+
+ void make_set(const point& p)
+ {
+ parent(p) = p;
+ // was: data(p) = f(p);
+ // now: in "initialization"
+ }
+
+ point find_root(const point& x)
+ {
+ if (parent(x) == x)
+ return x;
+ else
+ return parent(x) = find_root(parent(x));
+ }
+
+ void do_union(const point& n, const point& p)
+ {
+ point r = find_root(n);
+ if (r != p)
+ {
+ // NEW: o replaces data
+
+ if (g(r) == g(p) or g(p) >= o(r)) // equiv test
+ {
+ parent(r) = p;
+ if (o(r) > o(p))
+ o(p) = o(r); // increasing criterion
+ }
+ else
+ o(p) = mln_max(value);
+ }
+ }
+
+ };
+
+
+ template <typename I, typename N>
+ I union_find(const I& f, const I& g, const N& nbh)
+ {
+ mln_precondition(f <= g);
+ union_find_t<I, N> run(f, g, nbh);
+ return run.o;
+ }
+
+
+ } // end of namespace mln::morpho::Rd
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_RD_UNION_FIND_HH
Index: sandbox/geraud/Rd/parallel.hh
--- sandbox/geraud/Rd/parallel.hh (revision 0)
+++ sandbox/geraud/Rd/parallel.hh (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2007 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_MORPHO_RD_PARALLEL_HH
+# define MLN_MORPHO_RD_PARALLEL_HH
+
+# include "utils.hh"
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace Rd
+ {
+
+
+ template <typename I, typename N>
+ I parallel(const I& f, const I& g, const N& nbh,
+ bool test = true)
+ {
+// if (test)
+// mln_precondition(f <= g);
+
+ f.name_it("f");
+ g.name_it("g");
+
+ I o_(f.domain());
+ o_.name_it("o_");
+ mln_piter(I) p(f.domain());
+
+ // initialisation
+ I o(f.domain());
+ o.name_it("o");
+ level::paste(f, o);
+ // WAS: I o = clone(f);
+
+ bool stability;
+ do
+ {
+ level::paste(o, o_); // memorisation
+
+ // opere
+ for_all(p)
+ o(p) = max_N(o_, p, nbh);
+ // conditionne
+ for_all(p)
+ o(p) = min(o(p), g(p));
+
+ stability = (o == o_);
+ }
+ while (not stability);
+
+ print_counts();
+
+ // mln_postcondition(o <= g);
+ return o;
+ }
+
+ } // end of namespace mln::morpho::Rd
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_RD_PARALLEL_HH
Index: sandbox/geraud/Rd/diff.cc
--- sandbox/geraud/Rd/diff.cc (revision 0)
+++ sandbox/geraud/Rd/diff.cc (revision 0)
@@ -0,0 +1,28 @@
+#include <oln/core/2d/image2d.hh>
+#include <oln/io/load_pgm.hh>
+#include <oln/level/compare.hh>
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " 1.pgm 2.pgm" << std::endl
+ << "(may 2007)" << std::endl;
+ exit(1);
+}
+
+
+int main(int argc, char* argv[])
+{
+ if (argc != 3)
+ usage(argv);
+
+ using namespace oln;
+ typedef image2d<unsigned char> I;
+
+ I ima1 = io::load_pgm(argv[1]);
+ I ima2 = io::load_pgm(argv[2]);
+
+ if (ima1 != ima2)
+ std::cout << "images differ" << std::endl;
+ return 0;
+}
Index: sandbox/geraud/Rd/sequential_bench.cc
--- sandbox/geraud/Rd/sequential_bench.cc (revision 0)
+++ sandbox/geraud/Rd/sequential_bench.cc (revision 0)
@@ -0,0 +1,51 @@
+#include <mln/core/image2d.hh>
+#include <mln/core/neighb2d.hh>
+
+#include <mln/debug/println.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include "sequential_bench.hh"
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " f.pgm g.pgm c output.pgm" << std::endl
+ << "reconstruction by dilation (sequential version; may 2007)" << std::endl
+ << "f = marker (to be dilated)" << std::endl
+ << "g = mask (constraint >= f)" << std::endl
+ << "c: 4 or 8" << std::endl;
+ exit(1);
+}
+
+
+int main(int argc, char* argv[])
+{
+ if (argc != 5)
+ usage(argv);
+
+ using namespace mln;
+ using value::int_u8;
+
+ typedef image2d<int_u8> I;
+
+ int c = atoi(argv[3]);
+ if (c != 4 and c != 8)
+ usage(argv);
+
+ I f = io::pgm::load<int_u8>(argv[1]);
+ f.name_it("main.f");
+
+ I g = io::pgm::load<int_u8>(argv[2]);
+ g.name_it("main.g");
+
+ if (not (f <= g))
+ {
+ std::cerr << "pb" << std::endl;
+ return 1;
+ }
+
+ io::pgm::save(morpho::Rd::sequential(f, g,
+ (c == 4 ? c4() : c8())),
+ argv[4]);
+}
Index: sandbox/geraud/Rd/sequential.cc
--- sandbox/geraud/Rd/sequential.cc (revision 0)
+++ sandbox/geraud/Rd/sequential.cc (revision 0)
@@ -0,0 +1,51 @@
+#include <mln/core/image2d.hh>
+#include <mln/core/neighb2d.hh>
+
+#include <mln/debug/println.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include "sequential.hh"
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " f.pgm g.pgm c output.pgm" << std::endl
+ << "reconstruction by dilation (sequential version; may 2007)" << std::endl
+ << "f = marker (to be dilated)" << std::endl
+ << "g = mask (constraint >= f)" << std::endl
+ << "c: 4 or 8" << std::endl;
+ exit(1);
+}
+
+
+int main(int argc, char* argv[])
+{
+ if (argc != 5)
+ usage(argv);
+
+ using namespace mln;
+ using value::int_u8;
+
+ typedef image2d<int_u8> I;
+
+ int c = atoi(argv[3]);
+ if (c != 4 and c != 8)
+ usage(argv);
+
+ I f = io::pgm::load<int_u8>(argv[1]);
+ f.name_it("main.f");
+
+ I g = io::pgm::load<int_u8>(argv[2]);
+ g.name_it("main.g");
+
+ if (not (f <= g))
+ {
+ std::cerr << "pb" << std::endl;
+ return 1;
+ }
+
+ io::pgm::save(morpho::Rd::sequential(f, g,
+ (c == 4 ? c4() : c8())),
+ argv[4]);
+}
Index: sandbox/geraud/Rd/utils.hh
--- sandbox/geraud/Rd/utils.hh (revision 0)
+++ sandbox/geraud/Rd/utils.hh (revision 0)
@@ -0,0 +1,268 @@
+// Copyright (C) 2007 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_MORPHO_RD_UTILS_HH
+# define MLN_MORPHO_RD_UTILS_HH
+
+# include <vector>
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/clone.hh>
+
+# include <mln/level/fill.hh>
+# include <mln/level/paste.hh>
+# include <mln/level/compare.hh>
+
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace Rd
+ {
+
+
+ template <typename T>
+ T min(T v1, T v2)
+ {
+ return v1 < v2 ? v1 : v2;
+ }
+
+
+ template <typename I>
+ I minimun(const I& ima1, const I& ima2)
+ {
+ mln_precondition(ima1.has_data() and ima2.has_data());
+ mln_precondition(ima1.domain() == ima2.domain());
+ I out(ima1.domain());
+ mln_piter(I) p(ima1.domain());
+ for_all(p)
+ out(p) = ima1(p) < ima2(p) ? ima1(p) : ima2(p);
+ return out;
+ }
+
+
+ template <typename I, typename P, typename N>
+ mln_value(I) max_N(const I& ima, const P& p, const N& nbh)
+ {
+ mln_value(I) v = ima(p);
+ mln_niter(N) n(nbh, p);
+ for_all(n)
+ if (ima.has(n) and ima(n) > v)
+ v = ima(n);
+ return v;
+ }
+
+
+ template <typename I, typename P, typename N>
+ mln_value(I) max_Nminus(const I& ima, const P& p, const N& nbh)
+ {
+ mln_value(I) v = ima(p);
+ mln_niter(N) n(nbh, p);
+ for_all(n)
+ if (ima.has(n) and n > p and ima(n) > v)
+ v = ima(n);
+ return v;
+ }
+
+ template <typename I, typename P, typename N>
+ mln_value(I) max_Nplus(const I& ima, const P& p, const N& nbh)
+ {
+ mln_value(I) v = ima(p);
+ mln_niter(N) n(nbh, p);
+ for_all(n)
+ if (ima.has(n) and n < p and ima(n) > v)
+ v = ima(n);
+ return v;
+ }
+
+
+ template <typename I>
+ std::vector<unsigned> compute_histo(const I& ima)
+ {
+ std::vector<unsigned> h(256, 0);
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ ++h[ima(p)];
+ return h;
+ }
+
+
+// template <typename I>
+// std::vector<mln_point(I)> histo_sort(const I& ima)
+// {
+// std::vector<unsigned> h = compute_histo(ima);
+// // preparing output data
+// std::vector<int> loc(256);
+// loc[0] = 0;
+// for (int l = 1; l < 256; ++l)
+// loc[l] = loc[l-1] + h[l-1];
+// std::vector<mln_point(I)> vec(ima.points().npoints());
+// // storing output data
+// mln_piter(I) p(ima.points());
+// for_all(p)
+// vec[loc[ima(p)]++] = p;
+// return vec;
+// }
+
+
+ template <typename I>
+ std::vector<mln_point(I)> histo_reverse_sort(const I& ima)
+ {
+ std::vector<unsigned> h = compute_histo(ima);
+ // preparing output data
+ std::vector<int> loc(256);
+ loc[255] = 0;
+ for (int l = 254; l >= 0; --l)
+ loc[l] = loc[l+1] + h[l+1];
+ std::vector<mln_point(I)> vec(ima.domain().npoints());
+ // storing output data
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ vec[loc[ima(p)]++] = p;
+ return vec;
+ }
+
+
+
+ template <typename I, typename N>
+ struct regional_maxima_t
+ {
+ typedef mln_point(I) point;
+ typedef mln_ch_value(I, bool) image_bool;
+ typedef mln_ch_value(I, point) image_point;
+
+ // in:
+ I f;
+ N nbh;
+
+ // out:
+ I o;
+
+ // aux:
+ std::vector<point> S;
+ image_bool is_proc;
+ image_bool attr;
+ image_point parent;
+
+ regional_maxima_t(const I& f, const N& nbh)
+ : f(f), nbh(nbh)
+ {
+ f.name_it("rm.f");
+ initialize(o, f);
+ o.name_it("rm.o");
+ initialize(parent, f);
+ parent.name_it("rm.parent");
+ initialize(attr, f);
+ attr.name_it("rm.attr");
+ initialize(is_proc, f);
+ is_proc.name_it("rm.is_proc");
+
+ // init
+
+ level::fill(is_proc, false);
+ S = histo_reverse_sort(f);
+
+ // first pass
+
+ for (unsigned i = 0; i < S.size(); ++i)
+ {
+ point p = S[i];
+
+ make_set(p);
+ mln_niter(N) n(nbh, p);
+ for_all(n)
+ if (f.has(n) and is_proc(n))
+ {
+ if (f(n) == f(p))
+ do_union(n, p);
+ else // f(n) > f(p)
+ attr(p) = false;
+ }
+ is_proc(p) = true;
+ }
+
+ // second pass
+
+ const mln_value(I) zero = 0;
+ for (int i = S.size() - 1; i >= 0; --i)
+ {
+ point p = S[i];
+ if (parent(p) == p)
+ o(p) = attr(p) ? f(p) : zero;
+ else
+ o(p) = o(parent(p));
+ }
+ }
+
+ void make_set(const point& p)
+ {
+ parent(p) = p;
+ attr(p) = true;
+ }
+
+ point find_root(const point& x)
+ {
+ if (parent(x) == x)
+ return x;
+ else
+ return parent(x) = find_root(parent(x));
+ }
+
+ void do_union(const point& n, const point& p)
+ {
+ point r = find_root(n);
+ if (r != p)
+ {
+ parent(r) = p;
+ attr(p) = attr(p) and attr(r);
+ }
+ }
+
+ };
+
+
+ template <typename I, typename N>
+ I
+ regional_maxima(const I& f, const N& nbh)
+ {
+ regional_maxima_t<I, N> run(f, nbh);
+ return run.o;
+ }
+
+
+ } // end of namespace mln::morpho::Rd
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_RD_UTILS_HH
Index: sandbox/geraud/Rd/deco.cc
--- sandbox/geraud/Rd/deco.cc (revision 0)
+++ sandbox/geraud/Rd/deco.cc (revision 0)
@@ -0,0 +1,71 @@
+// Copyright (C) 2007 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.
+
+/*! \file tests/decorated_image.cc
+ *
+ * \brief Tests on mln::decorated_image.
+ * \todo Make this test work.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/core/decorated_image.hh>
+
+
+unsigned count_read = 0, count_write = 0;
+
+template <typename I>
+struct counter
+{
+ void reading(const I&, const mln_psite(I)&) const
+ {
+ ++count_read;
+ }
+ void writing(I&, const mln_psite(I)&, const mln_value(I)&)
+ {
+ ++count_write;
+ }
+};
+
+
+int main()
+{
+ using namespace mln;
+
+ typedef image2d<int> I;
+ I ima(1, 1);
+ point2d p = make::point2d(0, 0);
+
+ decorated_image< I, counter<I> > ima_ = decorate(ima, counter<I>());
+ ima_(p) = ima_(p) = 51;
+
+ std::cout << count_read << ' ' << count_write << std::endl;
+
+ mln_assertion(count_read == 1 && count_write == 2);
+
+ const I& imac = ima;
+ decorated_image< const I, counter<I> > cima_ = decorate(imac, counter<I>());
+}
Index: sandbox/geraud/Rd/hybrid.cc
--- sandbox/geraud/Rd/hybrid.cc (revision 0)
+++ sandbox/geraud/Rd/hybrid.cc (revision 0)
@@ -0,0 +1,51 @@
+#include <iostream>
+
+#include <mln/core/image2d.hh>
+#include <mln/core/neighb2d.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/debug/println.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include "hybrid.hh"
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " f.pgm g.pgm c output.pgm" << std::endl
+ << "reconstruction by dilation (hybrid version; may 2007)" << std::endl
+ << "f = marker (to be dilated)" << std::endl
+ << "g = mask (constraint >= f)" << std::endl
+ << "c: 4 or 8" << std::endl;
+ exit(1);
+}
+
+
+int main(int argc, char* argv[])
+{
+ if (argc != 5)
+ usage(argv);
+
+ using namespace mln;
+ using value::int_u8;
+
+ typedef image2d<int_u8> I;
+
+ int c = atoi(argv[3]);
+ if (c != 4 and c != 8)
+ usage(argv);
+
+ I f = io::pgm::load<int_u8>(argv[1]);
+ I g = io::pgm::load<int_u8>(argv[2]);
+
+ if (not (f <= g))
+ {
+ std::cerr << "pb" << std::endl;
+ return 1;
+ }
+
+ io::pgm::save(morpho::Rd::hybrid(f, g,
+ (c == 4 ? c4() : c8())),
+ argv[4]);
+}
Index: sandbox/geraud/Rd/queue_based.cc
--- sandbox/geraud/Rd/queue_based.cc (revision 0)
+++ sandbox/geraud/Rd/queue_based.cc (revision 0)
@@ -0,0 +1,49 @@
+#include <mln/core/image2d.hh>
+#include <mln/core/neighb2d.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/debug/println.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include "queue_based.hh"
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " f.pgm g.pgm c output.pgm" << std::endl
+ << "reconstruction by dilation (queue_based version; may 2007)" << std::endl
+ << "f = marker (to be dilated)" << std::endl
+ << "g = mask (constraint >= f)" << std::endl
+ << "c: 4 or 8" << std::endl;
+ exit(1);
+}
+
+
+int main(int argc, char* argv[])
+{
+ if (argc != 5)
+ usage(argv);
+
+ using namespace mln;
+ using value::int_u8;
+
+ typedef image2d<int_u8> I;
+
+ int c = atoi(argv[3]);
+ if (c != 4 and c != 8)
+ usage(argv);
+
+ I f = io::pgm::load<int_u8>(argv[1]);
+ I g = io::pgm::load<int_u8>(argv[2]);
+
+ if (not (f <= g))
+ {
+ std::cerr << "pb" << std::endl;
+ return 1;
+ }
+
+ io::pgm::save(morpho::Rd::queue_based(f, g,
+ (c == 4 ? c4() : c8())),
+ argv[4]);
+}
Index: sandbox/geraud/Rd/sequential_bench.hh
--- sandbox/geraud/Rd/sequential_bench.hh (revision 0)
+++ sandbox/geraud/Rd/sequential_bench.hh (revision 0)
@@ -0,0 +1,100 @@
+// Copyright (C) 2007 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_MORPHO_RD_SEQUENTIAL_HH
+# define MLN_MORPHO_RD_SEQUENTIAL_HH
+
+# include "utils.hh"
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace Rd
+ {
+
+ template <typename I, typename N>
+ I sequential(const I& f, const I& g, const N& nbh)
+ {
+ mln_precondition(f <= g);
+
+ f.name_it("f");
+ g.name_it("g");
+
+ I o_(f.domain());
+ o_.name_it("o_");
+
+ unsigned nloops = 0;
+
+ // initialisation
+ I o = clone(f);
+ o.name_it("o");
+
+ bool stability;
+ do
+ {
+ ++nloops;
+
+ level::paste(o, o_); // memorisation
+
+ // passe 1
+ {
+ mln_bkd_piter(I) p(f.domain());
+ for_all(p)
+ o(p) = min( max_Nminus(o, p, nbh), g(p) );
+ }
+
+ // passe 2
+ {
+ mln_fwd_piter(I) p(f.domain());
+ for_all(p)
+ o(p) = min( max_Nplus(o, p, nbh), g(p) );
+ }
+
+ stability = (o == o_);
+ }
+ while (not stability);
+
+ std::cout << "nloops = " << nloops << std::endl;
+
+ print_counts();
+
+ mln_postcondition(o <= g);
+ return o;
+ }
+
+ } // end of namespace mln::morpho::Rd
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_RD_SEQUENTIAL_HH
Index: sandbox/geraud/Rd/min.cc
--- sandbox/geraud/Rd/min.cc (revision 0)
+++ sandbox/geraud/Rd/min.cc (revision 0)
@@ -0,0 +1,42 @@
+#include <mln/core/image2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " 1.pgm 2.pgm out.pgm" << std::endl
+ << "(2008 Feb)" << std::endl;
+ exit(1);
+}
+
+
+template <typename I>
+I min(const I& ima1, const I& ima2)
+{
+ mln_precondition(ima1.has_data() and ima2.has_data());
+ mln_precondition(ima1.domain() == ima2.domain());
+ I out(ima1.domain());
+ mln_piter(I) p(ima1.domain());
+ for_all(p)
+ out(p) = ima1(p) < ima2(p) ? ima1(p) : ima2(p);
+ return out;
+}
+
+
+int main(int argc, char* argv[])
+{
+ if (argc != 4)
+ usage(argv);
+
+ using namespace mln;
+ using value::int_u8;
+
+ typedef image2d<int_u8> I;
+
+ I ima1 = io::pgm::load<int_u8>(argv[1]);
+ I ima2 = io::pgm::load<int_u8>(argv[2]);
+
+ io::pgm::save(min(ima1, ima2), argv[3]);
+}
Index: sandbox/geraud/Rd/sequential.hh
--- sandbox/geraud/Rd/sequential.hh (revision 0)
+++ sandbox/geraud/Rd/sequential.hh (revision 0)
@@ -0,0 +1,96 @@
+// Copyright (C) 2007 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_MORPHO_RD_SEQUENTIAL_HH
+# define MLN_MORPHO_RD_SEQUENTIAL_HH
+
+# include "utils.hh"
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace Rd
+ {
+
+ template <typename I, typename N>
+ I sequential(const I& f, const I& g, const N& nbh)
+ {
+ mln_precondition(f <= g);
+
+ f.name_it("f");
+ g.name_it("g");
+
+ I o_(f.domain());
+ o_.name_it("o_");
+
+ // initialisation
+ I o(f.domain());
+ o.name_it("o");
+ level::paste(f, o);
+ // WAS: I o = clone(f);
+
+ bool stability;
+ do
+ {
+ level::paste(o, o_); // memorisation
+
+ // passe 1
+ {
+ mln_bkd_piter(I) p(f.domain());
+ for_all(p)
+ o(p) = min( max_Nminus(o, p, nbh), g(p) );
+ }
+
+ // passe 2
+ {
+ mln_fwd_piter(I) p(f.domain());
+ for_all(p)
+ o(p) = min( max_Nplus(o, p, nbh), g(p) );
+ }
+
+ stability = (o == o_);
+ }
+ while (not stability);
+
+ print_counts();
+
+ mln_postcondition(o <= g);
+ return o;
+ }
+
+ } // end of namespace mln::morpho::Rd
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_RD_SEQUENTIAL_HH
Index: sandbox/geraud/Rd/debase.union_find.hh
--- sandbox/geraud/Rd/debase.union_find.hh (revision 0)
+++ sandbox/geraud/Rd/debase.union_find.hh (revision 0)
@@ -0,0 +1,165 @@
+// Copyright (C) 2007 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 OLN_MORPHO_RD_UNION_FIND_HH
+# define OLN_MORPHO_RD_UNION_FIND_HH
+
+# include <oln/morpho/Rd/utils.hh>
+
+
+namespace oln
+{
+
+ namespace morpho
+ {
+
+ namespace Rd
+ {
+
+
+ template <typename I, typename N>
+ struct union_find_t
+ {
+ typedef oln_point(I) point;
+
+ // in:
+ I f, g;
+ N nbh;
+
+ // out:
+ I o;
+
+ // aux:
+ std::vector<point> S;
+ I data;
+ oln_plain_value(I, bool) is_proc;
+ oln_plain_value(I, point) parent;
+
+ union_find_t(const I& f, const I& g, const N& nbh)
+ : f(f), g(g), nbh(nbh)
+ {
+ prepare(o, with, f);
+ prepare(parent, with, f);
+ prepare(is_proc, with, f);
+ prepare(data, with, f);
+
+ // init
+
+ std::cout << "0 ";
+ level::fill(inplace(is_proc), false);
+ S = histo_reverse_sort(g);
+
+ // first pass
+
+ std::cout << "1 ";
+ for (unsigned i = 0; i < S.size(); ++i)
+ {
+ point p = S[i];
+
+ make_set(p);
+ oln_niter(N) n(nbh, p);
+ for_all(n)
+ if (f.has(n) and is_proc(n))
+ do_union(n, p);
+ is_proc(p) = true;
+ }
+
+ // second pass
+
+ std::cout << "2 ";
+ level::fill(inplace(is_proc), false);
+ for (int i = S.size() - 1; i >= 0; --i)
+ {
+ point p = S[i];
+ assert(is_proc(p) == false);
+ if (parent(p) == p)
+ o(p) = data(p) == 255 ? g(p) : data(p);
+ else
+ {
+ assert(is_proc(parent(p)) == true);
+ o(p) = o(parent(p));
+ }
+ is_proc(p) = true;
+ }
+
+ }
+
+ void make_set(const point& p)
+ {
+ parent(p) = p;
+ data(p) = f(p);
+ }
+
+ point find_root(const point& x)
+ {
+ if (parent(x) == x)
+ return x;
+ else
+ return parent(x) = find_root(parent(x));
+ }
+
+ bool equiv(const point& r, const point& p)
+ {
+ return g(r) == g(p) or g(p) >= data(r);
+ }
+
+ void do_union(const point& n, const point& p)
+ {
+ point r = find_root(n);
+ if (r != p)
+ {
+ if (equiv(r, p))
+ {
+ parent(r) = p;
+ if (data(r) > data(p))
+ data(p) = data(r); // increasing criterion
+ }
+ else
+ data(p) = 255;
+ }
+ }
+
+ };
+
+
+ template <typename I, typename N>
+ I union_find(const I& f, const I& g, const N& nbh)
+ {
+ precondition(f <= g);
+ union_find_t<I, N> run(f, g, nbh);
+ return run.o;
+ }
+
+
+ } // end of namespace oln::morpho::Rd
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLN_MORPHO_RD_UNION_FIND_HH
Index: sandbox/geraud/Rd/union_find.cc
--- sandbox/geraud/Rd/union_find.cc (revision 0)
+++ sandbox/geraud/Rd/union_find.cc (revision 0)
@@ -0,0 +1,50 @@
+#include <mln/core/image2d.hh>
+#include <mln/core/neighb2d.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/debug/println.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include "union_find.hh"
+
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " f.pgm g.pgm c output.pgm" << std::endl
+ << "reconstruction by dilation (union_find version; may 2007)" << std::endl
+ << "f = marker (to be dilated)" << std::endl
+ << "g = mask (constraint >= f)" << std::endl
+ << "c: 4 or 8" << std::endl;
+ exit(1);
+}
+
+
+int main(int argc, char* argv[])
+{
+ if (argc != 5)
+ usage(argv);
+
+ using namespace mln;
+ using value::int_u8;
+
+ typedef image2d<int_u8> I;
+
+ int c = atoi(argv[3]);
+ if (c != 4 and c != 8)
+ usage(argv);
+
+ I f = io::pgm::load<int_u8>(argv[1]);
+ I g = io::pgm::load<int_u8>(argv[2]);
+
+ if (not (f <= g))
+ {
+ std::cerr << "pb" << std::endl;
+ return 1;
+ }
+
+ io::pgm::save(morpho::Rd::union_find(f, g,
+ (c == 4 ? c4() : c8())),
+ argv[4]);
+}
Index: sandbox/geraud/Rd/svg.queue_based.hh
--- sandbox/geraud/Rd/svg.queue_based.hh (revision 0)
+++ sandbox/geraud/Rd/svg.queue_based.hh (revision 0)
@@ -0,0 +1,118 @@
+// Copyright (C) 2007 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_MORPHO_RD_QUEUE_BASED_HH
+# define MLN_MORPHO_RD_QUEUE_BASED_HH
+
+# include <queue>
+# include "utils.hh"
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace Rd
+ {
+
+ template <typename I, typename N>
+ I queue_based(const I& f, const I& g, const N& nbh,
+ bool echo = false)
+ {
+ if (echo) std::cout << std::endl;
+
+ f.name_it("f");
+ g.name_it("g");
+
+ typedef mln_point(I) point;
+ std::queue<point> q;
+ I o;
+ o.name_it("o");
+
+ unsigned n_init_pushs = 0, n_body_pushs = 0, n_pops = 0;
+
+ // initialisation
+ {
+ o = regional_maxima(f, nbh);
+ // p in M <=> o(p) != 0
+ if (echo) debug::println(o);
+
+ mln_piter(I) p(f.domain());
+ mln_niter(N) n(nbh, p);
+
+ for_all(p) if (o(p) != 0) // p in M
+ for_all(n) if (f.has(n) and o(n) == 0) // n not in M
+ {
+ q.push(p);
+ ++n_init_pushs;
+ break;
+ }
+ }
+
+ // propagation
+ {
+ point p;
+ mln_niter(N) n(nbh, p);
+ while (not q.empty())
+ {
+ p = q.front();
+ if (echo) std::cout << std::endl << "pop " << p << " :";
+ q.pop();
+ ++n_pops;
+ for_all(n) if (f.has(n))
+ {
+ if (o(n) < o(p) and o(n) != g(n))
+ {
+ o(n) = min(o(p), g(n));
+ if (echo) std::cout << " push " << n;
+ q.push(n);
+ ++n_body_pushs;
+ }
+ }
+ }
+ if (echo) std::cout << std::endl;
+ }
+
+ std::cout << "n_init_pushs = " << n_init_pushs << std::endl
+ << "n_body_pushs = " << n_body_pushs << std::endl
+ << "n_pops = " << n_pops << std::endl;
+
+ print_counts();
+
+ return o;
+ }
+
+ } // end of namespace mln::morpho::Rd
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_RD_QUEUE_BASED_HH
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix double_neighb2d name.
* mln/core/image/ch_piter.hh: New.
* mln/make/dual_neighb2d.hh: Rename as...
* mln/make/double_neighb2d.hh: ...this.
* doc/examples/tuto_bis.cc: Update.
doc/examples/tuto_bis.cc | 39 ----------
mln/core/image/ch_piter.hh | 167 ++++++++++++++++++++++++++++++++++++++++++++
mln/make/double_neighb2d.hh | 13 +--
3 files changed, 176 insertions(+), 43 deletions(-)
Index: doc/examples/tuto_bis.cc
--- doc/examples/tuto_bis.cc (revision 2281)
+++ doc/examples/tuto_bis.cc (working copy)
@@ -7,7 +7,7 @@
# include <mln/core/alias/window2d.hh>
# include <mln/core/alias/neighb2d.hh>
-# include <mln/make/dual_neighb2d.hh>
+# include <mln/make/double_neighb2d.hh>
# include <mln/core/site_set/p_centered.hh>
# include <mln/literal/origin.hh>
@@ -26,39 +26,6 @@
# include <mln/debug/println.hh>
-/*
-
-namespace mln
-{
-
- namespace level
- {
-
- template<typename I, typename R>
- mln_ch_value(I, R)
- transform(const Image<I>& input_, const std::vector<R>& v)
- {
- trace::entering("level::transform");
- const I& input = exact(input_);
-
- mln_ch_value(I, R) output;
- initialize(output, input);
-
- mln_piter(I) p(input.domain());
- for_all(p)
- output(p) = v[input(p)];
-
- trace::exiting("level::transform");
- return output;
- }
-
- } // mln::level
-
-
-} // mln
-
-*/
-
namespace mln
{
@@ -220,7 +187,7 @@
1, 0, 1,
0, 0, 0 };
- mln_VAR( e2c, make::dual_neighb2d(is_row_odd, e2c_h, e2c_v) );
+ mln_VAR( e2c, make::double_neighb2d(is_row_odd, e2c_h, e2c_v) );
bool e2e_h[] = { 0, 0, 1, 0, 0,
0, 1, 0, 1, 0,
@@ -234,7 +201,7 @@
0, 1, 0, 1, 0,
0, 0, 0, 0, 0 };
- mln_VAR( e2e, make::dual_neighb2d(is_row_odd, e2e_h, e2e_v) );
+ mln_VAR( e2e, make::double_neighb2d(is_row_odd, e2e_h, e2e_v) );
Index: mln/core/image/ch_piter.hh
--- mln/core/image/ch_piter.hh (revision 0)
+++ mln/core/image/ch_piter.hh (revision 0)
@@ -0,0 +1,167 @@
+// 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_CORE_IMAGE_CH_PITER_HH
+# define MLN_CORE_IMAGE_CH_PITER_HH
+
+/*!
+ * \file mln/core/image/ch_piter.hh
+ *
+ * \brief Definition of a morpher that changes the iterators.
+ */
+
+# include <mln/core/internal/image_identity.hh>
+
+
+
+namespace mln
+{
+
+ // Forward declaration.
+ template <typename I, typename Fwd> struct ch_piter_image;
+
+
+ namespace internal
+ {
+
+ /// \internal Data structure for \c mln::ch_piter_image<I,Fwd>.
+ template <typename I, typename Fwd>
+ struct data< ch_piter_image<I,Fwd> >
+ {
+ data(I& ima);
+ I ima_;
+ };
+
+ } // end of namespace mln::internal
+
+
+ namespace trait
+ {
+
+ template <typename I, typename Fwd>
+ struct image_< ch_piter_image<I,Fwd> > : image_< I > // Same as I except...
+ {
+ // ...theis change.
+ typedef trait::image::category::identity_morpher category;
+ };
+
+ } // end of namespace mln::trait
+
+
+
+ // FIXME: Doc!
+
+ template <typename I, typename Fwd>
+ class ch_piter_image : public internal::image_identity< I,
+ mln_pset(I),
+ ch_piter_image<I,Fwd> >
+ {
+ public:
+
+ /// Skeleton.
+ typedef ch_piter_image< tag::image_<I>, Fwd > skeleton;
+
+ typedef Fwd fwd_piter;
+ typedef Fwd bkd_piter; // FIXME
+ typedef fwd_piter piter;
+
+ ch_piter_image();
+ ch_piter_image(I& ima);
+
+ // Deferred initialization.
+ void init_(I& ima);
+ };
+
+
+
+ template <typename Fwd, typename I>
+ ch_piter_image<I,Fwd>
+ ch_piter(Image<I>& ima);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // internal::data< ch_piter_image<I,S> >
+
+ namespace internal
+ {
+
+ template <typename I, typename Fwd>
+ inline
+ data< ch_piter_image<I,Fwd> >::data(I& ima)
+ : ima_(ima)
+ {
+ }
+
+ } // end of namespace mln::internal
+
+
+ // ch_piter_image<I,Fwd>
+
+ template <typename I, typename Fwd>
+ inline
+ ch_piter_image<I,Fwd>::ch_piter_image()
+ {
+ }
+
+ template <typename I, typename Fwd>
+ inline
+ ch_piter_image<I,Fwd>::ch_piter_image(I& ima)
+ {
+ mln_precondition(ima.has_data());
+ init_(ima);
+ }
+
+ template <typename I, typename Fwd>
+ inline
+ void
+ ch_piter_image<I,Fwd>::init_(I& ima)
+ {
+ mln_precondition(ima.has_data());
+ this->data_ = new internal::data< ch_piter_image<I,Fwd> >(ima);
+ }
+
+
+ // ch_piter
+
+ template <typename Fwd, typename I>
+ inline
+ ch_piter_image<I,Fwd>
+ ch_piter(Image<I>& ima)
+ {
+ ch_piter_image<I,Fwd> tmp(exact(ima));
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_IMAGE_CH_PITER_HH
Index: mln/make/double_neighb2d.hh
--- mln/make/double_neighb2d.hh (revision 2281)
+++ mln/make/double_neighb2d.hh (working copy)
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_MAKE_DUAL_NEIGHB2D_HH
-# define MLN_MAKE_DUAL_NEIGHB2D_HH
+#ifndef MLN_MAKE_DOUBLE_NEIGHB2D_HH
+# define MLN_MAKE_DOUBLE_NEIGHB2D_HH
-/*! \file mln/make/dual_neighb2d.hh
+/*! \file mln/make/double_neighb2d.hh
*
* \brief Routine to create a dual neighborhood.
*/
@@ -47,7 +47,7 @@
template <typename A, unsigned St, unsigned Sf>
neighb< win::multiple<window2d, bool(*)(A)> >
- dual_neighb2d(bool (*test)(A),
+ double_neighb2d(bool (*test)(A),
bool const (&when_true) [St],
bool const (&when_false)[Sf]);
@@ -55,11 +55,10 @@
# ifndef MLN_INCLUDE_ONLY
-
template <typename A, unsigned St, unsigned Sf>
inline
neighb< win::multiple<window2d, bool(*)(A)> >
- dual_neighb2d(bool (*test)(A),
+ double_neighb2d(bool (*test)(A),
bool const (&when_true) [St],
bool const (&when_false)[Sf])
{
@@ -78,4 +77,4 @@
} // end of namespace mln
-#endif // ! MLN_MAKE_DUAL_NEIGHB2D_HH
+#endif // ! MLN_MAKE_DOUBLE_NEIGHB2D_HH
1
0
16 Sep '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Make the tricky morpho example fully work.
* mln/core/site_set/p_centered.hh: New.
* mln/core/site_set/all.hh: Update.
* mln/core/image/extended.hh: New.
* mln/core/image/extension_fun.hh,
* mln/core/image/extension_ima.hh,
* mln/core/image/extension_val.hh (ch_value): New.
The extension is propagated to a concrete type iff it can
work.
(todo): New.
* mln/core/image/image1d.hh,
* mln/core/image/image3d.hh (line_piter): De-activate cause it
does not work yet.
* mln/core/point.hh (point): Add explicit to the 1D ctor.
* mln/level/sort_psites.hh: Update.
* mln/border/fill.hh,
* mln/border/mirror.hh: Update.
* mln/fun/i2v/array.hh: New.
* mln/win/all.hh: Update.
* mln/win/multiple.hh (i_): Fix warning.
* doc/examples/tuto_bis.cc: Update.
doc/examples/tuto_bis.cc | 224 +++++++++++++++++------------
mln/border/fill.hh | 4
mln/border/mirror.hh | 30 ++--
mln/core/image/extended.hh | 226 ++++++++++++++++++++++++++++++
mln/core/image/extension_fun.hh | 11 +
mln/core/image/extension_ima.hh | 11 +
mln/core/image/extension_val.hh | 11 +
mln/core/image/image1d.hh | 1
mln/core/image/image3d.hh | 4
mln/core/point.hh | 2
mln/core/site_set/all.hh | 14 +
mln/core/site_set/p_centered.hh | 300 ++++++++++++++++++++++++++++++++++++++++
mln/fun/i2v/array.hh | 147 +++++++++++++++++++
mln/level/sort_psites.hh | 13 +
mln/win/all.hh | 4
mln/win/multiple.hh | 2
16 files changed, 877 insertions(+), 127 deletions(-)
Index: doc/examples/tuto_bis.cc
--- doc/examples/tuto_bis.cc (revision 2280)
+++ doc/examples/tuto_bis.cc (working copy)
@@ -2,37 +2,28 @@
# include <mln/core/image/image2d.hh>
# include <mln/core/image/image_if.hh>
+# include <mln/core/image/extended.hh>
# include <mln/core/routine/extend.hh>
# include <mln/core/alias/window2d.hh>
+# include <mln/core/alias/neighb2d.hh>
# include <mln/make/dual_neighb2d.hh>
+# include <mln/core/site_set/p_centered.hh>
+# include <mln/literal/origin.hh>
-# include <mln/debug/println.hh>
+# include <mln/accu/min_max.hh>
+# include <mln/accu/mean.hh>
+
+# include <mln/fun/i2v/array.hh>
# include <mln/fun/p2v/iota.hh>
# include <mln/level/paste.hh>
# include <mln/level/fill.hh>
+# include <mln/level/transform.hh>
-# include <mln/accu/min_max.hh>
-# include <mln/morpho/meyer_wst.hh>
-
-
-/*
-# include <vector>
-
-# include <mln/core/image/sub_image.hh>
-
-# include <mln/core/alias/neighb2d.hh>
-# include <mln/core/alias/window2d.hh>
-# include <mln/convert/to_window.hh>
-
-# include <mln/morpho/dilation.hh>
# include <mln/morpho/meyer_wst.hh>
-# include <mln/level/transform.hh>
-# include <mln/accu/mean.hh>
-
-*/
+# include <mln/debug/println.hh>
/*
@@ -63,18 +54,49 @@
} // mln::level
+
+} // mln
+
+*/
+
+
+namespace mln
+{
+
+ namespace border
+ {
+
+ template <typename I>
+ void
+ fill(I& ima, const mln_value(I)& v)
+ {
+ const int nrows = ima.nrows();
+ const int ncols = ima.ncols();
+ for (int r = -1; r <= nrows; ++r)
+ {
+ ima.at(r, -1) = v;
+ ima.at(r, ncols) = v;
+ }
+ for (int c = -1; c <= ncols; ++c)
+ {
+ ima.at(-1, c) = v;
+ ima.at(nrows, c) = v;
+ }
+ }
+
+ } // mln::border
+
namespace accu
{
- template <typename A_, typename I, typename L, typename R>
+ template <typename A_, typename I, typename L, typename V>
inline
void
compute(const Image<I>& input_,
const Image<L>& label_,
- std::vector<R>& v)
+ V& v)
{
mlc_is_a(A_, Meta_Accumulator)::check();
-
trace::entering("accu::compute");
const I& input = exact(input_);
@@ -89,51 +111,13 @@
a[label(p)].take(input(p));
for (unsigned l = 1; l < n; ++l)
- v[l] = a[l].to_result();
+ v(l) = a[l];
trace::exiting("accu::compute");
}
} // mln::accu
-} // mln
-
-
-*/
-
-
-namespace mln
-{
-
- template <typename W, typename S>
- void convert_to_site_set(const Window<W>& win,
- const mln_psite(W)& p,
- Site_Set<S>& s_)
- {
- std::cout << "win -> pset" << std::endl;
-
- S& s = exact(s_);
- s.clear();
-
- mln_qiter(W) q(exact(win), p);
- for_all(q)
- exact(s).insert(q);
- }
-
- template <typename N, typename S>
- void convert_to_site_set(const Neighborhood<N>& nbh,
- const mln_psite(N)& p,
- Site_Set<S>& s_)
- {
- S& s = exact(s_);
- s.clear();
-
- mln_niter(N) n(exact(nbh), p);
- for_all(n)
- exact(s).insert(n);
- }
-
-
namespace morpho
{
@@ -157,42 +141,75 @@
return output;
}
+ template <typename I, typename N>
+ mln_concrete(I)
+ dilation(const I& input, const N& nbh)
+ {
+ typedef mln_value(I) V;
+ // extension::fill(input, mln_min(V));
- } // mln::morpho
+ mln_concrete(I) output;
+ initialize(output, input);
+ accu::max_<V> m;
+ mln_piter(I) p(input.domain());
+ mln_niter(N) n(nbh, p);
+ for_all(p)
+ {
+ m.init();
+ for_all(n) if (input.has(n))
+ m.take(input(n));
+ output(p) = m;
+ }
+ return output;
+ }
+
+ } // mln::morpho
} // mln
+
// Functions
+inline
bool is_row_odd(const mln::point2d& p)
{
return p.row() % 2;
}
+inline
bool is_cell(const mln::point2d& p)
{
return p.row() % 2 == 0 && p.col() % 2 == 0;
}
+inline
bool is_edge(const mln::point2d& p)
{
return p.row() % 2 + p.col() % 2 == 1;
}
+inline
bool is_point(const mln::point2d& p)
{
return p.row() % 2 && p.col() % 2;
}
+inline
+bool is_not_edge(const mln::point2d& p)
+{
+ return ! is_edge(p);
+}
+
int main()
{
using namespace mln;
+
// e2c
bool e2c_h[] = { 0, 1, 0,
@@ -221,6 +238,16 @@
+// {
+// p_centered<e2e_t::window> wc(e2e.to_window(), literal::origin);
+// std::cout << wc << std::endl;
+
+// p_set<point2d> s;
+// s += wc;
+// std::cout << s << std::endl;
+// }
+
+
image2d<int> ima(3, 5);
@@ -244,29 +271,26 @@
// 1 1
- unsigned nbasins;
- mln_VAR(wst, morpho::meyer_wst(edge, e2e, nbasins));
- // ^^^
- // edge -> neighboring edges
- debug::println(wst);
- // 2 2
- // 0 0 0
- // 1 1
-
- std::cout << nbasins << " bassins" << std::endl;
- // 2 bassins
-
-
+ image2d<unsigned> label(ima.bbox(), 1);
+ border::fill(label, 0);
+ level::fill(label, 9);
+ debug::println(label);
+ // 9 9 9 9 9
+ // 9 9 9 9 9
+ // 9 9 9 9 9
- /*
- window2d c4 = convert::to_window(mln::c4());
+ mln_VAR(wst, label | is_edge);
+ debug::println(wst);
+ // 9 9
+ // 9 9 9
+ // 9 9
unsigned nbasins;
- mln_VAR(wst, morpho::meyer_wst(edge, nbh_e2e, nbasins));
- // ^^^^^^^
- // edge -> neighbooring edges
+ level::fill(wst, morpho::meyer_wst(edge, e2e, nbasins));
+ // ^^^
+ // edge -> neighboring edges
debug::println(wst);
// 2 2
// 0 0 0
@@ -276,11 +300,15 @@
// 2 bassins
+
+
// '0' IS THE TAG VALUE FOR THE WATERSHED LINE
// THE OTHER VALUES ARE THE REGION LABELS
- std::cout << "the watershed line = " << (wst | 0).domain() << std::endl;
+ mln_VAR(wst_line, wst | (pw::value(wst) == pw::cst(0u))); // FIXME: wst | 0
+ std::cout << "the watershed line = " << wst_line.domain() << std::endl
+ << std::endl;
// the watershed line = {(1,0)(1,2)(1,4)}
// ^^^^^
// meaning (row = 1, col = 0)
@@ -298,22 +326,31 @@
// row
- // YET THOSE VALUES ARE ON EDGES, NOT ON CELLS...
+ // YET THOSE VALUES ARE ON EDGES, NOT ON CELLS...
- mln_VAR(label, wst.full());
debug::println(label);
- // 0 2 0 2 0
- // 0 0 0 0 0
- // 0 1 0 1 0
+ // 9 2 9 2 9
+ // 0 9 0 9 0
+ // 9 1 9 1 9
- level::paste(morpho::dilation(label | is_cell, c4), label);
+
+ mln_VAR(lab, label | is_cell);
+ debug::println(lab);
+ // 9 9 9
+ //
+ // 9 9 9
+
+ level::paste(morpho::dilation(extend(lab, pw::value(label)),
+ c4()),
+ label);
debug::println(label);
// 2 2 2 2 2
- // 0 0 0 0 0
+ // 0 9 0 9 0
// 1 1 1 1 1
- debug::println(label | is_cell);
+
+ debug::println(lab);
// 2 2 2
//
// 1 1 1
@@ -332,18 +369,17 @@
// NOW WE WANT TO MODIFY THE INPUT IMAGE TO FLATTEN REGIONS...
- std::vector<int> m(nbasins + 1);
+ fun::i2v::array<int> m(nbasins + 1);
accu::compute<accu::mean>(cell, label, m);
for (unsigned i = 1; i <= nbasins; ++i)
- std::cout << "mean value of basin " << i << " is " << m[i] << std::endl;
+ std::cout << "mean value of basin #" << i << " is " << m(i) << std::endl;
- level::fill(cell, level::transform(label, m));
+ level::fill(cell, level::transform(lab, m));
debug::println(cell);
// 2 2 2
//
// 5 5 5
- // DONE!
- */
+ // DONE!
}
Index: mln/core/site_set/all.hh
--- mln/core/site_set/all.hh (revision 2280)
+++ mln/core/site_set/all.hh (working copy)
@@ -31,18 +31,24 @@
/*! \file mln/core/site_set/all.hh
*
* \brief File that includes all site_set types.
- *
- * \todo Make it effective after having moved image-defining files.
*/
-// # include <mln/core/site_set/p_array_of.hh> // FIXME: Uncomment.
+# include <mln/core/site_set/box.hh>
+# include <mln/core/site_set/line2d.hh>
+# include <mln/core/site_set/p_array.hh>
+# include <mln/core/site_set/p_centered.hh>
+# include <mln/core/site_set/p_if.hh>
# include <mln/core/site_set/p_image.hh>
# include <mln/core/site_set/p_key.hh>
# include <mln/core/site_set/p_mutable_array_of.hh>
+# include <mln/core/site_set/p_priority.hh>
+# include <mln/core/site_set/p_queue.hh>
+# include <mln/core/site_set/p_queue_fast.hh>
+# include <mln/core/site_set/p_run.hh>
+# include <mln/core/site_set/p_set.hh>
# include <mln/core/site_set/p_set_of.hh>
# include <mln/core/site_set/p_vaccess.hh>
-// FIXME: Complete...
#endif // ! MLN_CORE_SITE_SET_ALL_HH
Index: mln/core/site_set/p_centered.hh
--- mln/core/site_set/p_centered.hh (revision 0)
+++ mln/core/site_set/p_centered.hh (revision 0)
@@ -0,0 +1,300 @@
+// Copyright (C) 2007, 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_CORE_SITE_SET_P_CENTERED_HH
+# define MLN_CORE_SITE_SET_P_CENTERED_HH
+
+/*! \file mln/core/site_set/p_centered.hh
+ *
+ * \brief This file defines the site set corresponding to a window
+ * centered on a site.
+ *
+ * \todo Add the bkd iter.
+ * \todo Code is_valid() and change_target() for the site set.
+ */
+
+# include <mln/core/internal/site_set_base.hh>
+
+
+namespace mln
+{
+
+ // Fwd decls.
+ template <typename W> class p_centered;
+ template <typename W> class p_centered_piter;
+
+
+ namespace trait
+ {
+
+ template <typename W>
+ struct site_set_< p_centered<W> >
+ {
+ typedef trait::site_set::nsites::unknown nsites;
+ typedef trait::site_set::bbox::unknown bbox;
+ typedef trait::site_set::contents::fixed contents;
+ typedef trait::site_set::arity::unique arity;
+ };
+
+// template <typename W>
+// struct set_precise_unary_< op::ord, p_centered<W> >
+// {
+// typedef set_precise_unary_< op::ord, p_centered<W> > ret; // Itself.
+// bool strict(const p_centered<W>& lhs, const p_centered<W>& rhs) const;
+// };
+
+ } // end of namespace mln::trait
+
+
+ template <typename W>
+ class p_centered : public internal::site_set_base_< mln_psite(W), p_centered<W> >,
+ private mlc_is_a(W, Window)::check_t
+ {
+ public:
+
+ /// Psite associated type.
+ typedef mln_psite(W) psite;
+
+ /// Site associated type.
+ typedef mln_site(W) site;
+
+
+ /// Element associated type.
+ typedef psite element;
+
+
+ /// Forward Site_Iterator associated type.
+ typedef p_centered_piter<W> fwd_piter;
+
+ /// Backward Site_Iterator associated type.
+ typedef p_centered_piter<W> bkd_piter; // FIXME
+
+ /// Site_Iterator associated type.
+ typedef fwd_piter piter;
+
+
+ /// Constructor without argument.
+ p_centered();
+
+ /// Constructor from a window \p win and a center \p c.
+ p_centered(const W& win, const mln_psite(W)& c);
+
+
+ /// Test if \p p belongs to the box.
+ template <typename P>
+ bool has(const P& p) const;
+
+ /// Test if this site set is initialized.
+ bool is_valid() const;
+
+ /// Return the size of this site set in memory.
+ std::size_t memory_size() const;
+
+ /// Give the center of this site set.
+ const mln_psite(W)& center() const;
+
+ /// Give the window this site set is defined upon.
+ const W& window() const;
+
+ protected:
+
+ W win_;
+ mln_psite(W) c_;
+ };
+
+
+ template <typename W>
+ class p_centered_piter : public internal::site_set_iterator_base< p_centered<W>,
+ p_centered_piter<W> >
+ {
+ typedef p_centered_piter<W> self_;
+ typedef internal::site_set_iterator_base< p_centered<W>, self_ > super_;
+ public:
+
+ /// Constructor without argument.
+ p_centered_piter();
+
+ /// Constructor.
+ p_centered_piter(const p_centered<W>& s);
+
+ /// Test the iterator validity.
+ bool is_valid_() const;
+
+ /// Invalidate the iterator.
+ void invalidate_();
+
+ /// Start an iteration.
+ void start_();
+
+ /// Go to the next point.
+ void next_();
+
+ protected:
+ using super_::p_;
+ using super_::s_;
+
+ mln_fwd_qiter(W) q_;
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // p_centered<W>
+
+ template <typename W>
+ inline
+ bool
+ p_centered<W>::is_valid() const
+ {
+ return true; // FIXME
+ }
+
+ template <typename W>
+ inline
+ p_centered<W>::p_centered()
+ {
+ }
+
+ template <typename W>
+ inline
+ p_centered<W>::p_centered(const W& win, const mln_psite(W)& c)
+ : win_(win),
+ c_(c)
+ {
+ mln_precondition(is_valid());
+ }
+
+ template <typename W>
+ template <typename P>
+ inline
+ bool
+ p_centered<W>::has(const P&) const
+ {
+ mln_precondition(is_valid());
+ return true; // FIXME
+ }
+
+ template <typename W>
+ inline
+ std::size_t
+ p_centered<W>::memory_size() const
+ {
+ return sizeof(*this);
+ }
+
+ template <typename W>
+ inline
+ const mln_psite(W)&
+ p_centered<W>::center() const
+ {
+ return c_;
+ }
+
+ template <typename W>
+ inline
+ const W&
+ p_centered<W>::window() const
+ {
+ return win_;
+ }
+
+// namespace trait
+// {
+
+// template <typename W>
+// inline
+// bool
+// set_precise_unary_< op::ord, p_centered<W> >::strict(const p_centered<W>& lhs, const p_centered<W>& rhs) const
+// {
+// // Lexicographical over "pmin then pmax".
+// return util::ord_lexi_strict(lhs.pmin(), lhs.pmax(),
+// rhs.pmin(), rhs.pmax());
+// }
+
+// } // end of namespace mln::trait
+
+
+ // p_centered_piter<W>
+
+ template <typename W>
+ inline
+ p_centered_piter<W>::p_centered_piter()
+ {
+ }
+
+ template <typename W>
+ inline
+ p_centered_piter<W>::p_centered_piter(const p_centered<W>& s)
+ {
+ this->change_target(s);
+ q_.center_at(s.center());
+ q_.change_target(s.window());
+ }
+
+ template <typename W>
+ inline
+ bool
+ p_centered_piter<W>::is_valid_() const
+ {
+ return q_.is_valid();
+ }
+
+ template <typename W>
+ inline
+ void
+ p_centered_piter<W>::invalidate_()
+ {
+ q_.invalidate();
+ }
+
+ template <typename W>
+ inline
+ void
+ p_centered_piter<W>::start_()
+ {
+ q_.start();
+ if (is_valid_())
+ p_ = q_;
+ }
+
+ template <typename W>
+ inline
+ void
+ p_centered_piter<W>::next_()
+ {
+ q_.next();
+ if (is_valid_())
+ p_ = q_;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_SITE_SET_P_CENTERED_HH
Index: mln/core/image/extension_fun.hh
--- mln/core/image/extension_fun.hh (revision 2280)
+++ mln/core/image/extension_fun.hh (working copy)
@@ -35,10 +35,10 @@
* with a function.
*
* \todo Deal with two-ways functions...
+ * \todo Use an envelop as lvalue to test extension writing.
*/
# include <mln/core/internal/image_identity.hh>
-# include <mln/metal/converts_to.hh>
@@ -81,6 +81,15 @@
typedef trait::image::ext_io::read_only ext_io;
};
+ template <typename I, typename F, typename V>
+ struct ch_value< extension_fun<I, F>, V >
+ {
+ typedef mlc_converts_to(mln_result(F), V) keep_ext;
+ typedef mln_ch_value(I, V) Iv;
+ typedef extension_fun<Iv, F> Iv_ext;
+ typedef mlc_if(keep_ext, Iv_ext, Iv) ret;
+ };
+
} // end of namespace mln::trait
Index: mln/core/image/extended.hh
--- mln/core/image/extended.hh (revision 0)
+++ mln/core/image/extended.hh (revision 0)
@@ -0,0 +1,226 @@
+// 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_CORE_IMAGE_EXTENDED_HH
+# define MLN_CORE_IMAGE_EXTENDED_HH
+
+/*!
+ * \file mln/core/image/extended.hh
+ *
+ * \brief Definition of morpher that makes an image become restricted
+ * given by a point set.
+ *
+ * \todo Add a special case for "ima | box"; think about some other
+ * special cases...
+ */
+
+# include <mln/core/internal/image_domain_morpher.hh>
+# include <mln/core/site_set/box.hh>
+
+
+namespace mln
+{
+
+
+ // Forward declaration.
+ template <typename I> class extended;
+
+
+ namespace internal
+ {
+
+ /// Data structure for \c mln::extended<I>.
+ template <typename I>
+ struct data< extended<I> >
+ {
+ data(I& ima, const box<mln_site(I)>& b_);
+
+ I ima_;
+ box<mln_site(I)> b_;
+ };
+
+ } // end of namespace mln::internal
+
+
+
+ namespace trait
+ {
+
+ template <typename I>
+ struct image_< extended<I> > : default_image_morpher< I,
+ mln_value(I),
+ extended<I> >
+ {
+ typedef trait::image::category::domain_morpher category;
+
+ typedef trait::image::ext_domain::none ext_domain;
+ typedef trait::image::ext_value::irrelevant ext_value;
+ typedef trait::image::ext_io::irrelevant ext_io;
+
+ typedef trait::image::value_storage::disrupted value_storage;
+ };
+
+ } // end of namespace mln::trait
+
+
+
+ // FIXME: Doc!
+
+ template <typename I>
+ struct extended : public internal::image_domain_morpher< I,
+ box<mln_site(I)>,
+ extended<I> >,
+ private mlc_not_equal(mln_trait_image_ext_domain(I),
+ trait::image::ext_domain::none)::check_t
+ {
+ /// Skeleton.
+ typedef tag::image_<I> skeleton; // This property is lost!
+
+ /// Constructor without argument.
+ extended();
+
+ /// Constructor.
+ extended(I& ima, const box<mln_site(I)>& );
+
+ /// Initialization.
+ void init_(I& ima, const box<mln_site(I)>& b);
+
+ /// Give the definition domain.
+ const box<mln_site(I)>& domain() const;
+ };
+
+
+
+ template <typename I, typename J>
+ void init_(tag::image_t, extended<I>& target, const J& model);
+
+
+ template <typename I, typename B>
+ extended<const I>
+ extended_to(const Image<I>& ima, const Box<B>& b);
+
+ template <typename I, typename B>
+ extended<I>
+ extended_to(Image<I>& ima, const Box<B>& b);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // init_
+
+ template <typename I, typename J>
+ inline
+ void init_(tag::image_t, extended<I>& target, const J& model)
+ {
+ I ima;
+ init_(tag::image, ima, model);
+ box<mln_site(I)> b;
+ init_(tag::bbox, b, model);
+ target.init_(ima, b);
+ }
+
+
+ // internal::data< extended<I> >
+
+ namespace internal
+ {
+
+ template <typename I>
+ inline
+ data< extended<I> >::data(I& ima, const box<mln_site(I)>& b)
+ : ima_(ima),
+ b_(b)
+ {
+ }
+
+ } // end of namespace mln::internal
+
+
+ // extended<I>
+
+ template <typename I>
+ inline
+ extended<I>::extended()
+ {
+ }
+
+ template <typename I>
+ inline
+ extended<I>::extended(I& ima, const box<mln_site(I)>& b)
+ {
+ init_(ima, b);
+ }
+
+ template <typename I>
+ inline
+ void
+ extended<I>::init_(I& ima, const box<mln_site(I)>& b)
+ {
+ mln_precondition(! this->has_data());
+ this->data_ = new internal::data< extended<I> >(ima, b);
+ }
+
+ template <typename I>
+ inline
+ const box<mln_site(I)>&
+ extended<I>::domain() const
+ {
+ return this->data_->b_;
+ }
+
+
+ // extended_to
+
+ template <typename I, typename B>
+ extended<const I>
+ extended_to(const Image<I>& ima, const Box<B>& b)
+ {
+ mlc_not_equal(mln_trait_image_ext_domain(I),
+ trait::image::ext_domain::none)::check();
+ mln_precondition(exact(ima).has_data());
+ extended<const I> tmp(exact(ima), exact(b));
+ return tmp;
+ }
+
+ template <typename I, typename B>
+ extended<I>
+ extended_to(Image<I>& ima, const Box<B>& b)
+ {
+ mlc_not_equal(mln_trait_image_ext_domain(I),
+ trait::image::ext_domain::none)::check();
+ mln_precondition(exact(ima).has_data());
+ extended<I> tmp(exact(ima), exact(b));
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_IMAGE_EXTENDED_HH
Index: mln/core/image/extension_ima.hh
--- mln/core/image/extension_ima.hh (revision 2280)
+++ mln/core/image/extension_ima.hh (working copy)
@@ -35,10 +35,10 @@
* with a function.
*
* \todo Use the 'instant' mechanism.
+ * \todo Use an envelop as lvalue to test extension writing.
*/
# include <mln/core/internal/image_identity.hh>
-# include <mln/metal/converts_to.hh>
@@ -81,6 +81,15 @@
typedef mln_trait_image_value_io(J) ext_io;
};
+ template <typename I, typename J, typename V>
+ struct ch_value< extension_ima<I, J>, V >
+ {
+ typedef mlc_converts_to(mln_result(J), V) keep_ext;
+ typedef mln_ch_value(I, V) Iv;
+ typedef extension_ima<Iv, J> Iv_ext;
+ typedef mlc_if(keep_ext, Iv_ext, Iv) ret;
+ };
+
} // end of namespace mln::trait
Index: mln/core/image/image1d.hh
--- mln/core/image/image1d.hh (revision 2280)
+++ mln/core/image/image1d.hh (working copy)
@@ -39,7 +39,6 @@
# include <mln/value/set.hh>
# include <mln/fun/i2v/all_to.hh>
-# include <mln/core/line_piter.hh>
// FIXME:
Index: mln/core/image/image3d.hh
--- mln/core/image/image3d.hh (revision 2280)
+++ mln/core/image/image3d.hh (working copy)
@@ -40,7 +40,7 @@
# include <mln/value/set.hh>
# include <mln/fun/i2v/all_to.hh>
-# include <mln/core/line_piter.hh>
+// # include <mln/core/line_piter.hh>
// FIXME:
@@ -131,7 +131,7 @@
typedef dpoint3d dpoint;
typedef mln_fwd_piter(box3d) fwd_piter;
typedef mln_bkd_piter(box3d) bkd_piter;
- typedef line_piter_<point> line_piter;
+// typedef line_piter_<point> line_piter;
// End of warning.
Index: mln/core/image/extension_val.hh
--- mln/core/image/extension_val.hh (revision 2280)
+++ mln/core/image/extension_val.hh (working copy)
@@ -34,10 +34,10 @@
* \brief Definition of a morpher that extends the domain of an image.
*
* \todo Use the 'instant' mechanism.
+ * \todo Use an envelop as lvalue to test extension writing.
*/
# include <mln/core/internal/image_identity.hh>
-# include <mln/metal/converts_to.hh>
@@ -80,6 +80,15 @@
typedef trait::image::ext_io::read_write ext_io;
};
+ template <typename I, typename V>
+ struct ch_value< extension_val<I>, V >
+ {
+ typedef mlc_converts_to(mln_value(I), V) keep_ext;
+ typedef mln_ch_value(I, V) Iv;
+ typedef extension_val<Iv> Iv_ext;
+ typedef mlc_if(keep_ext, Iv_ext, Iv) ret;
+ };
+
} // end of namespace mln::trait
Index: mln/core/point.hh
--- mln/core/point.hh (revision 2280)
+++ mln/core/point.hh (working copy)
@@ -140,7 +140,7 @@
/// \{ Constructors with different numbers of arguments
/// (coordinates) w.r.t. the dimension.
- point(C ind);
+ explicit point(C ind);
point(C row, C col);
point(C sli, C row, C col);
/// \}
Index: mln/level/sort_psites.hh
--- mln/level/sort_psites.hh (revision 2280)
+++ mln/level/sort_psites.hh (working copy)
@@ -38,6 +38,7 @@
# include <mln/core/concept/image.hh>
# include <mln/convert/to_p_array.hh>
# include <mln/histo/compute.hh>
+# include <mln/util/ord.hh>
namespace mln
@@ -89,8 +90,10 @@
bool operator()(const mln_psite(I)& lhs,
const mln_psite(I)& rhs) const
{
- return ima_(lhs) < ima_(rhs) || (ima_(lhs) == ima_(rhs)
- && lhs < rhs);
+ return util::ord_strict(ima_(lhs), ima_(rhs))
+ || (ima_(lhs) == ima_(rhs)
+ &&
+ util::ord_strict(lhs, rhs));
}
};
@@ -109,8 +112,10 @@
bool operator()(const mln_psite(I)& lhs,
const mln_psite(I)& rhs) const
{
- return ima_(lhs) > ima_(rhs) || (ima_(lhs) == ima_(rhs)
- && lhs > rhs);
+ return util::ord_strict(ima_(rhs), ima_(lhs))
+ || (ima_(lhs) == ima_(rhs)
+ &&
+ util::ord_strict(rhs, lhs));
}
};
Index: mln/border/fill.hh
--- mln/border/fill.hh (revision 2280)
+++ mln/border/fill.hh (working copy)
@@ -77,12 +77,12 @@
for_all (pl)
{
std::size_t end = ima.index_of_point (pl);
- std::memset((void*)&ima[st],
+ std::memset((void*)&ima.element(st),
*(const int*)(&v),
end - st);
st = end + len_r;
}
- std::memset((void*)&ima[st],
+ std::memset((void*)&ima.element(st),
*(const int*)(&v),
ima.nelements () - st);
Index: mln/border/mirror.hh
--- mln/border/mirror.hh (revision 2280)
+++ mln/border/mirror.hh (working copy)
@@ -73,9 +73,10 @@
template <typename I>
inline
- void mirror_(const box1d&, const I& ima)
+ void mirror_(const box1d&, const I& ima_)
{
trace::entering("border::impl::mirror_");
+ I& ima = const_cast<I&>(ima_);
std::size_t border = ima.border ();
std::size_t nbinds = geom::ninds(ima);
@@ -90,10 +91,10 @@
{
std::size_t i = 0;
for (; i < min; ++i)
- const_cast<I&>(ima)[border - 1 - i] = ima(point1d(i));
+ ima.element(border - 1 - i) = ima(point1d(i));
for (; i < border; ++i)
- const_cast<I&>(ima)[border - 1 - i] = ima(point1d(min - 1));
+ ima.element(border - 1 - i) = ima(point1d(min - 1));
}
/// right border
@@ -103,21 +104,22 @@
for (;
i < min;
++i, --j)
- const_cast<I&>(ima)[border + nbinds + i] = ima(point1d(j));
+ ima.element(border + nbinds + i) = ima(point1d(j));
++j;
for (;
i < border;
++i)
- const_cast<I&>(ima)[border + nbinds + i] = ima(point1d(j));
+ ima.element(border + nbinds + i) = ima(point1d(j));
}
trace::exiting("border::impl::mirror_");
}
template <typename I>
inline
- void mirror_(const box2d&, const I& ima)
+ void mirror_(const box2d&, const I& ima_)
{
trace::entering("border::impl::mirror_");
+ I& ima = const_cast<I&>(ima_);
std::size_t border = ima.border ();
std::size_t nbrows = geom::max_row(ima) - geom::min_row(ima);
@@ -129,49 +131,49 @@
// mirror top left corner
for (std::size_t i = 0; i < border; ++i)
for (std::size_t j = 0; j < border; ++j)
- const_cast<I&>(ima)[i * ((nbcols + 1) + 2 * border) + j] = ima[s];
+ ima.element(i * ((nbcols + 1) + 2 * border) + j) = ima.element(s);
// mirror top left corner
s = start + nbcols;
for (std::size_t i = 0; i < border; ++i)
for (std::size_t j = 1; j <= border; ++j)
- const_cast<I&>(ima)[i * ((nbcols + 1) + 2 * border) + (nbcols + border + j)] = ima[s];
+ ima.element(i * ((nbcols + 1) + 2 * border) + (nbcols + border + j)) = ima.element(s);
// mirror bottom left corner
s = start + (nbrows * real_nbcols);
for (std::size_t i = 1; i <= border; ++i)
for (std::size_t j = 1; j <= border; ++j)
- const_cast<I&>(ima)[s - i + (j * (real_nbcols))] = ima[s];
+ ima.element(s - i + (j * (real_nbcols))) = ima.element(s);
// mirror bottom right corner
s = start + (nbrows * real_nbcols) + nbcols;
for (std::size_t i = 1; i <= border; ++i)
for (std::size_t j = 1; j <= border; ++j)
- const_cast<I&>(ima)[s + i + (j * real_nbcols)] = ima[s];
+ ima.element(s + i + (j * real_nbcols)) = ima.element(s);
// mirror top border
s = start;
for (std::size_t i = 0; i <= nbcols; ++i)
for (std::size_t j = 1; j <= border; ++j)
- const_cast<I&>(ima)[s + i - (j * real_nbcols)] = ima[s + i + ((j - 1)* real_nbcols)];
+ ima.element(s + i - (j * real_nbcols)) = ima.element(s + i + ((j - 1)* real_nbcols));
// mirror left border
s = start;
for (std::size_t i = 0; i <= nbrows; ++i)
for (std::size_t j = 1; j <= border; ++j)
- const_cast<I&>(ima)[s + (i * real_nbcols) - j] = ima[s + (i * real_nbcols) + (j - 1)];
+ ima.element(s + (i * real_nbcols) - j) = ima.element(s + (i * real_nbcols) + (j - 1));
// mirror right border
s = start;
for (std::size_t i = 0; i <= nbrows; ++i)
for (std::size_t j = 1; j <= border; ++j)
- const_cast<I&>(ima)[s + (i * real_nbcols + nbcols) + j] = ima[s + (i * real_nbcols + nbcols) - (j - 1)];
+ ima.element(s + (i * real_nbcols + nbcols) + j) = ima.element(s + (i * real_nbcols + nbcols) - (j - 1));
// mirror bottom border
s = start + (nbrows * real_nbcols);
for (std::size_t i = 0; i <= nbcols; ++i)
for (std::size_t j = 1; j <= border; ++j)
- const_cast<I&>(ima)[s + i + (j * real_nbcols)] = ima[s + i - ((j - 1)* real_nbcols)];
+ ima.element(s + i + (j * real_nbcols)) = ima.element(s + i - ((j - 1)* real_nbcols));
trace::exiting("border::impl::mirror_");
}
Index: mln/fun/i2v/array.hh
--- mln/fun/i2v/array.hh (revision 0)
+++ mln/fun/i2v/array.hh (revision 0)
@@ -0,0 +1,147 @@
+// 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_FUN_I2V_ARRAY_HH
+# define MLN_FUN_I2V_ARRAY_HH
+
+/*! \file mln/fun/i2v/array.hh
+ *
+ * \brief FIXME.
+ */
+
+# include <vector>
+# include <algorithm>
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace i2v
+ {
+
+ template <typename T>
+ class array : public Function_i2v< array<T> >
+ {
+ public:
+
+ typedef T result;
+
+ array();
+ array(unsigned n);
+
+ void resize(unsigned n);
+ unsigned size() const;
+
+ T operator()(unsigned i) const;
+ T& operator()(unsigned i);
+
+ private:
+ std::vector<T> v_;
+ };
+
+ } // end of namespace mln::fun::i2v
+
+ } // end of namespace mln::fun
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace fun
+ {
+
+ namespace i2v
+ {
+
+ template <typename T>
+ inline
+ array<T>::array()
+ {
+ }
+
+ template <typename T>
+ inline
+ array<T>::array(unsigned n)
+ {
+ resize(n);
+ }
+
+ template <typename T>
+ inline
+ void
+ array<T>::resize(unsigned n)
+ {
+ v_.resize(n);
+ }
+
+ template <typename T>
+ inline
+ unsigned
+ array<T>::size() const
+ {
+ return v_.size();
+ }
+
+ template <typename T>
+ inline
+ T
+ array<T>::operator()(unsigned i) const
+ {
+ mln_precondition(i < v_.size());
+ return v_[i];
+ }
+
+ template <typename T>
+ inline
+ T&
+ array<T>::operator()(unsigned i)
+ {
+ mln_precondition(i < v_.size());
+ return v_[i];
+ }
+
+ } // end of namespace mln::fun::i2v
+
+ } // end of namespace mln::fun
+
+ template <typename T>
+ inline
+ fun::i2v::array<T> array(T t)
+ {
+ fun::i2v::array<T> tmp(t);
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_I2V_ARRAY_HH
Index: mln/win/all.hh
--- mln/win/all.hh (revision 2280)
+++ mln/win/all.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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
@@ -44,10 +44,12 @@
# include <mln/win/backdiag2d.hh>
# include <mln/win/cube3d.hh>
+# include <mln/win/cuboid3d.hh>
# include <mln/win/diag2d.hh>
# include <mln/win/disk2d.hh>
# include <mln/win/hline2d.hh>
# include <mln/win/line.hh>
+# include <mln/win/multiple.hh>
# include <mln/win/octagon2d.hh>
# include <mln/win/rectangle2d.hh>
# include <mln/win/segment1d.hh>
Index: mln/win/multiple.hh
--- mln/win/multiple.hh (revision 2280)
+++ mln/win/multiple.hh (working copy)
@@ -119,7 +119,7 @@
mln_psite(W) compute_p_() const;
private:
- int i_;
+ unsigned i_;
unsigned n_() const;
};
1
0
URL: https://svn.lrde.epita.fr/svn/scool/branches/scool-ng
ChangeLog:
2008-09-16 Maxime van Noppen <yabo(a)lrde.epita.fr>
Handle function parameters
* src/scoolt/Declaration.str: Handle function parameters.
* src/scoolt/Function.str: Convert parameters.
* src/scoolt/Type.str: Handle the "type" keyword.
Declaration.str | 5 +++--
Function.str | 37 +++++++++++++++++++++++++++++++++++--
Type.str | 3 +++
3 files changed, 41 insertions(+), 4 deletions(-)
Index: branches/scool-ng/src/scoolt/Type.str
===================================================================
--- branches/scool-ng/src/scoolt/Type.str (revision 83)
+++ branches/scool-ng/src/scoolt/Type.str (revision 84)
@@ -15,6 +15,9 @@
<+ <eq> (type, "double")
TypeToCxx:
+ "type" -> CxxType("typename")
+
+ TypeToCxx:
SimpleType(type) -> CxxType(type)
TypeToCxx:
Index: branches/scool-ng/src/scoolt/Declaration.str
===================================================================
--- branches/scool-ng/src/scoolt/Declaration.str (revision 83)
+++ branches/scool-ng/src/scoolt/Declaration.str (revision 84)
@@ -42,16 +42,17 @@
////////////////////////////////////////////////////////////////////////////////
DeclarationToCxx:
- |[ ~idf : ~ftype:fun_type; ]| -> CxxFun([], cxx_ret_type, cxx_idf, cxx_args)
+ |[ ~idf : ~ftype:fun_type; ]| -> CxxFun(cxx_params, cxx_ret_type, cxx_idf, cxx_args)
where
<IdentifierToCxx> idf => cxx_idf
; <TypeToCxx> <GetReturnType> fun_type => cxx_ret_type
+ ; <ParametersToCxx> <GetParameters> fun_type => cxx_params
; <ArgumentsToCxx> <GetArguments> fun_type => cxx_args
DeclarationToCxx:
|[ ~idf : ~ftype:fun_type = { ~fbody:body } ]| -> CxxFun([], cxx_ret_type, cxx_idf, cxx_args, cxx_body)
where
- <?FunctionType(None(), _, _)> fun_type // Ensure there are no parameters
+ <?FunctionType(None(), _, _)> fun_type // Ensure that there is no parameters
; <IdentifierToCxx> idf => cxx_idf
; <TypeToCxx> <GetReturnType> fun_type => cxx_ret_type
; <ArgumentsToCxx> <GetArguments> fun_type => cxx_args
Index: branches/scool-ng/src/scoolt/Function.str
===================================================================
--- branches/scool-ng/src/scoolt/Function.str (revision 83)
+++ branches/scool-ng/src/scoolt/Function.str (revision 84)
@@ -4,12 +4,40 @@
rules
- GetReturnType:
- FunctionType(_, _, ret_type) -> ret_type
+ // Extract data from a FunctionType
+
+ GetParameters:
+ FunctionType(None(), _, _) -> None()
+
+ GetParameters:
+ FunctionType(Some(params), _, _) -> params
GetArguments:
FunctionType(_, args, _) -> args
+ GetReturnType:
+ FunctionType(_, _, ret_type) -> ret_type
+
+
+
+
+ // Convert parameters (templates)
+
+ ParametersToCxx:
+ None() -> []
+
+ ParametersToCxx:
+ ParametersDeclaration(param_list) -> <map (ParameterToCxx)> param_list
+
+ ParameterToCxx:
+ TypedId(idf, type) -> (cxx_type, cxx_idf)
+ where
+ <IdentifierToCxx> idf => cxx_idf
+ ; <TypeToCxx> type => cxx_type
+
+
+ // Convert arguments
+
ArgumentsToCxx:
ArgumentsDeclaration(arg_list) -> <map (ArgumentToCxx)> arg_list
@@ -19,6 +47,11 @@
<TypeToConstRefCxx <+ TypeToCxx> type => cxx_type
; <IdentifierToCxx> idf => cxx_idf
+
+
+
+ // Convert function statements
+
FunctionStatementToCxx:
ReturnStatement(exp) -> CxxExpStm(CxxKeyword("return", cxx_exp))
where
Property changes on: branches/scool-ng
___________________________________________________________________
Name: mailto
- transformers-patches(a)lrde.epita.fr
olena-patches(a)lrde.epita.fr
--
\__/ \__/
(00) Maxime `yabo` van Noppen (00)
___) \ Epita 2009 / (___
(_____/ \_____)
1
0
URL: https://svn.lrde.epita.fr/svn/scool/branches/scool-ng
ChangeLog:
2008-09-16 Maxime van Noppen <yabo(a)lrde.epita.fr>
Add tests on templates
* function/c++_ast/declaration_005.aterm: New.
* function/c++_ast/declaration_006.aterm: New.
* function/c++_ast/declaration_007.aterm: New.
* function/scool_ast/declaration_005.aterm: New.
* function/scool_ast/declaration_006.aterm: New.
* function/scool_ast/declaration_007.aterm: New.
* function/scool_ast/declaration_008.aterm: New.
* function/scool_src/declaration_005.scl: New.
* function/scool_src/declaration_006.scl: New.
* function/scool_src/declaration_007.scl: New.
* function/scool_src/declaration_008.scl: New.
c++_ast/declaration_005.aterm | 1 +
c++_ast/declaration_006.aterm | 1 +
c++_ast/declaration_007.aterm | 1 +
scool_ast/declaration_005.aterm | 1 +
scool_ast/declaration_006.aterm | 1 +
scool_ast/declaration_007.aterm | 1 +
scool_ast/declaration_008.aterm | 1 +
scool_src/declaration_005.scl | 1 +
scool_src/declaration_006.scl | 1 +
scool_src/declaration_007.scl | 1 +
scool_src/declaration_008.scl | 1 +
11 files changed, 11 insertions(+)
Index: branches/scool-ng/tests/function/c++_ast/declaration_005.aterm
===================================================================
--- branches/scool-ng/tests/function/c++_ast/declaration_005.aterm (revision 0)
+++ branches/scool-ng/tests/function/c++_ast/declaration_005.aterm (revision 83)
@@ -0,0 +1 @@
+CxxProgram([CxxFun([(CxxType("typename"),CxxId("T"))],CxxType("void"),CxxId("foo"),[])])
Index: branches/scool-ng/tests/function/c++_ast/declaration_006.aterm
===================================================================
--- branches/scool-ng/tests/function/c++_ast/declaration_006.aterm (revision 0)
+++ branches/scool-ng/tests/function/c++_ast/declaration_006.aterm (revision 83)
@@ -0,0 +1 @@
+CxxProgram([CxxFun([(CxxType("typename"),CxxId("T"))],CxxType("void"),CxxId("foo"),[(CxxConstType(CxxRefType(CxxType("T"))),CxxId("a"))])])
Index: branches/scool-ng/tests/function/c++_ast/declaration_007.aterm
===================================================================
--- branches/scool-ng/tests/function/c++_ast/declaration_007.aterm (revision 0)
+++ branches/scool-ng/tests/function/c++_ast/declaration_007.aterm (revision 83)
@@ -0,0 +1 @@
+CxxProgram([CxxFun([(CxxType("typename"),CxxId("T")),(CxxType("typename"),CxxId("S"))],CxxType("void"),CxxId("foo"),[(CxxConstType(CxxRefType(CxxType("T"))),CxxId("a")),(CxxConstType(CxxRefType(CxxType("S"))),CxxId("b"))])])
Index: branches/scool-ng/tests/function/scool_ast/declaration_005.aterm
===================================================================
--- branches/scool-ng/tests/function/scool_ast/declaration_005.aterm (revision 0)
+++ branches/scool-ng/tests/function/scool_ast/declaration_005.aterm (revision 83)
@@ -0,0 +1 @@
+Program([FunctionDeclaration(None,Identifier("foo"),FunctionType(Some(ParametersDeclaration([TypedId(Identifier("T"),"type")])),ArgumentsDeclaration([]),SimpleType("void")))])
Index: branches/scool-ng/tests/function/scool_ast/declaration_006.aterm
===================================================================
--- branches/scool-ng/tests/function/scool_ast/declaration_006.aterm (revision 0)
+++ branches/scool-ng/tests/function/scool_ast/declaration_006.aterm (revision 83)
@@ -0,0 +1 @@
+Program([FunctionDeclaration(None,Identifier("foo"),FunctionType(Some(ParametersDeclaration([TypedId(Identifier("T"),"type")])),ArgumentsDeclaration([TypedId(Identifier("a"),SimpleType("T"))]),SimpleType("void")))])
Index: branches/scool-ng/tests/function/scool_ast/declaration_007.aterm
===================================================================
--- branches/scool-ng/tests/function/scool_ast/declaration_007.aterm (revision 0)
+++ branches/scool-ng/tests/function/scool_ast/declaration_007.aterm (revision 83)
@@ -0,0 +1 @@
+Program([FunctionDeclaration(None,Identifier("foo"),FunctionType(Some(ParametersDeclaration([TypedId(Identifier("T"),"type"),TypedId(Identifier("S"),"type")])),ArgumentsDeclaration([TypedId(Identifier("a"),SimpleType("T")),TypedId(Identifier("b"),SimpleType("S"))]),SimpleType("void")))])
Index: branches/scool-ng/tests/function/scool_ast/declaration_008.aterm
===================================================================
--- branches/scool-ng/tests/function/scool_ast/declaration_008.aterm (revision 0)
+++ branches/scool-ng/tests/function/scool_ast/declaration_008.aterm (revision 83)
@@ -0,0 +1 @@
+Program([FunctionDeclaration(None,Identifier("foo"),FunctionType(Some(ParametersDeclaration([TypedId(Identifier("B"),SimpleType("bool"))])),ArgumentsDeclaration([]),SimpleType("void")))])
Index: branches/scool-ng/tests/function/scool_src/declaration_005.scl
===================================================================
--- branches/scool-ng/tests/function/scool_src/declaration_005.scl (revision 0)
+++ branches/scool-ng/tests/function/scool_src/declaration_005.scl (revision 83)
@@ -0,0 +1 @@
+foo : [T : type] () -> void;
Index: branches/scool-ng/tests/function/scool_src/declaration_006.scl
===================================================================
--- branches/scool-ng/tests/function/scool_src/declaration_006.scl (revision 0)
+++ branches/scool-ng/tests/function/scool_src/declaration_006.scl (revision 83)
@@ -0,0 +1 @@
+foo : [T : type] (a : T) -> void;
Index: branches/scool-ng/tests/function/scool_src/declaration_007.scl
===================================================================
--- branches/scool-ng/tests/function/scool_src/declaration_007.scl (revision 0)
+++ branches/scool-ng/tests/function/scool_src/declaration_007.scl (revision 83)
@@ -0,0 +1 @@
+foo : [T : type, S : type] (a : T, b : S) -> void;
Index: branches/scool-ng/tests/function/scool_src/declaration_008.scl
===================================================================
--- branches/scool-ng/tests/function/scool_src/declaration_008.scl (revision 0)
+++ branches/scool-ng/tests/function/scool_src/declaration_008.scl (revision 83)
@@ -0,0 +1 @@
+foo : [B : bool] () -> void;
--
\__/ \__/
(00) Maxime `yabo` van Noppen (00)
___) \ Epita 2009 / (___
(_____/ \_____)
1
0
16 Sep '08
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008
ChangeLog:
2008-09-16 Guillaume Lazzara <z(a)lrde.epita.fr>
Fix various test related files (again).
* milena/tests/convert/to_image.cc,
* milena/tests/convert/to_window.cc,
* milena/tests/histo/compute.cc,
* milena/tests/histo/to_image1d.cc,
* milena/tests/morpho/hit_or_miss.cc,
* milena/tests/morpho/thinning.cc,
* milena/tests/set/inter.cc,
* milena/tests/set/is_subset_of.cc,
* milena/tests/set/sym_diff.cc,
* milena/tests/set/uni.cc: Make the test compile.
* milena/mln/fun/x2x/rotation.hh,
* milena/mln/set/diff.hh,
* milena/mln/labeling/regional_minima.hh,
* milena/mln/border/resize.hh,
* milena/mln/level/fill.hh,
* milena/mln/level/fill_with_image.hh,
* milena/mln/level/fill_with_value.hh:
Avoid compilation warning when compiled with -DNDEBUG.
* milena/mln/convert/to_p_array.hh: Add a missing exact().
* milena/mln/set/inter.hh,
* milena/mln/convert/to_image.hh,
* milena/mln/convert/to_p_set.hh,
* milena/mln/convert/to_std_set.hh,
* milena/mln/convert/to_window.hh: Rename mln_point.
* milena/mln/core/alias/box1d.hh: Add full namespace name.
* milena/mln/draw/label.hh: Use sub_image instead of image_if_value.
* milena/mln/level/transform.spe.hh,
* milena/mln/level/median.hh: use values_eligible() instead of values().
* milena/mln/morpho/Rd.hh: Use greater_point instead of operator<.
* milena/mln/morpho/erosion.spe.hh: Add a missing include.
* milena/tests/morpho/Makefile.am: Disable graph related tests.
---
mln/border/resize.hh | 10 +++++++
mln/convert/to_image.hh | 6 ++--
mln/convert/to_p_array.hh | 5 ++-
mln/convert/to_p_set.hh | 30 ++++++++++++++-------
mln/convert/to_std_set.hh | 2 -
mln/convert/to_window.hh | 24 ++++++++---------
mln/core/alias/box1d.hh | 2 -
mln/draw/label.hh | 7 ++---
mln/fun/x2x/rotation.hh | 5 +++
mln/labeling/regional_minima.hh | 13 +++++++--
mln/level/fill.hh | 4 ++
mln/level/fill_with_image.hh | 5 +++
mln/level/fill_with_value.hh | 4 ++
mln/level/median.hh | 4 +-
mln/level/transform.spe.hh | 2 -
mln/morpho/Rd.hh | 5 ++-
mln/morpho/erosion.spe.hh | 1
mln/set/diff.hh | 11 +++++---
mln/set/inter.hh | 16 +++++------
tests/convert/to_image.cc | 1
tests/convert/to_window.cc | 14 +++++-----
tests/histo/compute.cc | 2 -
tests/histo/to_image1d.cc | 2 -
tests/morpho/Makefile.am | 4 +-
tests/morpho/hit_or_miss.cc | 2 +
tests/morpho/thinning.cc | 2 +
tests/set/inter.cc | 55 ++++++++++++++++++----------------------
tests/set/is_subset_of.cc | 41 +++++++++++++----------------
tests/set/sym_diff.cc | 48 ++++++++++++++++------------------
tests/set/uni.cc | 48 ++++++++++++++++------------------
30 files changed, 210 insertions(+), 165 deletions(-)
Index: branches/cleanup-2008/milena/tests/histo/compute.cc
===================================================================
--- branches/cleanup-2008/milena/tests/histo/compute.cc (revision 2279)
+++ branches/cleanup-2008/milena/tests/histo/compute.cc (revision 2280)
@@ -50,7 +50,7 @@
// Test on 'bool'.
{
- accu::histo< value::set<bool> > h;
+ accu::histo<bool> h;
for (unsigned i = 0; i < 5; ++i)
h.take(false);
Index: branches/cleanup-2008/milena/tests/histo/to_image1d.cc
===================================================================
--- branches/cleanup-2008/milena/tests/histo/to_image1d.cc (revision 2279)
+++ branches/cleanup-2008/milena/tests/histo/to_image1d.cc (revision 2280)
@@ -51,7 +51,7 @@
using value::int_u8;
{
- accu::histo< value::set<bool> > h;
+ accu::histo<bool> h;
for (unsigned i = 0; i < 5; ++i)
h.take(false);
Index: branches/cleanup-2008/milena/tests/convert/to_image.cc
===================================================================
--- branches/cleanup-2008/milena/tests/convert/to_image.cc (revision 2279)
+++ branches/cleanup-2008/milena/tests/convert/to_image.cc (revision 2280)
@@ -37,6 +37,7 @@
#include <mln/level/compare.hh>
#include <mln/convert/to_image.hh>
+#include <mln/convert/to.hh>
#include <mln/debug/println.hh>
Index: branches/cleanup-2008/milena/tests/convert/to_window.cc
===================================================================
--- branches/cleanup-2008/milena/tests/convert/to_window.cc (revision 2279)
+++ branches/cleanup-2008/milena/tests/convert/to_window.cc (revision 2280)
@@ -61,7 +61,10 @@
d(0,-1);
window2d ref;
- ref.insert(a).insert(b).insert(c).insert(d);
+ ref.insert(a);
+ ref.insert(b);
+ ref.insert(c);
+ ref.insert(d);
// Reference constructed.
// Nbh :
@@ -78,11 +81,10 @@
// Window :
p_set<point2d> setp;
- setp
- .insert(point2d::origin + a)
- .insert(point2d::origin + b)
- .insert(point2d::origin + c)
- .insert(point2d::origin + d);
+ setp.insert(point2d::origin + a);
+ setp.insert(point2d::origin + b);
+ setp.insert(point2d::origin + c);
+ setp.insert(point2d::origin + d);
window2d test_setp = convert::to_window(setp);
test(ref, test_setp);
Index: branches/cleanup-2008/milena/tests/set/uni.cc
===================================================================
--- branches/cleanup-2008/milena/tests/set/uni.cc (revision 2279)
+++ branches/cleanup-2008/milena/tests/set/uni.cc (revision 2280)
@@ -39,20 +39,18 @@
{
window<dpoint2d> win1;
- win1
- .insert( 2, 7)
- .insert( 2, 1)
- .insert(-4, 0)
- .insert( 0, 0)
- .insert( 1, 1)
- .insert( 6, 5);
+ win1.insert( 2, 7);
+ win1.insert( 2, 1);
+ win1.insert(-4, 0);
+ win1.insert( 0, 0);
+ win1.insert( 1, 1);
+ win1.insert( 6, 5);
window<dpoint2d> win2;
- win2
- .insert( 2, 7)
- .insert(-2, 1)
- .insert(-4, 0)
- .insert( 1,-1)
- .insert( 6, 5);
+ win2.insert( 2, 7);
+ win2.insert(-2, 1);
+ win2.insert(-4, 0);
+ win2.insert( 1,-1);
+ win2.insert( 6, 5);
window<dpoint2d> win3 = set::uni(win1, win2);
mln_assertion(win3.has(dpoint2d( 2, 1)));
mln_assertion(win3.has(dpoint2d( 0, 0)));
@@ -66,20 +64,18 @@
{
p_set<point2d> pst1;
- pst1
- .insert(point2d( 2, 7))
- .insert(point2d( 2, 1))
- .insert(point2d(-4, 0))
- .insert(point2d( 0, 0))
- .insert(point2d( 1, 1))
- .insert(point2d( 6, 5));
+ pst1.insert(point2d( 2, 7));
+ pst1.insert(point2d( 2, 1));
+ pst1.insert(point2d(-4, 0));
+ pst1.insert(point2d( 0, 0));
+ pst1.insert(point2d( 1, 1));
+ pst1.insert(point2d( 6, 5));
p_set<point2d> pst2;
- pst2
- .insert(point2d( 2, 7))
- .insert(point2d(-2, 1))
- .insert(point2d(-4, 0))
- .insert(point2d( 1,-1))
- .insert(point2d( 6, 5));
+ pst2.insert(point2d( 2, 7));
+ pst2.insert(point2d(-2, 1));
+ pst2.insert(point2d(-4, 0));
+ pst2.insert(point2d( 1,-1));
+ pst2.insert(point2d( 6, 5));
p_set<point2d> pst3 = set::uni(pst1, pst2);
mln_assertion(pst3.has(point2d( 2, 1)));
mln_assertion(pst3.has(point2d( 0, 0)));
Index: branches/cleanup-2008/milena/tests/set/sym_diff.cc
===================================================================
--- branches/cleanup-2008/milena/tests/set/sym_diff.cc (revision 2279)
+++ branches/cleanup-2008/milena/tests/set/sym_diff.cc (revision 2280)
@@ -39,20 +39,18 @@
{
window<dpoint2d> win1;
- win1
- .insert( 2, 7)
- .insert( 2, 1)
- .insert(-4, 0)
- .insert( 0, 0)
- .insert( 1, 1)
- .insert( 6, 5);
+ win1.insert( 2, 7);
+ win1.insert( 2, 1);
+ win1.insert(-4, 0);
+ win1.insert( 0, 0);
+ win1.insert( 1, 1);
+ win1.insert( 6, 5);
window<dpoint2d> win2;
- win2
- .insert( 2, 7)
- .insert(-2, 1)
- .insert(-4, 0)
- .insert( 1,-1)
- .insert( 6, 5);
+ win2.insert( 2, 7);
+ win2.insert(-2, 1);
+ win2.insert(-4, 0);
+ win2.insert( 1,-1);
+ win2.insert( 6, 5);
window<dpoint2d> win3 = set::sym_diff(win1, win2);
mln_assertion(win3.has(dpoint2d( 2, 1)));
mln_assertion(win3.has(dpoint2d( 0, 0)));
@@ -66,20 +64,18 @@
{
p_set<point2d> pst1;
- pst1
- .insert(point2d( 2, 7))
- .insert(point2d( 2, 1))
- .insert(point2d(-4, 0))
- .insert(point2d( 0, 0))
- .insert(point2d( 1, 1))
- .insert(point2d( 6, 5));
+ pst1.insert(point2d( 2, 7));
+ pst1.insert(point2d( 2, 1));
+ pst1.insert(point2d(-4, 0));
+ pst1.insert(point2d( 0, 0));
+ pst1.insert(point2d( 1, 1));
+ pst1.insert(point2d( 6, 5));
p_set<point2d> pst2;
- pst2
- .insert(point2d( 2, 7))
- .insert(point2d(-2, 1))
- .insert(point2d(-4, 0))
- .insert(point2d( 1,-1))
- .insert(point2d( 6, 5));
+ pst2.insert(point2d( 2, 7));
+ pst2.insert(point2d(-2, 1));
+ pst2.insert(point2d(-4, 0));
+ pst2.insert(point2d( 1,-1));
+ pst2.insert(point2d( 6, 5));;
p_set<point2d> pst3 = set::sym_diff(pst1, pst2);
mln_assertion(pst3.has(point2d( 2, 1)));
mln_assertion(pst3.has(point2d( 0, 0)));
Index: branches/cleanup-2008/milena/tests/set/inter.cc
===================================================================
--- branches/cleanup-2008/milena/tests/set/inter.cc (revision 2279)
+++ branches/cleanup-2008/milena/tests/set/inter.cc (revision 2280)
@@ -32,6 +32,7 @@
#include <mln/set/inter.hh>
#include <mln/core/alias/dpoint2d.hh>
+#include <mln/core/alias/window2d.hh>
int main()
@@ -39,22 +40,20 @@
using namespace mln;
{
- window<dpoint2d> win1;
- win1
- .insert( 2, 7)
- .insert( 2, 1)
- .insert(-4, 0)
- .insert( 0, 0)
- .insert( 1, 1)
- .insert( 6, 5);
- window<dpoint2d> win2;
- win2
- .insert( 2, 7)
- .insert(-2, 1)
- .insert(-4, 0)
- .insert( 1,-1)
- .insert( 6, 5);
- window<dpoint2d> win3 = set::inter(win1, win2);
+ window2d win1;
+ win1.insert( 2, 7);
+ win1.insert( 2, 1);
+ win1.insert(-4, 0);
+ win1.insert( 0, 0);
+ win1.insert( 1, 1);
+ win1.insert( 6, 5);
+ window2d win2;
+ win2.insert( 2, 7);
+ win2.insert(-2, 1);
+ win2.insert(-4, 0);
+ win2.insert( 1,-1);
+ win2.insert( 6, 5);
+ window2d win3 = set::inter(win1, win2);
mln_assertion(!win3.has(dpoint2d( 2, 1)));
mln_assertion(!win3.has(dpoint2d( 0, 0)));
mln_assertion(!win3.has(dpoint2d( 1, 1)));
@@ -67,20 +66,18 @@
{
p_set<point2d> pst1;
- pst1
- .insert(point2d( 2, 7))
- .insert(point2d( 2, 1))
- .insert(point2d(-4, 0))
- .insert(point2d( 0, 0))
- .insert(point2d( 1, 1))
- .insert(point2d( 6, 5));
+ pst1.insert(point2d( 2, 7));
+ pst1.insert(point2d( 2, 1));
+ pst1.insert(point2d(-4, 0));
+ pst1.insert(point2d( 0, 0));
+ pst1.insert(point2d( 1, 1));
+ pst1.insert(point2d( 6, 5));
p_set<point2d> pst2;
- pst2
- .insert(point2d( 2, 7))
- .insert(point2d(-2, 1))
- .insert(point2d(-4, 0))
- .insert(point2d( 1,-1))
- .insert(point2d( 6, 5));
+ pst2.insert(point2d( 2, 7));
+ pst2.insert(point2d(-2, 1));
+ pst2.insert(point2d(-4, 0));
+ pst2.insert(point2d( 1,-1));
+ pst2.insert(point2d( 6, 5));
p_set<point2d> pst3 = set::inter(pst1, pst2);
mln_assertion(!pst3.has(point2d( 2, 1)));
mln_assertion(!pst3.has(point2d( 0, 0)));
Index: branches/cleanup-2008/milena/tests/set/is_subset_of.cc
===================================================================
--- branches/cleanup-2008/milena/tests/set/is_subset_of.cc (revision 2279)
+++ branches/cleanup-2008/milena/tests/set/is_subset_of.cc (revision 2280)
@@ -43,28 +43,25 @@
p_set<point2d> pst2;
p_set<point2d> pst3;
p_set<point2d> pst4;
- pst1
- .insert(point2d( 2, 7))
- .insert(point2d( 2, 1))
- .insert(point2d(-4, 0))
- .insert(point2d( 0, 0))
- .insert(point2d( 1, 1))
- .insert(point2d( 6, 5));
- pst2
- .insert(point2d( 2, 7))
- .insert(point2d(-2, 1))
- .insert(point2d(-4, 0))
- .insert(point2d( 1,-1))
- .insert(point2d( 6, 5));
- pst3
- .insert(point2d( 2, 7))
- .insert(point2d( 2, 1))
- .insert(point2d(-4, 0))
- .insert(point2d( 0, 0))
- .insert(point2d( 1, 1))
- .insert(point2d( 6, 5))
- .insert(point2d(-2, 1))
- .insert(point2d( 1,-1));
+ pst1.insert(point2d( 2, 7));
+ pst1.insert(point2d( 2, 1));
+ pst1.insert(point2d(-4, 0));
+ pst1.insert(point2d( 0, 0));
+ pst1.insert(point2d( 1, 1));
+ pst1.insert(point2d( 6, 5));
+ pst2.insert(point2d( 2, 7));
+ pst2.insert(point2d(-2, 1));
+ pst2.insert(point2d(-4, 0));
+ pst2.insert(point2d( 1,-1));
+ pst2.insert(point2d( 6, 5));
+ pst3.insert(point2d( 2, 7));
+ pst3.insert(point2d( 2, 1));
+ pst3.insert(point2d(-4, 0));
+ pst3.insert(point2d( 0, 0));
+ pst3.insert(point2d( 1, 1));
+ pst3.insert(point2d( 6, 5));
+ pst3.insert(point2d(-2, 1));
+ pst3.insert(point2d( 1,-1));
mln_assertion(set::is_subset_of(pst1, pst3));
mln_assertion(set::is_subset_of(pst2, pst3));
Index: branches/cleanup-2008/milena/tests/morpho/thinning.cc
===================================================================
--- branches/cleanup-2008/milena/tests/morpho/thinning.cc (revision 2279)
+++ branches/cleanup-2008/milena/tests/morpho/thinning.cc (revision 2280)
@@ -43,6 +43,8 @@
#include <mln/morpho/thinning.hh>
+#include<mln/convert/to.hh>
+
#include "tests/data.hh"
Index: branches/cleanup-2008/milena/tests/morpho/hit_or_miss.cc
===================================================================
--- branches/cleanup-2008/milena/tests/morpho/hit_or_miss.cc (revision 2279)
+++ branches/cleanup-2008/milena/tests/morpho/hit_or_miss.cc (revision 2280)
@@ -44,6 +44,8 @@
#include <mln/morpho/hit_or_miss.hh>
+# include <mln/convert/to.hh>
+
#include "tests/data.hh"
Index: branches/cleanup-2008/milena/tests/morpho/Makefile.am
===================================================================
--- branches/cleanup-2008/milena/tests/morpho/Makefile.am (revision 2279)
+++ branches/cleanup-2008/milena/tests/morpho/Makefile.am (revision 2280)
@@ -17,9 +17,9 @@
gradient_elementary \
hit_or_miss \
laplacian \
- lena_line_graph_image_wst1 \
+## lena_line_graph_image_wst1 \
lena_line_graph_image_wst2 \
- line_graph_image_wst \
+## line_graph_image_wst \
meyer_wst \
meyer_wst_long \
opening_area \
Index: branches/cleanup-2008/milena/mln/core/alias/box1d.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/alias/box1d.hh (revision 2279)
+++ branches/cleanup-2008/milena/mln/core/alias/box1d.hh (revision 2280)
@@ -46,7 +46,7 @@
*
* \see mln::win::rectangle1d.
*/
- typedef box<point1d> box1d;
+ typedef box<mln::point1d> box1d;
} // end of namespace mln
Index: branches/cleanup-2008/milena/mln/draw/label.hh
===================================================================
--- branches/cleanup-2008/milena/mln/draw/label.hh (revision 2279)
+++ branches/cleanup-2008/milena/mln/draw/label.hh (revision 2280)
@@ -39,13 +39,12 @@
# include <mln/pw/cst.hh>
# include <mln/trait/image_from_mesh.hh>
-# include <mln/core/image_if_value.hh>
+# include <mln/core/image/sub_image.hh>
# include <mln/value/rgb8.hh>
# include <mln/level/fill.hh>
# include <mln/level/paste.hh>
# include <mln/core/site_set/p_set.hh>
# include <mln/metal/is_not.hh>
-# include <mln/core/image_if_value.hh>
# include <mln/debug/println.hh>
namespace mln
@@ -77,7 +76,7 @@
{
typedef mln_value(I) V;
typedef mln_ch_value(I, value::rgb8) O;
- typedef const mln::p_if<mln_pset(I), mln::fun::eq_p2b_expr_<mln::pw::value_<I>, mln::pw::cst_<V> > > F;
+ typedef sub_image<I,V> F;
I in = exact(input);
mln_precondition(in.has_data());
@@ -102,7 +101,7 @@
break;
}
V val = ref(p);
- image_if_value<I> ima_if = ref | val;
+ F ima_if = ref | val;
mln_piter(F) l (ima_if.domain());
for_all (l)
out(l) = color;
Index: branches/cleanup-2008/milena/mln/level/fill_with_image.hh
===================================================================
--- branches/cleanup-2008/milena/mln/level/fill_with_image.hh (revision 2279)
+++ branches/cleanup-2008/milena/mln/level/fill_with_image.hh (revision 2280)
@@ -72,6 +72,11 @@
inline
void fill_with_image_tests(Image<I>& ima, const Image<J>& data)
{
+ // Avoid a warning about an undefined variable when NDEBUG
+ // is not defined.
+ (void)ima;
+ (void)data;
+
mlc_is(mln_trait_image_value_io(I),
mln::trait::image::value_io::read_write)::check();
mlc_converts_to(mln_value(J), mln_value(I))::check();
Index: branches/cleanup-2008/milena/mln/level/fill.hh
===================================================================
--- branches/cleanup-2008/milena/mln/level/fill.hh (revision 2279)
+++ branches/cleanup-2008/milena/mln/level/fill.hh (revision 2280)
@@ -72,6 +72,10 @@
inline
void fill_tests(Image<I>& ima, const D&)
{
+ // Avoid a warning about an undefined variable when NDEBUG
+ // is not defined.
+ (void) ima;
+
mlc_is(mln_trait_image_value_io(I), trait::image::value_io::read_write)::check();
mln_precondition(exact(ima).has_data());
// FIXME: check for ambiguities...
Index: branches/cleanup-2008/milena/mln/level/median.hh
===================================================================
--- branches/cleanup-2008/milena/mln/level/median.hh (revision 2279)
+++ branches/cleanup-2008/milena/mln/level/median.hh (revision 2280)
@@ -123,7 +123,7 @@
win(exact(win_)),
output(exact(output_)),
// aux data
- med(input.values()),
+ med(input.values_eligible()),
p(),
win_fp(set::diff(win, geom::shift(win, left))),
win_fm(set::diff(geom::shift(win, left), win)),
@@ -208,7 +208,7 @@
output(exact(output)),
// aux data
p(),
- med(input.values())
+ med(input.values_eligible())
{
}
Index: branches/cleanup-2008/milena/mln/level/transform.spe.hh
===================================================================
--- branches/cleanup-2008/milena/mln/level/transform.spe.hh (revision 2279)
+++ branches/cleanup-2008/milena/mln/level/transform.spe.hh (revision 2280)
@@ -85,7 +85,7 @@
const F& f = exact(f_);
O& output = exact(output_);
- value::lut_vec<mln_vset(I), mln_result(F)> lut(input.values(), f);
+ value::lut_vec<mln_vset(I), mln_result(F)> lut(input.values_eligible(), f);
mln_piter(I) p(input.domain());
for_all(p)
output(p) = lut(input(p));
Index: branches/cleanup-2008/milena/mln/level/fill_with_value.hh
===================================================================
--- branches/cleanup-2008/milena/mln/level/fill_with_value.hh (revision 2279)
+++ branches/cleanup-2008/milena/mln/level/fill_with_value.hh (revision 2280)
@@ -83,6 +83,10 @@
inline
void fill_with_value_tests(Image<I>& ima, const V&)
{
+ // Avoid a warning about an undefined variable when NDEBUG
+ // is not defined.
+ (void) ima;
+
mlc_is(mln_trait_image_value_io(I),
mln::trait::image::value_io::read_write)::check();
mlc_converts_to(mln_exact(V), mln_value(I))::check();
Index: branches/cleanup-2008/milena/mln/border/resize.hh
===================================================================
--- branches/cleanup-2008/milena/mln/border/resize.hh (revision 2279)
+++ branches/cleanup-2008/milena/mln/border/resize.hh (revision 2280)
@@ -113,6 +113,11 @@
void resize_(trait::image::ext_domain::none,
const I& ima, unsigned thickness)
{
+ // Avoid a warning about an undefined variable when NDEBUG
+ // is not defined.
+ (void) ima;
+ (void) thickness;
+
// No-op.
}
@@ -121,6 +126,11 @@
void resize_(trait::image::ext_domain::fixed,
const I& ima, unsigned thickness)
{
+ // Avoid a warning about an undefined variable when NDEBUG
+ // is not defined.
+ (void) ima;
+ (void) thickness;
+
// No-op.
}
Index: branches/cleanup-2008/milena/mln/convert/to_image.hh
===================================================================
--- branches/cleanup-2008/milena/mln/convert/to_image.hh (revision 2279)
+++ branches/cleanup-2008/milena/mln/convert/to_image.hh (revision 2280)
@@ -66,7 +66,7 @@
template <typename T>
struct helper_dim_
{
- typedef mln_site(T) P;
+ typedef mln_psite(T) P;
enum { value = P::dim };
};
@@ -152,7 +152,7 @@
const W& win = exact(win_);
mln_precondition(! win.is_empty());
- typedef mln_site(W) P;
+ typedef mln_psite(W) P;
box<P> b = geom::bbox(win);
mln_image_from(W, bool) ima(b);
level::fill(ima, false);
@@ -176,7 +176,7 @@
const W& w_win = exact(w_win_);
mln_precondition(! w_win.is_empty());
- typedef mln_site(W) P;
+ typedef mln_psite(W) P;
box<P> b = geom::bbox(w_win);
mln_image_from(W, mln_weight(W)) ima(b);
// Fill the image with zeros, as (weighted) windows are not
Index: branches/cleanup-2008/milena/mln/convert/to_std_set.hh
===================================================================
--- branches/cleanup-2008/milena/mln/convert/to_std_set.hh (revision 2279)
+++ branches/cleanup-2008/milena/mln/convert/to_std_set.hh (revision 2280)
@@ -61,7 +61,7 @@
std::set<mln_dpsite(W)> to_std_set(const Window<W>& win)
{
typedef mln_dpsite(W) D;
- typedef mln_point(D) P;
+ typedef mln_psite(D) P;
std::set<D> s;
mln_qiter(W) q(exact(win), P::origin);
for_all(q)
Index: branches/cleanup-2008/milena/mln/convert/to_window.hh
===================================================================
--- branches/cleanup-2008/milena/mln/convert/to_window.hh (revision 2279)
+++ branches/cleanup-2008/milena/mln/convert/to_window.hh (revision 2280)
@@ -59,7 +59,7 @@
// Default case.
template <typename N>
struct nbh_to_win_trait
- { typedef window<mln_dpoint(N)> ret; };
+ { typedef window<mln_dpsite(N)> ret; };
// Case of line_graph_elt_neighborhood<P>.
template <typename P>
@@ -75,11 +75,11 @@
template <typename I>
window<mln_dpsite(I)> to_window(const Image<I>& ima);
- /// Convert a point set \p pset into a window.
+ /// Convert a site set \p pset into a window.
template <typename S>
- window<mln_dpoint(S)> to_window(const Site_Set<S>& pset);
+ window<mln_dpsite(S)> to_window(const Site_Set<S>& pset);
- /// Convert an std::set \p s of delta-points into a window.
+ /// Convert an std::set \p s of delta-sites into a window.
template <typename D>
window<D> to_window(const std::set<D>& s);
@@ -95,11 +95,11 @@
template <typename N>
inline
- window<mln_dpoint(N)> to_window(const N& nbh_)
+ window<mln_dpsite(N)> to_window(const N& nbh_)
{
const N& nbh = exact(nbh_);
- typedef mln_dpoint(N) D;
- typedef mln_point(D) P;
+ typedef mln_dpsite(N) D;
+ typedef mln_psite(D) P;
window<D> win;
mln_niter(N) n(nbh, P::origin);
for_all(n)
@@ -131,9 +131,9 @@
`------------------------------*/
/* FIXME: According to milena/core/concepts/README, windows are
- not necessarily based on a set of dpoints. So the current
- algorithm won't work on non dpoint-set-based windows. In the
- general case (of windows not being a set of dpoints), the
+ not necessarily based on a set of dpsites. So the current
+ algorithm won't work on non dpsite-set-based windows. In the
+ general case (of windows not being a set of dpsites), the
window resulting from this conversion (as well as the iterators
based on such windows!) should depend on the initial
neighborhood (i.e., delegate the actual iteration to the
@@ -147,7 +147,7 @@
mln_precondition(ima.has_data());
// FIXME: Check that ima is binary!
typedef mln_dpsite(I) D;
- typedef mln_point(D) P;
+ typedef mln_psite(D) P;
window<D> win;
mln_piter(I) p(ima.domain());
for_all(p)
@@ -162,7 +162,7 @@
template <typename S>
inline
- window<mln_dpoint(S)> to_window(const Site_Set<S>& pset)
+ window<mln_dpsite(S)> to_window(const Site_Set<S>& pset)
{
return to_window(pw::cst(true) | pset);
}
Index: branches/cleanup-2008/milena/mln/convert/to_p_set.hh
===================================================================
--- branches/cleanup-2008/milena/mln/convert/to_p_set.hh (revision 2279)
+++ branches/cleanup-2008/milena/mln/convert/to_p_set.hh (revision 2280)
@@ -53,30 +53,36 @@
/// Convert a neighborhood \p nbh into a point set.
template <typename N>
- p_set<mln_point(N)> to_p_set(const Neighborhood<N>& nbh);
+ p_set<mln_psite(N)>
+ to_p_set(const Neighborhood<N>& nbh);
/// Convert a binary image \p ima into a point set.
template <typename I>
- p_set<mln_psite(I)> to_p_set(const Image<I>& ima);
+ p_set<mln_psite(I)>
+ to_p_set(const Image<I>& ima);
/// Convert a Window \p win into a point set.
template <typename W>
- p_set<mln_site(W)> to_p_set(const Window<W>& win);
+ p_set<mln_psite(W)>
+ to_p_set(const Window<W>& win);
/// Convert an std::set \p s of points into a point set.
template <typename P>
- p_set<P> to_p_set(const std::set<P>& s);
+ p_set<P>
+ to_p_set(const std::set<P>& s);
/// Convert any point set \p ps into a 'mln::p_set' point set.
template <typename S>
- p_set<mln_psite(S)> to_p_set(const Site_Set<S>& ps);
+ p_set<mln_psite(S)>
+ to_p_set(const Site_Set<S>& ps);
# ifndef MLN_INCLUDE_ONLY
template <typename N>
inline
- p_set<mln_point(N)> to_p_set(const Neighborhood<N>& nbh_)
+ p_set<mln_point(N)>
+ to_p_set(const Neighborhood<N>& nbh_)
{
const N& nbh = exact(nbh_);
typedef mln_dpoint(N) D;
@@ -90,7 +96,8 @@
template <typename I>
inline
- p_set<mln_psite(I)> to_p_set(const Image<I>& ima_)
+ p_set<mln_psite(I)>
+ to_p_set(const Image<I>& ima_)
{
const I& ima = exact(ima_);
mln_precondition(ima.has_data());
@@ -110,7 +117,8 @@
template <typename W>
inline
- p_set<mln_site(W)> to_p_set(const Window<W>& win)
+ p_set<mln_site(W)>
+ to_p_set(const Window<W>& win)
{
typedef mln_site(W) P;
p_set<P> pset;
@@ -122,7 +130,8 @@
template <typename P>
inline
- p_set<P> to_p_set(const std::set<P>& s)
+ p_set<P>
+ to_p_set(const std::set<P>& s)
{
mln::metal::is_a<P, Point_Site>::check();
p_set<P> pset;
@@ -134,7 +143,8 @@
template <typename S>
inline
- p_set<mln_psite(S)> to_p_set(const Site_Set<S>& ps_)
+ p_set<mln_psite(S)>
+ to_p_set(const Site_Set<S>& ps_)
{
const S& ps = exact(ps_);
p_set<mln_psite(S)> tmp;
Index: branches/cleanup-2008/milena/mln/convert/to_p_array.hh
===================================================================
--- branches/cleanup-2008/milena/mln/convert/to_p_array.hh (revision 2279)
+++ branches/cleanup-2008/milena/mln/convert/to_p_array.hh (revision 2280)
@@ -78,11 +78,12 @@
template <typename W>
inline
- p_array<mln_psite(W)> to_p_array(const Window<W>& win,
+ p_array<mln_psite(W)> to_p_array(const Window<W>& win_,
const mln_psite(W)& p)
{
+ const W& win = exact(win_);
p_array<mln_psite(W)> v;
- v.reserve(exact(win).size());
+ v.reserve(win.size());
mln_qiter(W) q(win, p);
for_all(q)
v.append(q);
Index: branches/cleanup-2008/milena/mln/fun/x2x/rotation.hh
===================================================================
--- branches/cleanup-2008/milena/mln/fun/x2x/rotation.hh (revision 2279)
+++ branches/cleanup-2008/milena/mln/fun/x2x/rotation.hh (revision 2280)
@@ -100,6 +100,11 @@
algebra::h_mat<2, C>
get_rot_h_mat(const float alpha_, const algebra::vec<2,C>& axis_)
{
+ // Avoid a warning about an undefined variable when NDEBUG
+ // is not defined.
+ (void) alpha_;
+ (void) axis_;
+
assert(!"not implemented yet");
}
}
Index: branches/cleanup-2008/milena/mln/set/inter.hh
===================================================================
--- branches/cleanup-2008/milena/mln/set/inter.hh (revision 2279)
+++ branches/cleanup-2008/milena/mln/set/inter.hh (revision 2280)
@@ -52,7 +52,7 @@
* \relates mln::Window
*/
template <typename Wl, typename Wr>
- window<mln_dpoint(Wl)>
+ window<mln_dpsite(Wl)>
inter(const Window<Wl>& lhs, const Window<Wr>& rhs);
/*! \brief Intersection between a couple of point sets.
@@ -60,19 +60,19 @@
* \relates mln::Site_Set
*/
template <typename Wl, typename Wr>
- p_set<mln_point(Wl)>
+ p_set<mln_psite(Wl)>
inter(const Site_Set<Wl>& lhs, const Site_Set<Wr>& rhs);
# ifndef MLN_INCLUDE_ONLY
template <typename Wl, typename Wr>
inline
- window<mln_dpoint(Wl)>
+ window<mln_dpsite(Wl)>
inter(const Window<Wl>& lhs, const Window<Wr>& rhs)
{
trace::entering("set::inter");
- mln::metal::equal<mln_dpoint(Wl), mln_dpoint(Wr)>::check();
- typedef mln_dpoint(Wl) D;
+ mln::metal::equal<mln_dpsite(Wl), mln_dpsite(Wr)>::check();
+ typedef mln_dpsite(Wl) D;
std::set<D>
sl = convert::to_std_set(lhs),
sr = convert::to_std_set(rhs),
@@ -86,12 +86,12 @@
template <typename Wl, typename Wr>
inline
- p_set<mln_point(Wl)>
+ p_set<mln_psite(Wl)>
inter(const Site_Set<Wl>& lhs, const Site_Set<Wr>& rhs)
{
trace::entering("set::inter");
- mln::metal::equal<mln_point(Wl), mln_point(Wr)>::check();
- typedef mln_point(Wl) P;
+ mln::metal::equal<mln_psite(Wl), mln_psite(Wr)>::check();
+ typedef mln_psite(Wl) P;
std::set<P>
sl = convert::to_std_set(lhs),
sr = convert::to_std_set(rhs),
Index: branches/cleanup-2008/milena/mln/set/diff.hh
===================================================================
--- branches/cleanup-2008/milena/mln/set/diff.hh (revision 2279)
+++ branches/cleanup-2008/milena/mln/set/diff.hh (revision 2280)
@@ -62,7 +62,7 @@
* \relates mln::Site_Set
*/
template <typename Wl, typename Wr>
- p_set<mln_point(Wl)>
+ p_set<mln_psite(Wl)>
diff(const Site_Set<Wl>& lhs, const Site_Set<Wr>& rhs);
@@ -96,11 +96,16 @@
template <typename Wl, typename Wr>
inline
- p_set<mln_site(Wl)>
+ p_set<mln_psite(Wl)>
diff(const Site_Set<Wl>& lhs, const Site_Set<Wr>& rhs)
{
+ // Avoid a warning about an undefined variable when NDEBUG
+ // is not defined.
+ (void) lhs;
+ (void) rhs;
+
trace::entering("set::diff");
- p_set<mln_site(Wl)> s;
+ p_set<mln_psite(Wl)> s;
abort();
// mln::metal::equal<mln_point(Wl), mln_point(Wr)>::check();
// typedef mln_point(Wl) P;
Index: branches/cleanup-2008/milena/mln/morpho/erosion.spe.hh
===================================================================
--- branches/cleanup-2008/milena/mln/morpho/erosion.spe.hh (revision 2279)
+++ branches/cleanup-2008/milena/mln/morpho/erosion.spe.hh (revision 2280)
@@ -32,6 +32,7 @@
# error "Forbidden inclusion of *.spe.hh"
# endif // ! MLN_MORPHO_EROSION_HH
+# include <mln/core/alias/window2d.hh>
# include <mln/win/octagon2d.hh>
# include <mln/win/rectangle2d.hh>
# include <mln/geom/shift.hh>
Index: branches/cleanup-2008/milena/mln/morpho/Rd.hh
===================================================================
--- branches/cleanup-2008/milena/mln/morpho/Rd.hh (revision 2279)
+++ branches/cleanup-2008/milena/mln/morpho/Rd.hh (revision 2280)
@@ -47,7 +47,7 @@
# include <mln/level/fill.hh>
# include <mln/level/compare.hh>
-
+# include <mln/util/greater_point.hh>
namespace mln
{
@@ -161,7 +161,8 @@
inline
bool is_proc__(const point& n, const point& p) const
{
- return g(n) > g(p) || (g(n) == g(p) && n < p);
+ util::greater_point<I> greater_than(g);
+ return g(n) > g(p) || (g(n) == g(p) && greater_than(p,n));
}
inline
Index: branches/cleanup-2008/milena/mln/labeling/regional_minima.hh
===================================================================
--- branches/cleanup-2008/milena/mln/labeling/regional_minima.hh (revision 2279)
+++ branches/cleanup-2008/milena/mln/labeling/regional_minima.hh (revision 2280)
@@ -88,9 +88,16 @@
bool labels(const P& p) const { return attr(p); }
bool equiv(const P& n, const P& p) const { return input(n) ==
input(p); }
- void do_no_union(const P& n, const P& p) { mln_invariant(input(n) <
- input(p));
- attr(p) = false; }
+ void do_no_union(const P& n, const P& p)
+ {
+ // Avoid a warning about an undefined variable when NDEBUG
+ // is not defined.
+ (void)n;
+
+ mln_invariant(input(n) < input(p));
+ attr(p) = false;
+ }
+
void init_attr(const P&) {}
void merge_attr(const P& r, const P& p) { attr(p) = attr(p) &&
attr(r); }
1
0
16 Sep '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Augment the documentation example on a 2D complex.
* doc/examples/tuto_bis.cc: Re-activate the first two steps.
* mln/core/image/image_if.hh (operator|): New overloads.
It now works with C functions.
* mln/core/alias/window1d.hh,
* mln/core/alias/window2d.hh,
* mln/core/alias/window3d.hh,
* mln/core/neighb.hh,
* mln/make/dual_neighb2d.hh: Fix missing include.
We shall always first include from_to.hh in files that provide
some overloading of from_to_.
* mln/level/sort_psites.hh: Fix.
* mln/convert/to_p_array.hh (reserve): Deactivate cause nsites
is an optional method.
* mln/fun/c.hh (C_Function): New concept declaration.
(category): New specialization for C functions.
(set_unary_, set_binary_): New specializations for C functions.
(C): Fix missing default ctor.
* mln/morpho/meyer_wst.hh (nbh): Fix missing exact.
doc/examples/tuto_bis.cc | 180 +++++++++++++++++++++------------------------
mln/convert/to_p_array.hh | 2
mln/core/alias/window1d.hh | 1
mln/core/alias/window2d.hh | 1
mln/core/alias/window3d.hh | 1
mln/core/image/image_if.hh | 27 ++++++
mln/core/neighb.hh | 1
mln/fun/c.hh | 54 +++++++++++++
mln/level/sort_psites.hh | 4 -
mln/make/dual_neighb2d.hh | 1
mln/morpho/meyer_wst.hh | 3
11 files changed, 177 insertions(+), 98 deletions(-)
Index: doc/examples/tuto_bis.cc
--- doc/examples/tuto_bis.cc (revision 2278)
+++ doc/examples/tuto_bis.cc (working copy)
@@ -1,32 +1,32 @@
-# include <vector>
-
# include <mln/core/var.hh>
-# include <mln/core/alias/point2d.hh>
+# include <mln/core/image/image2d.hh>
+# include <mln/core/image/image_if.hh>
+# include <mln/core/routine/extend.hh>
+
# include <mln/core/alias/window2d.hh>
-# include <mln/make/win_multiple.hh>
-# include <mln/convert/to.hh>
# include <mln/make/dual_neighb2d.hh>
-# include <mln/literal/origin.hh>
-# include <mln/core/site_set/p_set.hh>
+
+# include <mln/debug/println.hh>
+# include <mln/fun/p2v/iota.hh>
+
+# include <mln/level/paste.hh>
+# include <mln/level/fill.hh>
+
+# include <mln/accu/min_max.hh>
+# include <mln/morpho/meyer_wst.hh>
/*
-# include <mln/core/image/image2d.hh>
+# include <vector>
+
# include <mln/core/image/sub_image.hh>
-# include <mln/core/image/image_if.hh>
# include <mln/core/alias/neighb2d.hh>
# include <mln/core/alias/window2d.hh>
# include <mln/convert/to_window.hh>
-# include <mln/debug/println.hh>
-# include <mln/fun/p2v/iota.hh>
-# include <mln/level/paste.hh>
-# include <mln/level/fill.hh>
-
# include <mln/morpho/dilation.hh>
-# include <mln/morpho/gradient.hh>
# include <mln/morpho/meyer_wst.hh>
# include <mln/level/transform.hh>
@@ -99,36 +99,6 @@
} // mln
-struct is_cell_t : mln::Function_p2b<is_cell_t>
-{
- typedef bool result;
- bool operator()(const mln::point2d& p) const
- {
- return p.row() % 2 == 0 && p.col() % 2 == 0;
- }
-}
- is_cell;
-
-struct is_edge_t : mln::Function_p2b<is_edge_t>
-{
- typedef bool result;
- bool operator()(const mln::point2d& p) const
- {
- return p.row() % 2 + p.col() % 2 == 1;
- }
-}
- is_edge;
-
-struct is_point_t : mln::Function_p2b<is_point_t>
-{
- typedef bool result;
- bool operator()(const mln::point2d& p) const
- {
- return p.row() % 2 && p.col() % 2;
- }
-}
- is_point;
-
*/
@@ -150,8 +120,6 @@
exact(s).insert(q);
}
-
-
template <typename N, typename S>
void convert_to_site_set(const Neighborhood<N>& nbh,
const mln_psite(N)& p,
@@ -165,15 +133,60 @@
exact(s).insert(n);
}
+
+ namespace morpho
+ {
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ gradient(const I& input, const N& nbh)
+ {
+ mln_concrete(I) output;
+ initialize(output, input);
+ accu::min_max_<mln_value(I)> mm;
+
+ mln_piter(I) p(input.domain());
+ mln_niter(N) n(nbh, p);
+ for_all(p)
+ {
+ mm.init();
+ for_all(n) if (input.has(n))
+ mm.take(input(n));
+ output(p) = mm.second() - mm.first();
+ }
+ return output;
}
+ } // mln::morpho
+
+
+} // mln
+
+
+// Functions
bool is_row_odd(const mln::point2d& p)
{
return p.row() % 2;
}
+bool is_cell(const mln::point2d& p)
+{
+ return p.row() % 2 == 0 && p.col() % 2 == 0;
+}
+
+bool is_edge(const mln::point2d& p)
+{
+ return p.row() % 2 + p.col() % 2 == 1;
+}
+
+bool is_point(const mln::point2d& p)
+{
+ return p.row() % 2 && p.col() % 2;
+}
+
+
int main()
@@ -192,10 +205,6 @@
mln_VAR( e2c, make::dual_neighb2d(is_row_odd, e2c_h, e2c_v) );
-// p_set<point2d> s;
-// convert_to_site_set(e2c, literal::origin, s);
-// std::cout << s << std::endl;
-
bool e2e_h[] = { 0, 0, 1, 0, 0,
0, 1, 0, 1, 0,
0, 0, 0, 0, 0,
@@ -211,44 +220,6 @@
mln_VAR( e2e, make::dual_neighb2d(is_row_odd, e2e_h, e2e_v) );
- /*
-
- window2d c4 = convert::to_window(mln::c4());
-
-
- dbl_neighb_<dpoint2d, is_row_odd_t> nbh_e2c, win_p_e2c, nbh_e2e;
- {
- bool e2c_h[] = { 0, 1, 0,
- 0, 0, 0,
- 0, 1, 0 };
-
- bool e2c_v[] = { 0, 0, 0,
- 1, 0, 1,
- 0, 0, 0 };
- nbh_e2c
- .when_true (make::neighb2d(e2c_h))
- .when_false(make::neighb2d(e2c_v));
-
- win_p_e2c = nbh_e2c;
- win_p_e2c
- .insert_true(dpoint2d(0,0))
- .insert_false(dpoint2d(0,0));
-
- bool e2e_h[] = { 0, 0, 1, 0, 0,
- 0, 1, 0, 1, 0,
- 0, 0, 0, 0, 0,
- 0, 1, 0, 1, 0,
- 0, 0, 1, 0, 0 };
-
- bool e2e_v[] = { 0, 0, 0, 0, 0,
- 0, 1, 0, 1, 0,
- 1, 0, 0, 0, 1,
- 0, 1, 0, 1, 0,
- 0, 0, 0, 0, 0 };
- nbh_e2e
- .when_true (make::neighb2d(e2e_h))
- .when_false(make::neighb2d(e2e_v));
- }
image2d<int> ima(3, 5);
@@ -260,15 +231,38 @@
//
// 4 5 6
- mln_VAR(edge, ima | is_edge);
- level::paste(morpho::gradient(edge, nbh_e2c), edge);
- // ^^^^^^^
- // edge -> neighbooring cells
+
+
+ mln_VAR(edge, extend(inplace(ima | is_edge),
+ pw::value(ima)));
+ level::paste(morpho::gradient(edge, e2c), edge);
+ // ^^^
+ // edge -> neighboring cells
debug::println(edge);
// 1 1
// 3 3 3
// 1 1
+
+ unsigned nbasins;
+ mln_VAR(wst, morpho::meyer_wst(edge, e2e, nbasins));
+ // ^^^
+ // edge -> neighboring edges
+ debug::println(wst);
+ // 2 2
+ // 0 0 0
+ // 1 1
+
+ std::cout << nbasins << " bassins" << std::endl;
+ // 2 bassins
+
+
+
+ /*
+
+ window2d c4 = convert::to_window(mln::c4());
+
+
unsigned nbasins;
mln_VAR(wst, morpho::meyer_wst(edge, nbh_e2e, nbasins));
// ^^^^^^^
Index: mln/core/image/image_if.hh
--- mln/core/image/image_if.hh (revision 2278)
+++ mln/core/image/image_if.hh (working copy)
@@ -39,6 +39,7 @@
# include <mln/core/internal/image_domain_morpher.hh>
# include <mln/core/site_set/p_if.hh>
# include <mln/pw/all.hh>
+# include <mln/convert/to_fun.hh>
namespace mln
@@ -149,6 +150,16 @@
+ template <typename I, typename A>
+ image_if< const I, fun::C<bool(*)(A)> >
+ operator | (const Image<I>& ima, bool (*f)(A) );
+
+ template <typename I, typename A>
+ image_if< I, fun::C<bool(*)(A)> >
+ operator | (Image<I>& ima, bool (*f)(A) );
+
+
+
# ifndef MLN_INCLUDE_ONLY
// internal::data< image_if<I,F> >
@@ -231,6 +242,22 @@
return tmp;
}
+
+ template <typename I, typename A>
+ image_if< const I, fun::C<bool(*)(A)> >
+ operator | (const Image<I>& ima, bool (*f)(A) )
+ {
+ return exact(ima) | convert::to_fun(f);
+ }
+
+ template <typename I, typename A>
+ image_if< I, fun::C<bool(*)(A)> >
+ operator | (Image<I>& ima, bool (*f)(A) )
+ {
+ return exact(ima) | convert::to_fun(f);
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
Index: mln/core/alias/window1d.hh
--- mln/core/alias/window1d.hh (revision 2278)
+++ mln/core/alias/window1d.hh (working copy)
@@ -34,6 +34,7 @@
# include <mln/core/window.hh>
# include <mln/core/alias/dpoint1d.hh>
+# include <mln/convert/from_to.hh>
namespace mln
Index: mln/core/alias/window2d.hh
--- mln/core/alias/window2d.hh (revision 2278)
+++ mln/core/alias/window2d.hh (working copy)
@@ -35,6 +35,7 @@
# include <mln/core/window.hh>
# include <mln/core/alias/dpoint2d.hh>
# include <mln/metal/math/sqrt.hh>
+# include <mln/convert/from_to.hh>
namespace mln
Index: mln/core/alias/window3d.hh
--- mln/core/alias/window3d.hh (revision 2278)
+++ mln/core/alias/window3d.hh (working copy)
@@ -35,6 +35,7 @@
# include <cmath>
# include <mln/core/window.hh>
# include <mln/core/alias/dpoint3d.hh>
+# include <mln/convert/from_to.hh>
namespace mln
Index: mln/core/neighb.hh
--- mln/core/neighb.hh (revision 2278)
+++ mln/core/neighb.hh (working copy)
@@ -34,6 +34,7 @@
*/
# include <mln/core/internal/neighborhood_base.hh>
+# include <mln/convert/from_to.hh>
Index: mln/level/sort_psites.hh
--- mln/level/sort_psites.hh (revision 2278)
+++ mln/level/sort_psites.hh (working copy)
@@ -124,7 +124,7 @@
const I& input)
{
p_array<mln_psite(I)> v = convert::to_p_array(input.domain());
- std::sort(v.hook_().begin(), v.hook_().end(),
+ std::sort(v.hook_std_vector_().begin(), v.hook_std_vector_().end(),
value_psite_less_<I>(input));
return v;
}
@@ -168,7 +168,7 @@
const I& input)
{
p_array<mln_psite(I)> v = convert::to_p_array(input.domain());
- std::sort(v.hook_().begin(), v.hook_().end(),
+ std::sort(v.hook_std_vector_().begin(), v.hook_std_vector_().end(),
value_psite_greater_<I>(input));
return v;
}
Index: mln/make/dual_neighb2d.hh
--- mln/make/dual_neighb2d.hh (revision 2278)
+++ mln/make/dual_neighb2d.hh (working copy)
@@ -33,6 +33,7 @@
* \brief Routine to create a dual neighborhood.
*/
+# include <mln/convert/to.hh>
# include <mln/core/alias/window2d.hh>
# include <mln/win/multiple.hh>
# include <mln/core/neighb.hh>
Index: mln/convert/to_p_array.hh
--- mln/convert/to_p_array.hh (revision 2278)
+++ mln/convert/to_p_array.hh (working copy)
@@ -68,7 +68,7 @@
{
const S& pset = exact(pset_);
p_array<mln_psite(S)> v;
- v.reserve(pset.nsites());
+// v.reserve(pset.nsites());
// FIXME: Why mln_fwd_piter and not mln_piter?
mln_fwd_piter(S) p(pset);
for_all(p)
Index: mln/fun/c.hh
--- mln/fun/c.hh (revision 2278)
+++ mln/fun/c.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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
@@ -41,6 +41,51 @@
namespace mln
{
+ /// Concept-like.
+ template <typename E>
+ struct C_Function;
+
+
+ /// Category declaration for a unary C function.
+ template <typename R, typename A>
+ struct category< R (*)(A) >
+ {
+ typedef C_Function<void> ret;
+ };
+
+
+
+ // Forward declaration.
+ namespace fun { template <typename F> struct C; }
+
+
+
+ namespace trait
+ {
+
+ template <template <class> class Op,
+ typename R, typename A>
+ struct set_unary_< Op, C_Function, R (*)(A) >
+ {
+ typedef Op< fun::C<R (*)(A)> > Op_;
+ typedef typename Op_::ret ret;
+ };
+
+ template <template <class, class> class Op,
+ typename O,
+ typename R, typename A>
+ struct set_binary_< Op,
+ Object, O,
+ C_Function, R (*)(A) >
+ {
+ typedef Op< O, fun::C<R (*)(A)> > Op_;
+ typedef typename Op_::ret ret;
+ };
+
+ } // end of namespace trait
+
+
+
namespace fun
{
@@ -53,6 +98,7 @@
:
fun::internal::selector_< R, A, C<R(*)(A)> >::ret
{
+ C();
C(R (*f)(A));
typedef R result;
R operator()(const mlc_unqualif(A)& a) const;
@@ -65,6 +111,12 @@
template <typename R, typename A>
inline
+ C<R(*)(A)>::C()
+ {
+ }
+
+ template <typename R, typename A>
+ inline
C<R(*)(A)>::C(R (*f)(A))
: f_(f)
{
Index: mln/morpho/meyer_wst.hh
--- mln/morpho/meyer_wst.hh (revision 2278)
+++ mln/morpho/meyer_wst.hh (working copy)
@@ -104,10 +104,11 @@
template <typename L, typename I, typename N>
mln_ch_value(I, L)
- meyer_wst(const Image<I>& input, const Neighborhood<N>& nbh,
+ meyer_wst(const Image<I>& input, const Neighborhood<N>& nbh_,
L& nbasins)
{
/* FIXME: Ensure the input image has scalar values. */
+ const N& nbh = exact(nbh_);
typedef L marker;
const marker unmarked = literal::zero;
1
0
15 Sep '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Make neighborhoods based on windows work.
* sandbox/geraud/cs2d/tuto_bis.cc: Rename as...
* doc/examples/tuto_bis.cc: ...this.
De-activate code.
Start with new material.
* mln/core/window.hh (is_symmetric): Fix the use of sym.
* mln/core/neighb.hh (neighb_fwd_niter, neighb_bkd_niter): New.
(fwd_niter, bkd_niter, niter): Update.
(change_window): New.
(from_to_): New overload.
* mln/core/concept/window.hh (operator==): Split decl and def.
* mln/core/concept/neighborhood.hh (to_window): Relax sig.
* mln/make/dual_neighb2d.hh: New.
* mln/convert/to_p_set.hh (D): Remove useless typedef.
* mln/win/multiple.hh (is_centered, is_symmetrical): New.
doc/examples/tuto_bis.cc | 96 ++++++++++++++-
mln/convert/to_p_set.hh | 3
mln/core/concept/neighborhood.hh | 5
mln/core/concept/window.hh | 13 +-
mln/core/neighb.hh | 237 ++++++++++++++++++++++++++++++++++++++-
mln/core/window.hh | 3
mln/make/dual_neighb2d.hh | 80 +++++++++++++
mln/win/multiple.hh | 28 ++++
8 files changed, 442 insertions(+), 23 deletions(-)
Index: doc/examples/tuto_bis.cc
--- doc/examples/tuto_bis.cc (revision 2268)
+++ doc/examples/tuto_bis.cc (working copy)
@@ -1,9 +1,20 @@
# include <vector>
+# include <mln/core/var.hh>
+
+# include <mln/core/alias/point2d.hh>
+# include <mln/core/alias/window2d.hh>
+# include <mln/make/win_multiple.hh>
+# include <mln/convert/to.hh>
+# include <mln/make/dual_neighb2d.hh>
+# include <mln/literal/origin.hh>
+# include <mln/core/site_set/p_set.hh>
+
+
+/*
# include <mln/core/image/image2d.hh>
# include <mln/core/image/sub_image.hh>
# include <mln/core/image/image_if.hh>
-# include <mln/core/image_if_value.hh>
# include <mln/core/alias/neighb2d.hh>
# include <mln/core/alias/window2d.hh>
@@ -21,13 +32,14 @@
# include <mln/level/transform.hh>
# include <mln/accu/mean.hh>
-# include "dbl_neighb.hh"
+*/
+/*
+
namespace mln
{
-
namespace level
{
@@ -117,19 +129,50 @@
}
is_point;
+*/
+
- struct is_row_odd_t
+namespace mln
{
- bool operator()(const mln::point2d& p) const
+
+ template <typename W, typename S>
+ void convert_to_site_set(const Window<W>& win,
+ const mln_psite(W)& p,
+ Site_Set<S>& s_)
{
- return p.row() % 2;
+ std::cout << "win -> pset" << std::endl;
+
+ S& s = exact(s_);
+ s.clear();
+
+ mln_qiter(W) q(exact(win), p);
+ for_all(q)
+ exact(s).insert(q);
}
- } is_row_odd;
-#define mln_VAR(Var, Expr) \
-typeof(Expr) Var = Expr;
+ template <typename N, typename S>
+ void convert_to_site_set(const Neighborhood<N>& nbh,
+ const mln_psite(N)& p,
+ Site_Set<S>& s_)
+ {
+ S& s = exact(s_);
+ s.clear();
+
+ mln_niter(N) n(exact(nbh), p);
+ for_all(n)
+ exact(s).insert(n);
+ }
+
+}
+
+
+
+ bool is_row_odd(const mln::point2d& p)
+ {
+ return p.row() % 2;
+ }
@@ -137,6 +180,39 @@
{
using namespace mln;
+ // e2c
+
+ bool e2c_h[] = { 0, 1, 0,
+ 0, 0, 0,
+ 0, 1, 0 };
+
+ bool e2c_v[] = { 0, 0, 0,
+ 1, 0, 1,
+ 0, 0, 0 };
+
+ mln_VAR( e2c, make::dual_neighb2d(is_row_odd, e2c_h, e2c_v) );
+
+// p_set<point2d> s;
+// convert_to_site_set(e2c, literal::origin, s);
+// std::cout << s << std::endl;
+
+ bool e2e_h[] = { 0, 0, 1, 0, 0,
+ 0, 1, 0, 1, 0,
+ 0, 0, 0, 0, 0,
+ 0, 1, 0, 1, 0,
+ 0, 0, 1, 0, 0 };
+
+ bool e2e_v[] = { 0, 0, 0, 0, 0,
+ 0, 1, 0, 1, 0,
+ 1, 0, 0, 0, 1,
+ 0, 1, 0, 1, 0,
+ 0, 0, 0, 0, 0 };
+
+ mln_VAR( e2e, make::dual_neighb2d(is_row_odd, e2e_h, e2e_v) );
+
+
+ /*
+
window2d c4 = convert::to_window(mln::c4());
@@ -274,4 +350,6 @@
// 5 5 5
// DONE!
+
+ */
}
Index: mln/core/window.hh
--- mln/core/window.hh (revision 2277)
+++ mln/core/window.hh (working copy)
@@ -186,7 +186,8 @@
window<D>::is_symmetric() const
{
window<D> cpy = *this;
- return cpy.sym() == *this;
+ cpy.sym();
+ return cpy == *this;
}
template <typename D>
Index: mln/core/neighb.hh
--- mln/core/neighb.hh (revision 2277)
+++ mln/core/neighb.hh (working copy)
@@ -39,24 +39,30 @@
namespace mln
{
+ // Forward declaration.
+ template <typename W> class neighb_fwd_niter;
+ template <typename W> class neighb_bkd_niter;
/*! \brief Adapter class from window to neighborhood.
*/
template <typename W>
- class neighb : public internal::neighborhood_base< mln_dpsite(W), neighb<D> >,
+ class neighb : public internal::neighborhood_base< mln_dpsite(W), neighb<W> >,
private mlc_is_a(W, Window)::check_t
{
public:
+ typedef W window;
+ const W& to_window() const { return win_; }
+
/// Forward site iterator associated type.
- typedef mln_fwd_qiter(W) fwd_niter;
+ typedef neighb_fwd_niter<W> fwd_niter;
/// Backward site iterator associated type.
- typedef mln_bkd_qiter(W) bkd_niter;
+ typedef neighb_bkd_niter<W> bkd_niter;
/// Site iterator associated type.
- typedef mln_qiter(W) niter;
+ typedef fwd_niter niter;
/// Constructor without argument.
@@ -68,6 +74,9 @@
/// Get the corresponding window.
const W& win() const;
+ /// Change the corresponding window.
+ void change_window(const W& new_win);
+
private:
W win_;
};
@@ -83,14 +92,94 @@
void
from_to_(const mln::neighb<W>& from, W& to);
+ template <typename W>
+ void
+ from_to_(const W& from, mln::neighb<W>& to);
+
} // end of namespace convert::impl
} // end of namespace convert
+ // neighb_fwd_niter<W>
+
+ template <typename W>
+ class neighb_fwd_niter
+ : public internal::site_relative_iterator_base< neighb<W>,
+ neighb_fwd_niter<W> >
+ {
+ public:
+
+ /// Constructor without argument.
+ neighb_fwd_niter();
+
+ template <typename P>
+ neighb_fwd_niter(const neighb<W>& nbh, const P& c);
+
+ /// Test the iterator validity.
+ bool is_valid_() const;
+
+ /// Invalidate the iterator.
+ void invalidate_();
+
+ /// Start an iteration.
+ void do_start_();
+
+ /// Go to the next point.
+ void do_next_();
+
+ /// Compute the current psite.
+ mln_psite(W) compute_p_() const;
+
+ protected:
+
+ mln_fwd_qiter(W) i_;
+ };
+
+
+
+ // neighb_bkd_niter<W>
+
+ template <typename W>
+ class neighb_bkd_niter
+ : public internal::site_relative_iterator_base< neighb<W>,
+ neighb_bkd_niter<W> >
+ {
+ public:
+
+ /// Constructor without argument.
+ neighb_bkd_niter();
+
+ template <typename P>
+ neighb_bkd_niter(const neighb<W>& nbh, const P& c);
+
+ /// Test the iterator validity.
+ bool is_valid_() const;
+
+ /// Invalidate the iterator.
+ void invalidate_();
+
+ /// Start an iteration.
+ void do_start_();
+
+ /// Go to the next point.
+ void do_next_();
+
+ /// Compute the current psite.
+ mln_psite(W) compute_p_() const;
+
+ protected:
+
+ mln_bkd_qiter(W) i_;
+ };
+
+
+
# ifndef MLN_INCLUDE_ONLY
+ // neighb<W>
+
template <typename W>
inline
neighb<W>::neighb()
@@ -101,8 +190,7 @@
inline
neighb<W>::neighb(const W& win)
{
- mln_precondition(win.is_neighbable_());
- win_ = win;
+ change_window(win);
}
template <typename W>
@@ -113,6 +201,17 @@
return win_;
}
+ template <typename W>
+ inline
+ void
+ neighb<W>::change_window(const W& new_win)
+ {
+ mln_precondition(new_win.is_neighbable_());
+ win_ = new_win;
+ }
+
+
+ // convert::impl::from_to_
namespace convert
{
@@ -126,11 +225,137 @@
to = from.win();
}
+ template <typename W>
+ void
+ from_to_(const W& from, mln::neighb<W>& to)
+ {
+ to.change_window(from);
+ }
+
} // end of namespace convert::impl
} // end of namespace convert
+ // neighb_fwd_niter<W>
+
+ template <typename W>
+ inline
+ neighb_fwd_niter<W>::neighb_fwd_niter()
+ {
+ }
+
+ template <typename W>
+ template <typename P>
+ inline
+ neighb_fwd_niter<W>::neighb_fwd_niter(const neighb<W>& nbh, const P& c)
+ {
+ this->change_target(nbh);
+ this->center_at(c);
+ i_.center_at(c); // Always before change_target for this kind of iter.
+ i_.change_target(nbh.to_window());
+ }
+
+ template <typename W>
+ inline
+ bool
+ neighb_fwd_niter<W>::is_valid_() const
+ {
+ return i_.is_valid();
+ }
+
+ template <typename W>
+ inline
+ void
+ neighb_fwd_niter<W>::invalidate_()
+ {
+ i_.invalidate();
+ }
+
+ template <typename W>
+ inline
+ void
+ neighb_fwd_niter<W>::do_start_()
+ {
+ i_.start();
+ }
+
+ template <typename W>
+ inline
+ void
+ neighb_fwd_niter<W>::do_next_()
+ {
+ i_.next();
+ }
+
+ template <typename W>
+ inline
+ mln_psite(W)
+ neighb_fwd_niter<W>::compute_p_() const
+ {
+ return i_.compute_p_();
+ }
+
+
+ // neighb_bkd_niter<W>
+
+ template <typename W>
+ inline
+ neighb_bkd_niter<W>::neighb_bkd_niter()
+ {
+ }
+
+ template <typename W>
+ template <typename P>
+ inline
+ neighb_bkd_niter<W>::neighb_bkd_niter(const neighb<W>& nbh, const P& c)
+ {
+ this->change_target(nbh);
+ this->center_at(c);
+ i_.center_at(c); // Always before change_target for this kind of iter.
+ i_.change_target(nbh.to_window());
+ }
+
+ template <typename W>
+ inline
+ bool
+ neighb_bkd_niter<W>::is_valid_() const
+ {
+ return i_.is_valid();
+ }
+
+ template <typename W>
+ inline
+ void
+ neighb_bkd_niter<W>::invalidate_()
+ {
+ i_.invalidate();
+ }
+
+ template <typename W>
+ inline
+ void
+ neighb_bkd_niter<W>::do_start_()
+ {
+ i_.start();
+ }
+
+ template <typename W>
+ inline
+ void
+ neighb_bkd_niter<W>::do_next_()
+ {
+ i_.next();
+ }
+
+ template <typename W>
+ inline
+ mln_psite(W)
+ neighb_bkd_niter<W>::compute_p_() const
+ {
+ return i_.compute_p_();
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
Index: mln/core/concept/window.hh
--- mln/core/concept/window.hh (revision 2277)
+++ mln/core/concept/window.hh (working copy)
@@ -79,10 +79,8 @@
template <typename Wl, typename Wr>
- bool operator==(const Window<Wl>& lhs, const Window<Wr>& rhs)
- {
- return exact(lhs).std_vector() == exact(rhs).std_vector();
- }
+ bool operator==(const Window<Wl>& lhs, const Window<Wr>& rhs);
+
# ifndef MLN_INCLUDE_ONLY
@@ -100,6 +98,13 @@
typedef mln_bkd_qiter(E) bkd_qiter;
}
+ template <typename Wl, typename Wr>
+ inline
+ bool operator==(const Window<Wl>& lhs, const Window<Wr>& rhs)
+ {
+ return exact(lhs).std_vector() == exact(rhs).std_vector();
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
Index: mln/core/concept/neighborhood.hh
--- mln/core/concept/neighborhood.hh (revision 2277)
+++ mln/core/concept/neighborhood.hh (working copy)
@@ -73,6 +73,7 @@
};
+
# ifndef MLN_INCLUDE_ONLY
template <typename E>
@@ -84,8 +85,10 @@
typedef mln_bkd_niter(E) bkd_niter;
typedef mln_window(E) window;
- window (E::*m)() const = & E::to_window;
+ bool m = (& E::to_window) == (& E::to_window);
m = 0;
+// const window& (E::*m)() const = & E::to_window;
+// m = 0;
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/make/dual_neighb2d.hh
--- mln/make/dual_neighb2d.hh (revision 0)
+++ mln/make/dual_neighb2d.hh (revision 0)
@@ -0,0 +1,80 @@
+// 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_MAKE_DUAL_NEIGHB2D_HH
+# define MLN_MAKE_DUAL_NEIGHB2D_HH
+
+/*! \file mln/make/dual_neighb2d.hh
+ *
+ * \brief Routine to create a dual neighborhood.
+ */
+
+# include <mln/core/alias/window2d.hh>
+# include <mln/win/multiple.hh>
+# include <mln/core/neighb.hh>
+
+
+namespace mln
+{
+
+ namespace make
+ {
+
+ template <typename A, unsigned St, unsigned Sf>
+ neighb< win::multiple<window2d, bool(*)(A)> >
+ dual_neighb2d(bool (*test)(A),
+ bool const (&when_true) [St],
+ bool const (&when_false)[Sf]);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename A, unsigned St, unsigned Sf>
+ inline
+ neighb< win::multiple<window2d, bool(*)(A)> >
+ dual_neighb2d(bool (*test)(A),
+ bool const (&when_true) [St],
+ bool const (&when_false)[Sf])
+ {
+ typedef win::multiple<window2d, bool(*)(A)> W;
+ W wm(test);
+ wm.set_window(false, convert::to<window2d>(when_false)); // 0
+ wm.set_window(true, convert::to<window2d>(when_true) ); // 1
+ neighb<W> tmp(wm);
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MAKE_DUAL_NEIGHB2D_HH
Index: mln/convert/to_p_set.hh
--- mln/convert/to_p_set.hh (revision 2277)
+++ mln/convert/to_p_set.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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
@@ -112,7 +112,6 @@
inline
p_set<mln_site(W)> to_p_set(const Window<W>& win)
{
- typedef mln_dpsite(W) D;
typedef mln_site(W) P;
p_set<P> pset;
mln_qiter(W) q(exact(win), P::origin);
Index: mln/win/multiple.hh
--- mln/win/multiple.hh (revision 2277)
+++ mln/win/multiple.hh (working copy)
@@ -78,6 +78,10 @@
const mln_dpsite(W)& ith_dp_around(unsigned i, const mln_psite(W)& p) const;
+ bool is_centered() const;
+
+ bool is_symmetric() const;
+
private:
util::array<W> win_;
@@ -179,6 +183,30 @@
template <typename W, typename F>
inline
+ bool
+ multiple<W,F>::is_centered() const
+ {
+ mln_precondition(win_.nelements() >= 1);
+ for (unsigned i = 0; i < win_.nelements(); ++i)
+ if (! win_[i].is_centered())
+ return false;
+ return true;
+ }
+
+ template <typename W, typename F>
+ inline
+ bool
+ multiple<W,F>::is_symmetric() const
+ {
+ mln_precondition(win_.nelements() >= 1);
+ for (unsigned i = 0; i < win_.nelements(); ++i)
+ if (! win_[i].is_symmetric())
+ return false;
+ return true;
+ }
+
+ template <typename W, typename F>
+ inline
unsigned
multiple<W,F>::size_around(const mln_psite(W)& p) const
{
1
0
* mln/make/neighb2d.hh: Include mln/convert/to.hh.
---
milena/ChangeLog | 6 ++++++
milena/mln/make/neighb2d.hh | 1 +
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 1654dea..2b828ba 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,11 @@
2008-09-15 Roland Levillain <roland(a)lrde.epita.fr>
+ Have tools/area_flooding compile again (cont.).
+
+ * mln/make/neighb2d.hh: Include mln/convert/to.hh.
+
+2008-09-15 Roland Levillain <roland(a)lrde.epita.fr>
+
Have tools/area_flooding compile again.
* mln/core/image/line_graph_image.hh
diff --git a/milena/mln/make/neighb2d.hh b/milena/mln/make/neighb2d.hh
index 0f4b19f..26ca9fa 100644
--- a/milena/mln/make/neighb2d.hh
+++ b/milena/mln/make/neighb2d.hh
@@ -34,6 +34,7 @@
*/
# include <mln/core/alias/window2d.hh>
+# include <mln/convert/to.hh>
namespace mln
--
1.5.6.5
1
0
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008
ChangeLog:
2008-09-15 Guillaume Lazzara <z(a)lrde.epita.fr>
Improve user doc generation.
* milena/doc/Doxyfile.in: Exclude the proper file.
* milena/doc/Makefile.am: Exclude the proper symbols for the user doc.
---
Doxyfile.in | 3 ++-
Makefile.am | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
Index: branches/cleanup-2008/milena/doc/Doxyfile.in
===================================================================
--- branches/cleanup-2008/milena/doc/Doxyfile.in (revision 2271)
+++ branches/cleanup-2008/milena/doc/Doxyfile.in (revision 2272)
@@ -80,7 +80,8 @@
*.hcc
RECURSIVE = YES
EXCLUDE = @top_srcdir@/milena/sandbox \
- @top_srcdir@/milena/mln/core/concept
+ @top_srcdir@/milena/mln/core/concept \
+ @top_srcdir@/milena/mln/core/concept/proxy.hxx
EXCLUDE_SYMLINKS = YES
EXCLUDE_PATTERNS = *spe.hh
EXCLUDE_SYMBOLS =
Index: branches/cleanup-2008/milena/doc/Makefile.am
===================================================================
--- branches/cleanup-2008/milena/doc/Makefile.am (revision 2271)
+++ branches/cleanup-2008/milena/doc/Makefile.am (revision 2272)
@@ -41,7 +41,7 @@
-e 's,INTERNAL_DOCS = YES,INTERNAL_DOCS = NO,g' \
-e 's,GENERATE_TODOLIST = YES,GENERATE_TODOLIST = NO,g' \
-e 's,PROJECT_NUMBER = \",PROJECT_NUMBER = \"User documentation ,g' \
- -e 's,EXCLUDE_SYMBOLS =,EXCLUDE_SYMBOLS = mln::internal::*,g'
+ -e 's,EXCLUDE_SYMBOLS =,EXCLUDE_SYMBOLS = *::internal*,g'
1
0