URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-04 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Add best canvas and make median_dir use it.
* mln/canvas/browsing/dir_ricard51.hh: New canvas.
* mln/canvas/browsing/directional.hh: Fix some names.
* mln/level/median.hh: Use new canvas.
* tests/level_median_dir.cc: New.
---
mln/canvas/browsing/dir_ricard51.hh | 173 ++++++++++++++++++++++++++++++++++++
mln/canvas/browsing/directional.hh | 8 -
mln/level/median.hh | 63 +++----------
tests/level_median_dir.cc | 55 +++++++++++
4 files changed, 248 insertions(+), 51 deletions(-)
Index: trunk/milena/tests/level_median_dir.cc
===================================================================
--- trunk/milena/tests/level_median_dir.cc (revision 0)
+++ trunk/milena/tests/level_median_dir.cc (revision 1239)
@@ -0,0 +1,55 @@
+// 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/level_median.cc
+ *
+ * \brief Test on mln::level::median.
+ */
+
+#include <mln/core/image2d_b.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/level/median.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ border::thickness = 7;
+
+ image2d_b<int_u8>
+ lena = io::pgm::load("../img/lena.pgm"),
+ out(lena.domain());
+
+ level::median_dir(lena, 1, 15, out);
+ io::pgm::save(out, "out.pgm");
+}
Index: trunk/milena/mln/level/median.hh
===================================================================
--- trunk/milena/mln/level/median.hh (revision 1238)
+++ trunk/milena/mln/level/median.hh (revision 1239)
@@ -41,7 +41,7 @@
# include <mln/set/diff.hh>
# include <mln/canvas/browsing/snake_fwd.hh>
-# include <mln/canvas/browsing/directional.hh>
+# include <mln/canvas/browsing/dir_ricard51.hh>
# include <mln/accu/median.hh>
@@ -190,11 +190,6 @@
// aux data
mln_point(I) p;
- const mln_point(I)
- pmin, pmax;
- const mln_coord(I)
- pmin_dir, pmax_dir,
- pmin_dir_plus, pmax_dir_minus;
accu::median<mln_vset(I)> med;
// ctor
@@ -206,12 +201,6 @@
output(exact(output)),
// aux data
p(),
- pmin(input.domain().pmin()),
- pmax(input.domain().pmax()),
- pmin_dir(pmin[dir]),
- pmax_dir(pmax[dir]),
- pmin_dir_plus (pmin[dir] + length / 2),
- pmax_dir_minus(pmax[dir] - length / 2),
med(input.values())
{
}
@@ -220,55 +209,26 @@
{
}
- void next()
+ void init_line()
{
- mln_point(I)
- p = this->p,
- pt = p,
- pu = p;
-
- typedef mln_coord(I)& coord_ref;
- coord_ref
- ct = pt[dir],
- cu = pu[dir],
- p_dir = p[dir];
-
- // initialization (before first point of the row)
med.init();
- for (ct = pmin_dir; ct < pmin_dir_plus; ++ct)
- if (input.has(pt))
- med.take(input(pt));
+ }
- // left columns (just take new points)
- for (p_dir = pmin_dir; p_dir <= pmin_dir_plus; ++p_dir, ++ct)
+ void add_point(mln_point(I) pt)
{
- if (input.has(pt))
med.take(input(pt));
- if (output.has(p))
- output(p) = med.to_result();
}
- // middle columns (both take and untake)
- cu = pmin[dir];
- for (; p_dir <= pmax_dir_minus; ++cu, ++p_dir, ++ct)
+ void remove_point(mln_point(I) pu)
{
- if (input.has(pt))
- med.take(input(pt));
- if (input.has(pu))
med.untake(input(pu));
- if (output.has(p))
- output(p) = med.to_result();
}
- // right columns (now just untake old points)
- for (; p_dir <= pmax_dir; ++cu, ++p_dir)
+ void next()
{
- if (input.has(pu))
- med.untake(input(pu));
if (output.has(p))
output(p) = med.to_result();
}
- }
void final()
{
@@ -282,7 +242,7 @@
void median_dir_(const Image<I>& input, unsigned dir, unsigned length, O& output)
{
median_dir_t<I,O> f(exact(input), dir, length, output);
- canvas::browsing::directional(f);
+ canvas::browsing::dir_ricard51(f);
}
@@ -330,11 +290,20 @@
void median_dir(const Image<I>& input, unsigned dir, unsigned length,
Image<O>& output)
{
+ trace::entering("level::median_dir");
+
+ mlc_is(mln_trait_image_io(O), trait::io::write)::check();
+ mlc_is(mln_trait_image_support(I), trait::support::aligned)::check();
+ mlc_converts_to(mln_value(I), mln_value(O))::check();
+
mln_precondition(exact(output).domain() == exact(input).domain());
typedef mln_point(I) P;
mln_precondition(dir < P::dim);
mln_precondition(length % 2 == 1);
+
impl::median_dir_(exact(input), dir, length, exact(output));
+
+ trace::exiting("level::median_dir");
}
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/canvas/browsing/dir_ricard51.hh
===================================================================
--- trunk/milena/mln/canvas/browsing/dir_ricard51.hh (revision 0)
+++ trunk/milena/mln/canvas/browsing/dir_ricard51.hh (revision 1239)
@@ -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_CANVAS_DIR_RICARD51_HH
+# define MLN_CANVAS_DIR_RICARD51_HH
+
+/*! \file mln/canvas/dir_ricard51.hh
+ *
+ * \brief Dir_Ricard51 browsing of an image.
+ */
+
+# include <mln/core/concept/browsing.hh>
+# include <mln/core/concept/image.hh>
+
+namespace mln
+{
+
+ namespace canvas
+ {
+
+ namespace browsing
+ {
+
+ /*! FIXME : DOC
+ * F shall features : \n
+ * { \n
+ * --- as types: \n
+ * I; \n
+ * --- as attributes: \n
+ * dim; \n
+ * dir; // and test dir < dim \n
+ * input; \n
+ * p; \n
+ * length; \n
+ * --- as methods: \n
+ * void init(); \n
+ * void init_line(); \n
+ * void add_point(p) \n
+ * void remove_point(p) \n
+ * void next(); \n
+ * void final(); \n
+ * } \n
+ *
+ */
+ struct dir_ricard51_t : public Browsing< dir_ricard51_t >
+ {
+ template <typename F>
+ void operator()(F& f) const;
+ }
+
+ dir_ricard51;
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename F>
+ void
+ dir_ricard51_t::operator()(F& f) const
+ {
+ mln_precondition(f.dir < f.dim);
+ typedef typename F::I I;
+
+ const mln_point(I)
+ pmin = f.input.domain().pmin(),
+ pmax = f.input.domain().pmax();
+
+ const mln_coord(I)
+ pmin_dir = pmin[f.dir],
+ pmax_dir = pmax[f.dir],
+ pmin_dir_plus_half_length = pmin_dir + f.length / 2,
+ pmax_dir_minus_half_length = pmax_dir - f.length / 2;
+
+ mln_point(I) pt, pu;
+
+ typedef mln_coord(I)& coord_ref;
+ coord_ref
+ ct = pt[f.dir],
+ cu = pu[f.dir],
+ p_dir = f.p[f.dir];
+
+ f.p = pmin;
+
+ f.init();
+
+ do
+ {
+ pt = f.p;
+ pu = f.p;
+
+ f.init_line();
+
+ // initialization (before first point of the line)
+ for (ct = pmin_dir; ct < pmin_dir_plus_half_length; ++ ct)
+ if (f.input.has(pt))
+ f.add_point(pt);
+
+ // left columns (just take new points)
+ for (p_dir = pmin_dir; p_dir <= pmin_dir_plus_half_length; ++p_dir, ++ct)
+ {
+ if (f.input.has(pt))
+ f.add_point(pt);
+ f.next();
+ }
+
+ // middle columns (both take and untake)
+ cu = pmin_dir;
+ for (; p_dir <= pmax_dir_minus_half_length; ++cu, ++p_dir, ++ct)
+ {
+ if (f.input.has(pt))
+ f.add_point(pt);
+ if (f.input.has(pu))
+ f.remove_point(pu);
+ f.next();
+ }
+
+ // right columns (now just untake old points)
+ for (; p_dir <= pmax_dir; ++cu, ++p_dir)
+ {
+ if (f.input.has(pu))
+ f.remove_point(pu);
+ f.next();
+ }
+
+ p_dir = pmin_dir;
+
+ for (int c = F::dim - 1; c >= 0; --c)
+ {
+ if (c == int(f.dir))
+ continue;
+ if (f.p[c] != pmax[c])
+ {
+ ++f.p[c];
+ break;
+ }
+ f.p[c] = pmin[c];
+ }
+ } while (f.p != pmin);
+
+ f.final();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::canvas::browsing
+
+ } // end of namespace mln::canvas
+
+} // end of namespace mln
+
+#endif // ! MLN_CANVAS_DIR_RICARD51_HH
Index: trunk/milena/mln/canvas/browsing/directional.hh
===================================================================
--- trunk/milena/mln/canvas/browsing/directional.hh (revision 1238)
+++ trunk/milena/mln/canvas/browsing/directional.hh (revision 1239)
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CANVAS_DIRBROWSING_HH
-# define MLN_CANVAS_DIRBROWSING_HH
+#ifndef MLN_CANVAS_DIRECTIONAL_HH
+# define MLN_CANVAS_DIRECTIONAL_HH
-/*! \file mln/canvas/dirbrowsing.hh
+/*! \file mln/canvas/browsing/directional.hh
*
* \brief Directional browsing of an image.
*/
@@ -115,4 +115,4 @@
} // end of namespace mln
-#endif // ! MLN_CANVAS_DIRBROWSING_HH
+#endif // ! MLN_CANVAS_DIRECTIONAL_HH
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-03 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add test for fast labeling.
* labeling_level_fast.cc: New test.
---
labeling_level_fast.cc | 63 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
Index: trunk/milena/tests/labeling_level_fast.cc
===================================================================
--- trunk/milena/tests/labeling_level_fast.cc (revision 0)
+++ trunk/milena/tests/labeling_level_fast.cc (revision 1235)
@@ -0,0 +1,63 @@
+// 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/labeling_foreground.cc
+ *
+ * \brief Test on mln::labeling::foreground.
+ */
+
+#include <mln/core/image2d_b.hh>
+#include <mln/core/image1d_b.hh>
+#include <mln/core/neighb2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/pw/all.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/labeling/level.hh>
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ unsigned border = 1;
+
+ image2d_b<value::int_u8> i1(5, 5, border);
+ debug::iota(i1);
+ i1[10] = i1[17] = i1[18] = i1[25] = i1[26] = i1[22] = i1[29] = 2;
+ debug::println(i1);
+
+ unsigned n;
+ image2d_b<value::int_u8> out(i1.domain(), border);
+ labeling::level_fast(i1, 2, c4(), out, n);
+
+ std::cout << "n = " << n << std::endl;
+ debug::println(out);
+}
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-03 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add test for voronoi algorithm.
* labeling_algo.cc: New.
---
labeling_algo.cc | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 82 insertions(+)
Index: trunk/milena/tests/labeling_algo.cc
===================================================================
--- trunk/milena/tests/labeling_algo.cc (revision 0)
+++ trunk/milena/tests/labeling_algo.cc (revision 1233)
@@ -0,0 +1,82 @@
+// 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/labeling_foreground.cc
+ *
+ * \brief Test on mln::labeling::foreground.
+ */
+
+# include <mln/core/image2d_b.hh>
+# include <mln/core/sub_image.hh>
+# include <mln/core/neighb2d.hh>
+# include <mln/value/int_u8.hh>
+# include <mln/level/fill.hh>
+# include <mln/level/stretch.hh>
+# include <mln/border/fill.hh>
+# include <mln/io/pbm/load.hh>
+# include <mln/io/pgm/save.hh>
+# include <mln/labeling/foreground.hh>
+# include <mln/debug/println.hh>
+# include <mln/draw/mesh.hh>
+# include <mln/geom/seeds2tiling.hh>
+# include <mln/make/voronoi.hh>
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d_b<bool> in = io::pbm::load("../img/toto.pbm");
+
+ image2d_b<int_u8> lab(in.domain());
+ image2d_b<int_u8> inte(in.domain());
+ image2d_b<int_u8> out(in.domain());
+
+ unsigned n;
+ labeling::foreground(in, c8(), lab, n);
+ std::cout << "number of labels = " << n << std::endl;
+ std::vector<int_u8> vec;
+
+ image2d_b<int> input(in.domain());
+ level::fill(input, lab);
+ lab(make::point2d (0,0)) = 0;
+
+ inte = geom::seeds2tiling(lab, c4 ());
+ border::fill (inte, 0);
+
+ image2d_b<int_u8> inte2(inte.domain());
+
+ level::stretch (inte, inte2);
+
+ io::pgm::save(inte2, "inte.pgm");
+
+ mesh_p<point2d> m = make::voronoi(inte, lab, c4());
+ std::cout << "OK : generate inte.pgm and out.pgm" << std::endl;
+ draw::mesh (out, m, 255, 128);
+
+ io::pgm::save(out, "out.pgm");
+}
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-03 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add voronoi algorithm.
* voronoi.hh: New.
---
voronoi.hh | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 129 insertions(+)
Index: trunk/milena/mln/make/voronoi.hh
===================================================================
--- trunk/milena/mln/make/voronoi.hh (revision 0)
+++ trunk/milena/mln/make/voronoi.hh (revision 1232)
@@ -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_MAKE_VORONOI_HH
+# define MLN_MAKE_VORONOI_HH
+
+/*! \file mln/make/voronoi.hh
+ *
+ * \brief Routine to construct an mln::make::voronoi.
+ */
+
+# include <vector>
+# include <map>
+
+# include <mln/core/mesh_p.hh>
+# include <mln/accu/mean.hh>
+# include <mln/estim/min_max.hh>
+
+namespace mln
+{
+
+ namespace make
+ {
+
+ template <typename I, typename N>
+ mesh_p<mln_psite(I)>
+ voronoi (Image<I>& ima_,
+ Image<I>& orig_,
+ const Neighborhood<N>& nbh);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename N>
+ mesh_p<mln_psite(I)>
+ voronoi (Image<I>& ima_,
+ Image<I>& orig_,
+ const Neighborhood<N>& nbh)
+ {
+ typedef metal::vec<2,float> X;
+ typedef mln_value(I) V;
+ typedef mln_psite(I) P;
+
+ I& ima = exact(ima_);
+ I& orig = exact(orig_);
+ util::graph<void> gr;
+ V min, max;
+ estim::min_max (ima, min, max);
+ unsigned nb = max - min + 1;
+ std::vector<P> v(nb);
+ std::vector< accu::mean_< X > > tab_mean (nb);
+ std::map<std::pair<V, V>, bool> m;
+
+ /// Take original point.
+ {
+ mln_piter(I) p(orig.domain());
+
+ for_all(p)
+ {
+ if (orig(p) != 0)
+ {
+ X x = mln_point(I)(p);
+ tab_mean[orig(p) - min].take(x);
+ }
+ }
+ }
+
+ /// Compute links between link.
+ {
+ mln_piter(I) p(ima.domain());
+ mln_niter(N) n(nbh, p);
+
+ for_all(p)
+ {
+ for_all (n) if (ima.has(n))
+ if (ima(p) != ima(n))
+ m[std::pair<V, V>(ima(p) - min, ima(n) - min)] = true;
+ }
+ }
+
+ /// Compute the center of label.
+ for (unsigned i = 0; i < nb; ++i)
+ {
+ gr.add_node ();
+
+ /// FIXME
+ v[i] = make::point2d ((unsigned)tab_mean[i].to_result ()[0],
+ (unsigned)tab_mean[i].to_result ()[1]);
+ }
+
+ typename std::map<std::pair<V, V>, bool>::const_iterator it = m.begin ();
+ for (; it != m.end (); ++it)
+ gr.add_edge((*it).first.first, (*it).first.second);
+
+ mesh_p<P> res(gr, v);
+ return res;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::make
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MAKE_VORONOI_HH
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-03 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add seeds2tiling.hh.
* seeds2tiling.hh: New.
---
seeds2tiling.hh | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 126 insertions(+)
Index: trunk/milena/mln/geom/seeds2tiling.hh
===================================================================
--- trunk/milena/mln/geom/seeds2tiling.hh (revision 0)
+++ trunk/milena/mln/geom/seeds2tiling.hh (revision 1231)
@@ -0,0 +1,126 @@
+// 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_GEOM_SEEDS2TILING_HH
+# define MLN_GEOM_SEEDS2TILING_HH
+
+/*! \file mln/geom/seeds2tiling.hh
+ *
+ * \brief .
+ */
+
+# include <map>
+
+# include <mln/core/queue_p.hh>
+# include <mln/core/clone.hh>
+# include <mln/accu/mean.hh>
+# include <mln/estim/min_max.hh>
+# include <mln/metal/vec.hh>
+
+
+namespace mln
+{
+ namespace geom
+ {
+
+ template <typename I, typename N>
+ I seeds2tiling (Image<I>& ima_, const Neighborhood<N>& nbh);
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename I, typename N>
+ I
+ seeds2tiling (Image<I>& ima_,
+ const Neighborhood<N>& nbh)
+ {
+ I& ima = exact(ima_);
+ I out = clone(ima_);
+ queue_p<mln_psite(I)> q;
+
+ // Init.
+ {
+ mln_piter(I) p(ima.domain());
+ mln_niter(N) n(nbh, p);
+
+ for_all(p) if (ima(p) == 0)
+ for_all(n) if (ima(n) != 0)
+ {
+ q.push(p);
+ break;
+ }
+ }
+
+// // Body.
+// {
+// while (! q.empty())
+// {
+// mln_psite(I) p = q.front();
+// q.pop();
+// mln_invariant(ima(p) == 0);
+
+// mln_niter(N) n(nbh, p);
+// for_all(n) if (ima.has(n))
+// if (out(n) != 0)
+// out(p) = out(n);
+// else
+// if (! q.has(n))
+// q.push(n);
+// }
+// }
+
+ // Body: alternative version.
+ {
+ while (! q.empty())
+ {
+ mln_psite(I) p = q.front();
+ q.pop();
+ if (out(p) != 0) // p has already been processed so ignore
+ continue;
+
+ mln_niter(N) n(nbh, p);
+ for_all(n) if (ima.has(n))
+ if (out(n) != 0)
+ out(p) = out(n);
+ else
+ q.push_force(n); // n may already be in the queue,
+ // yet we then queue again this psite
+ }
+ }
+
+ return out;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_SEEDS2TILING_HH
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-03 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add color sub_image in sandbox.
* color_sub.cc: New.
Update
* labeling_algo.cc,
* labeling_level_fast.cc: Update.
---
color_sub.cc | 83 +++++++++++++++++++++++++++++++++++++++++++++++++
labeling_algo.cc | 2 -
labeling_level_fast.cc | 2 -
3 files changed, 85 insertions(+), 2 deletions(-)
Index: trunk/milena/sandbox/duhamel/labeling_algo.cc
===================================================================
--- trunk/milena/sandbox/duhamel/labeling_algo.cc (revision 1229)
+++ trunk/milena/sandbox/duhamel/labeling_algo.cc (revision 1230)
@@ -52,7 +52,7 @@
using value::int_u8;
// image2d_b<bool> in = io::pbm::load("../../img/toto.pbm");
- image2d_b<bool> in = io::pbm::load("../../img/toto.pbm");
+ image2d_b<bool> in = io::pbm::load("test.pbm");
image2d_b<int_u8> lab(in.domain());
image2d_b<int_u8> inte(in.domain());
Index: trunk/milena/sandbox/duhamel/color_sub.cc
===================================================================
--- trunk/milena/sandbox/duhamel/color_sub.cc (revision 0)
+++ trunk/milena/sandbox/duhamel/color_sub.cc (revision 1230)
@@ -0,0 +1,83 @@
+// 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/sub_image.cc
+ *
+ * \brief Tests on mln::sub_image.
+ */
+
+#include <mln/core/image2d_b.hh>
+#include <mln/core/sub_image.hh>
+#include <mln/core/inplace.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/level/fill.hh>
+#include <mln/debug/println.hh>
+
+#include <mln/core/image2d_b.hh>
+#include <mln/core/point2d.hh>
+#include <mln/debug/println.hh>
+#include <mln/util/graph.hh>
+#include <mln/io/ppm/save.hh>
+#include <mln/fun/p2b/chess.hh>
+
+#include <mln/core/image_if_value.hh>
+#include <mln/debug/iota.hh>
+
+namespace mln
+{
+ template <typename I, typename J>
+ void
+ color (Image<I>& ima_, Image<J>& out_)
+ {
+ I& ima = exact (ima_);
+ J& out = exact (out_);
+
+ level::fill (out, value::rgb8(255, 0, 0));
+
+ {
+ mln_piter(I) p (ima.domain ());
+ for_all (p)
+ {
+ out(p) = value::rgb8(ima(p));
+ }
+ }
+ }
+}
+
+int main()
+{
+ using namespace mln;
+
+ image2d_b<value::int_u8> ima(3,3);
+ debug::iota(ima);
+ image2d_b<value::rgb8> out(ima.domain ().bbox ());
+ std::cout << ima.domain() << std::endl;
+ color(inplace (ima | 6), out);
+ io::ppm::save(out, "out.ppm");
+ debug::println(out);
+}
Index: trunk/milena/sandbox/duhamel/labeling_level_fast.cc
===================================================================
--- trunk/milena/sandbox/duhamel/labeling_level_fast.cc (revision 1229)
+++ trunk/milena/sandbox/duhamel/labeling_level_fast.cc (revision 1230)
@@ -38,7 +38,7 @@
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
-#include "labeling_level.hh"
+#include <mln/labeling/level.hh>
#include <mln/debug/iota.hh>
#include <mln/debug/println_with_border.hh>