https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add a test of attribute image computation.
* geraud/test_attribute.cc: New.
test_attribute.cc | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 122 insertions(+)
Index: geraud/test_attribute.cc
--- geraud/test_attribute.cc (revision 0)
+++ geraud/test_attribute.cc (revision 0)
@@ -0,0 +1,122 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// \file tests/morpho/tree/compute_attribute_image.cc
+///
+/// Tests on mln::morpho::tree::compute_attribute_image.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/core/site_set/p_array.hh>
+#include <mln/level/sort_psites.hh>
+#include <mln/level/transform.hh>
+
+#include <mln/debug/println.hh>
+#include <mln/core/var.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/morpho/tree/data.hh>
+#include <mln/morpho/tree/compute_attribute_image.hh>
+
+#include <mln/morpho/closing_area.hh>
+#include <mln/morpho/opening_area.hh>
+
+#include <mln/accu/count.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/pbm/save.hh>
+
+#include <mln/arith/min.hh>
+#include <mln/arith/diff_abs.hh>
+
+
+struct sat_t : mln::Function_v2v<sat_t>
+{
+ typedef mln::value::int_u8 result;
+ result operator()(unsigned u) const
+ {
+ return u > 255 ? 255 : u;
+ }
+}
+ sat;
+
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ typedef image2d<int_u8> I;
+ typedef p_array<point2d> S;
+ typedef util::pix<I> Px;
+
+
+ I f;
+ io::pgm::load(f, "../../../img/tiny.pgm");
+
+
+ image2d<unsigned> area_inc, area_dec;
+ {
+ S s = level::sort_psites_increasing(f);
+ morpho::tree::data<I,S> t(f, s, c4());
+ accu::count<Px> a;
+ area_inc = morpho::tree::compute_attribute_image(a, t);
+ debug::println("area_inc =", area_inc);
+ }
+ {
+ S s = level::sort_psites_decreasing(f);
+ morpho::tree::data<I,S> t(f, s, c4());
+ accu::count<Px> a;
+ area_dec = morpho::tree::compute_attribute_image(a, t);
+ debug::println("area_dec =", area_dec);
+ }
+
+ io::pgm::save(level::transform(area_inc, sat), "inc.pgm");
+ io::pgm::save(level::transform(area_dec, sat), "dec.pgm");
+
+ image2d<unsigned> area = arith::min(area_inc, area_dec);
+ io::pgm::save(level::transform(area, sat), "min.pgm");
+
+ unsigned lambda = 20;
+
+ {
+ I clo = morpho::closing_area(f, c4(), lambda);
+ io::pgm::save(clo, "clo.pgm");
+
+ I ope(clo.domain());
+ morpho::opening_area(f, c4(), lambda, ope);
+ io::pgm::save(ope, "ope.pgm");
+
+ I d_clo = arith::diff_abs(f, clo);
+ io::pgm::save(d_clo, "d_clo.pgm");
+
+ I d_ope = arith::diff_abs(f, ope);
+ io::pgm::save(d_ope, "d_ope.pgm");
+ }
+
+}
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add a version of parent computation that store roots.
* geraud/compute_parent_more.hh: New.
compute_parent_more.hh | 191 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 191 insertions(+)
Index: geraud/compute_parent_more.hh
--- geraud/compute_parent_more.hh (revision 0)
+++ geraud/compute_parent_more.hh (revision 0)
@@ -0,0 +1,191 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_MORPHO_TREE_COMPUTE_PARENT_HH
+# define MLN_MORPHO_TREE_COMPUTE_PARENT_HH
+
+/// \file mln/morpho/tree/compute_parent.hh
+///
+/// Compute a canonized tree from an image.
+///
+/// \todo Specialize for low quant (and try fastest).
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/level/fill.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace tree
+ {
+
+
+ template <typename T>
+ inline
+ mln_psite(T)
+ zfind_root(T& zpar, const mln_psite(T)& x)
+ {
+ mlc_equal(mln_value(T), mln_psite(T))::check();
+ if (zpar(x) == x)
+ return x;
+ else
+ return zpar(x) = zfind_root(zpar, zpar(x));
+ }
+
+
+
+ template <typename I, typename N, typename S>
+ inline
+ mln_ch_value(I, mln_psite(I))
+ compute_parent_more(const Image<I>& f_,
+ const Neighborhood<N>& nbh_,
+ const Site_Set<S>& s_)
+ {
+ typedef mln_psite(I) P;
+
+ const I& f = exact(f_);
+ const N& nbh = exact(nbh_);
+ const S& s = exact(s_);
+
+ // Auxiliary data.
+ mln_ch_value(I, bool) deja_vu;
+ mln_ch_value(I, P) parent;
+ mln_ch_value(I, P) zpar;
+
+ initialize(deja_vu, f);
+ initialize(parent, f);
+ initialize(zpar, f);
+
+ typedef mln_vset(S) Vs;
+ typedef mln_pset(S) Ps;
+ S roots;
+
+ // Initialization.
+ level::fill(deja_vu, false);
+ unsigned nnodes = 0;
+
+ // Body.
+ mln_bkd_viter(Vs) v(s.values());
+ for_all(v)
+ {
+ if (s(v).is_empty())
+ continue;
+
+ mln_bkd_piter(Ps) p(s(v));
+ mln_niter(N) n(nbh, p);
+ for_all(p)
+ {
+ // Make-Set.
+ parent(p) = p;
+ zpar(p) = p;
+
+ for_all(n)
+ if (f.domain().has(n) && deja_vu(n))
+ {
+ // Do-Union.
+ P r = internal::zfind_root(zpar, n);
+ if (r != p)
+ {
+ parent(r) = p;
+ zpar(r) = p;
+ }
+ }
+ deja_vu(p) = true;
+ }
+
+
+ /*
+
+ // Canonization on the-fly.
+ {
+ // Intra-v:
+ mln_fwd_piter(Ps) p(s(v));
+ for_all(p)
+ parent(p) = parent(parent(p));
+
+ // Inter "previous v and current v":
+ mln_piter(Ps) r(v_roots);
+ for_all(r)
+ parent(r) = parent(parent(r));
+ v_roots.clear();
+
+ {
+ // New roots:
+ mln_piter(Ps) p(s(v));
+ for_all(p)
+ if (parent(p) == p)
+ v_roots.insert(p);
+ nnodes += v_roots.nsites();
+ }
+ }
+
+ */
+
+ // Storing roots.
+ {
+ mln_piter(Ps) p(s(v));
+ for_all(p)
+ if (parent(p) == p)
+ roots(v).insert(p);
+ nnodes += roots(v).nsites();
+ }
+
+ } // end of "for_all(v)"
+
+
+ // Canonization.
+ {
+ mln_fwd_piter(S) p(s);
+ for_all(p)
+ {
+ P q = parent(p);
+ if (f(parent(q)) == f(q))
+ parent(p) = parent(q);
+ }
+ }
+
+ std::cout << "roots = " << roots << std::endl;
+ std::cout << "nnodes = " << nnodes << std::endl;
+
+
+ return parent;
+ }
+
+
+ } // end of namespace mln::morpho::tree
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_TREE_COMPUTE_PARENT_HH
* doc/examples/erosion.cc: Apply a vertical and a horizontal erosion
on a given image.
* doc/examples/graph.cc: Show how to use graphes with images.
---
milena/ChangeLog | 9 +++
milena/doc/examples/erosion.cc | 110 +++++++++++++++++++++++++++++++++++++
milena/doc/examples/graph.cc | 116 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 235 insertions(+), 0 deletions(-)
create mode 100644 milena/doc/examples/erosion.cc
create mode 100644 milena/doc/examples/graph.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 28fdcc9..374175c 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,4 +1,13 @@
2008-11-27 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Add new examples.
+
+ * doc/examples/erosion.cc: Apply a vertical and a horizontal erosion
+ on a given image.
+
+ * doc/examples/graph.cc: Show how to use graphes with images.
+
+2008-11-27 Guillaume Lazzara <z(a)lrde.epita.fr>
Various small fixes.
diff --git a/milena/doc/examples/erosion.cc b/milena/doc/examples/erosion.cc
new file mode 100644
index 0000000..890fd81
--- /dev/null
+++ b/milena/doc/examples/erosion.cc
@@ -0,0 +1,110 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// \file doc/examples/my_test.cc
+///
+/// Test on mln::morpho::hit_or_miss.
+
+# include <mln/core/image/image2d.hh>
+
+# include <mln/core/image/image_if.hh>
+# include <mln/core/image/sub_image.hh>
+# include <mln/core/alias/neighb2d.hh>
+# include <mln/core/var.hh>
+# include <mln/core/site_set/p_vaccess.hh>
+
+# include <mln/binarization/threshold.hh>
+# include <mln/morpho/hit_or_miss.hh>
+# include <mln/level/fill.hh>
+# include <mln/border/fill.hh>
+# include <mln/io/pbm/load.hh>
+# include <mln/io/pgm/load.hh>
+# include <mln/io/pbm/save.hh>
+# include <mln/io/pgm/save.hh>
+# include <mln/debug/println.hh>
+# include <mln/morpho/opening.hh>
+# include <mln/trait/value_.hh>
+# include <mln/value/int_u8.hh>
+# include <mln/level/paste.hh>
+# include <mln/labeling/blobs.hh>
+# include <mln/level/fill.hh>
+# include <mln/pw/all.hh>
+# include <mln/convert/to_fun.hh>
+# include <mln/geom/bbox.hh>
+
+
+void clean_lines(mln::image2d<bool>& in,
+ const mln::image2d<bool>& ima,
+ unsigned bbox_larger)
+{
+ using namespace mln;
+ using value::label8;
+
+ label8 nlabels;
+ image2d<label8> lbl = labeling::blobs(ima, c4(), nlabels);
+
+ for (unsigned i = nlabels; i > 0; --i)
+ {
+ level::paste(pw::cst(false)
+ | geom::bbox(lbl | (pw::value(lbl) == pw::cst(i))),//.to_larger(bbox_larger),
+ in);
+ }
+}
+
+
+int main(int argc, char*argv[])
+{
+ using namespace mln;
+ using value::int_u8;
+
+ if (argc < 2)
+ {
+ std::cout << argv[0] << " <image.pgm> <height> <width>" << std::endl;
+ return 1;
+ }
+
+ image2d<bool> in;
+ io::pbm::load(in, argv[1]);
+
+ unsigned h = atoi(argv[2]);
+ unsigned w = atoi(argv[3]);
+ unsigned n = atoi(argv[4]);
+
+ // Remove vertical lines.
+ win::rectangle2d vwin(h, w);
+ image2d<bool> vout = morpho::opening(in, vwin);
+ io::pbm::save(vout, "./vout.pbm");
+ clean_lines(in, vout, n);
+
+ // Remove Horizontal lines.
+ win::rectangle2d hwin(w, h);
+ image2d<bool> hout = morpho::opening(in, hwin);
+ io::pbm::save(hout, "./hout.pbm");
+ clean_lines(in, hout, n);
+
+ io::pbm::save(in, "./out.pbm");
+}
diff --git a/milena/doc/examples/graph.cc b/milena/doc/examples/graph.cc
new file mode 100644
index 0000000..08f0944
--- /dev/null
+++ b/milena/doc/examples/graph.cc
@@ -0,0 +1,116 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+
+#include <mln/essential/2d.hh>
+#include <mln/transform/influence_zone_geodesic.hh>
+#include <mln/make/graph.hh>
+#include <mln/util/graph.hh>
+#include <mln/util/line_graph.hh>
+#include <mln/debug/draw_graph.hh>
+#include <mln/debug/colorize.hh>
+
+template <typename G>
+struct gcolor_t : public mln::Function< gcolor_t<G> >
+{
+ typedef mln::value::rgb8 result;
+
+ mln::value::rgb8
+ operator()(const mln::util::vertex<G>& v) const
+ {
+ return mln::literal::cyan;
+ }
+
+ mln::value::rgb8
+ operator()(const mln::util::edge<G>& e) const
+ {
+ return mln::literal::magenta;
+ }
+
+};
+
+
+int main(int, char *argv[])
+{
+ using namespace mln;
+ using value::label16;
+ using value::rgb8;
+
+ image2d<bool> ima;
+ io::pbm::load(ima, argv[1]);
+ //logical::not_inplace(ima);
+
+ label16 nlabels;
+ image2d<label16> lbl = labeling::blobs(ima, c8(), nlabels);
+
+#ifndef NOUT
+ io::ppm::save(debug::colorize(rgb8(), lbl, nlabels), "01-lbl.ppm");
+#endif
+
+ image2d<label16> iz = transform::influence_zone_geodesic(lbl, c8(), mln_max(int));
+
+#ifndef NOUT
+ io::ppm::save(debug::colorize(rgb8(), iz, nlabels), "02-iz.ppm");
+#endif
+
+ util::graph g = make::graph(iz, nlabels);
+
+ // Compute the components center and use them as vertex.
+ //FIXME: Add fun::vertex2p
+ typedef fun::i2v::array<point2d> fv2p_t;
+ util::array<point2d> centers = labeling::compute(accu::center<point2d>(), iz, nlabels);
+ fv2p_t fv2p = convert::to<fv2p_t>(centers);
+
+ // Create a p_vertices.
+ p_vertices<util::graph, fv2p_t> pv(g, fv2p);
+
+#ifndef NOUT
+ image2d<rgb8> gima = level::convert(rgb8(), ima);
+ debug::draw_graph(gima, pv, gcolor_t<util::graph>());
+ io::ppm::save(gima, "03-graph.ppm");
+#endif
+
+ typedef util::line_graph<util::graph> LG;
+ LG lg(g);
+
+ // Find lines (sites) associated to edges in g.
+ typedef fun::i2v::array<p_line2d> i2e_t;
+ util::array<p_line2d> lines;
+ mln_edge_iter_(util::graph) e(g);
+ for_all(e)
+ lines.append(p_line2d(fv2p(e.v1()), fv2p(e.v2())));
+
+ // Map lines to vertices in lg.
+ p_vertices<LG, i2e_t> pvlg(lg, convert::to<i2e_t>(lines));
+/*
+#ifndef NOUT
+ image2d<rgb8> lgima = level::convert(rgb8(), ima);
+ debug::draw_graph(lgima, pvlg, gcolor_t<LG>());
+ io::ppm::save(gima, "04-line-graph.ppm");
+#endif
+*/
+}
--
1.5.6.5
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add a test on p_vaccess.
* doc/tutorial/examples/p_vaccess.cc: Fix missing update.
* tests/core/site_set/p_vaccess.cc: New.
* tests/core/site_set/Makefile.am: Update.
* mln/convert/to.hh (include): New: from_to.hh
so that user of convert::to does not have to also include
convert::from_to.
* mln/convert/impl/from_image_to_site_set.hh
(from_image_to_site_set_): New overload for s containing
pairs like (v,p).
Upgrade doc style.
* mln/morpho/tree/compute_parent.hh
(zfind_root): Move from impl::generic to internal.
doc/tutorial/examples/p_vaccess.cc | 2
mln/convert/impl/from_image_to_site_set.hh | 29 ++++++++----
mln/convert/to.hh | 7 ++-
mln/morpho/tree/compute_parent.hh | 32 ++++++-------
tests/core/site_set/Makefile.am | 2
tests/core/site_set/p_vaccess.cc | 67 +++++++++++++++++++++++++++++
6 files changed, 110 insertions(+), 29 deletions(-)
Index: tests/core/site_set/Makefile.am
--- tests/core/site_set/Makefile.am (revision 2959)
+++ tests/core/site_set/Makefile.am (working copy)
@@ -13,6 +13,7 @@
p_queue_fast \
p_set \
pset_if \
+ p_vaccess \
p_vertices
p_array_SOURCES = p_array.cc
@@ -24,6 +25,7 @@
p_queue_fast_SOURCES = p_queue_fast.cc
p_set_SOURCES = p_set.cc
pset_if_SOURCES = pset_if.cc
+p_vaccess_SOURCES = p_vaccess.cc
p_vertices_SOURCES = p_vertices.cc
p_edges_SOURCES = p_edges.cc
Index: tests/core/site_set/p_vaccess.cc
--- tests/core/site_set/p_vaccess.cc (revision 0)
+++ tests/core/site_set/p_vaccess.cc (revision 0)
@@ -0,0 +1,67 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// \file tests/core/site_set/p_vaccess.cc
+///
+/// Tests on mln::p_vaccess.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/site_set/p_array.hh>
+#include <mln/core/site_set/p_vaccess.hh>
+#include <mln/debug/println.hh>
+#include <mln/convert/to.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ unsigned char vals[] = { 1, 2, 1,
+ 2, 2, 3,
+ 3, 4, 1 };
+ image2d<unsigned char> ima = make::image2d(vals);
+
+ debug::println(ima);
+
+ typedef p_array<point2d> Arr;
+ typedef p_vaccess<unsigned char, Arr> S;
+
+ S s = convert::to<S>(ima);
+
+ mln_viter_(S::vset) v(s.values());
+ for_all(v)
+ {
+ if (s(v).nsites() == 0)
+ continue;
+ std::cout << int(v) << ": ";
+ mln_piter_(Arr) p(s(v));
+ for_all(p)
+ std::cout << p << ' ';
+ std::cout << std::endl;
+ }
+
+}
Index: doc/tutorial/examples/p_vaccess.cc
--- doc/tutorial/examples/p_vaccess.cc (revision 2959)
+++ doc/tutorial/examples/p_vaccess.cc (working copy)
@@ -40,7 +40,7 @@
{0, 1, 1, 0},
{1, 1, 0, 1}
};
- image2d<bool> ima = make::image2d(vals);
+ image2d<bool> ima = make::image(vals);
debug::println(ima);
unsigned n;
Index: mln/convert/to.hh
--- mln/convert/to.hh (revision 2959)
+++ mln/convert/to.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License version 2 as published by the
@@ -81,4 +81,7 @@
} // end of namespace mln
+# include <mln/convert/from_to.hh>
+
+
#endif // ! MLN_CONVERT_TO_HH
Index: mln/convert/impl/from_image_to_site_set.hh
--- mln/convert/impl/from_image_to_site_set.hh (revision 2959)
+++ mln/convert/impl/from_image_to_site_set.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,14 +28,13 @@
#ifndef MLN_CONVERT_IMPL_FROM_IMAGE_TO_SITE_SET_HH
# define MLN_CONVERT_IMPL_FROM_IMAGE_TO_SITE_SET_HH
-/*! \file mln/convert/from_to.hh
- *
- * \brief General conversion procedure from an image to a site_set.
- *
- * \todo Augment code + add checks.
- *
- * \todo Add (?) the case p_run-based -> site set.
- */
+/// \file mln/convert/from_to.hh
+///
+/// General conversion procedure from an image to a site_set.
+///
+/// \todo Augment code + add checks.
+///
+/// \todo Add (?) the case p_run-based -> site set.
# include <utility>
# include <mln/core/concept/image.hh>
@@ -125,6 +124,18 @@
}
+ template <typename I, typename P, typename S>
+ void
+ from_image_to_site_set_(const I& input, const Gpoint<P>&,
+ S& s, const std::pair< mln_value(I), P >&)
+ {
+ s.clear();
+ mln_fwd_piter(I) p(input.domain());
+ for_all(p)
+ s.insert(input(p), p);
+ }
+
+
// Facade.
template <typename I, typename S>
Index: mln/morpho/tree/compute_parent.hh
--- mln/morpho/tree/compute_parent.hh (revision 2959)
+++ mln/morpho/tree/compute_parent.hh (working copy)
@@ -101,24 +101,12 @@
}
- } // end of namespace mln::morpho::tree::internal
-
-
-
- // Implementations.
-
-
- namespace impl
- {
-
- namespace generic
- {
-
// Z-Find-Root.
template <typename T>
inline
- mln_psite(T) zfind_root(T& zpar, const mln_psite(T)& x)
+ mln_psite(T)
+ zfind_root(T& zpar, const mln_psite(T)& x)
{
mlc_equal(mln_value(T), mln_psite(T))::check();
if (zpar(x) == x)
@@ -127,7 +115,18 @@
return zpar(x) = zfind_root(zpar, zpar(x));
}
- // Compute-Parent.
+ } // end of namespace mln::morpho::tree::internal
+
+
+
+ // Implementations.
+
+
+ namespace impl
+ {
+
+ namespace generic
+ {
template <typename I, typename N, typename S>
inline
@@ -172,7 +171,7 @@
if (f.domain().has(n) && deja_vu(n))
{
// Do-Union.
- P r = zfind_root(zpar, n);
+ P r = internal::zfind_root(zpar, n);
if (r != p)
{
parent(r) = p;
@@ -202,7 +201,6 @@
} // end of namespace mln::morpho::tree::impl
-
// Dispatch.
namespace internal