Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
December 2008
- 12 participants
- 201 discussions
* doc/examples/graph.cc: update example. Improve graph output.
* mln/core/site_set/p_line2d.hh: add to_vec().
* mln/debug/draw_graph.hh: Add a specialization for line_graph.
* mln/labeling/relabel.hh: Add new overloads.
* mln/util/line_graph.hh: add graph().
* doc/tutorial/outputs/labeling-compute-1,
* doc/tutorial/outputs/labeling-compute.txt: update reference output
files for tutorial.
* mln/fun/l2l/relabel.hh: fix wrong namespace closure.
* tests/convert/Makefile.am: comment a test.
* tests/morpho/tree/Makefile.am: rename a test.
* tests/unit_test/Makefile.am,
* tests/unit_test/mln_accu_lor.cc,
* tests/unit_test/mln_accu_lor_basic.cc,
* tests/unit_test/mln_core_internal_image_if_base.cc,
* tests/unit_test/mln_level_domain.cc,
* tests/unit_test/mln_morpho_general.cc,
* tests/unit_test/mln_morpho_tree_compute_attribute_image.cc,
* tests/unit_test/mln_util_internal_edge_impl.cc,
* tests/unit_test/mln_util_internal_graph_edge_impl.cc,
* tests/unit_test/mln_util_internal_graph_vertex_impl.cc,
* tests/unit_test/mln_util_internal_vertex_impl.cc: update unit tests.
* Makefile.am: uncomment targets.
* tests/util/Makefile.am: fix wrong target name.
---
milena/ChangeLog | 40 ++++++
milena/Makefile.am | 6 +-
milena/doc/examples/graph.cc | 136 +++++++++++++++++---
milena/doc/tutorial/outputs/labeling-compute-1 | Bin 206 -> 0 bytes
milena/doc/tutorial/outputs/labeling-compute.txt | 2 -
milena/mln/core/site_set/p_line2d.hh | 14 ++
milena/mln/debug/draw_graph.hh | 56 +++++++-
milena/mln/fun/l2l/relabel.hh | 8 +-
milena/mln/labeling/relabel.hh | 121 ++++++++++++++++--
milena/mln/util/line_graph.hh | 11 ++
milena/tests/convert/Makefile.am | 2 +-
milena/tests/morpho/tree/Makefile.am | 4 +-
milena/tests/unit_test/Makefile.am | 20 ++-
milena/tests/unit_test/mln_accu_lor.cc | 8 +
milena/tests/unit_test/mln_accu_lor_basic.cc | 8 +
.../unit_test/mln_core_internal_image_if_base.cc | 8 -
milena/tests/unit_test/mln_level_domain.cc | 8 -
milena/tests/unit_test/mln_morpho_general.cc | 8 +
.../mln_morpho_tree_compute_attribute_image.cc | 8 +
.../tests/unit_test/mln_util_internal_edge_impl.cc | 8 +
.../unit_test/mln_util_internal_graph_edge_impl.cc | 8 -
.../mln_util_internal_graph_vertex_impl.cc | 8 -
.../unit_test/mln_util_internal_vertex_impl.cc | 8 +
milena/tests/util/Makefile.am | 4 +-
24 files changed, 414 insertions(+), 90 deletions(-)
delete mode 100644 milena/doc/tutorial/outputs/labeling-compute-1
create mode 100644 milena/tests/unit_test/mln_accu_lor.cc
create mode 100644 milena/tests/unit_test/mln_accu_lor_basic.cc
delete mode 100644 milena/tests/unit_test/mln_core_internal_image_if_base.cc
delete mode 100644 milena/tests/unit_test/mln_level_domain.cc
create mode 100644 milena/tests/unit_test/mln_morpho_general.cc
create mode 100644 milena/tests/unit_test/mln_morpho_tree_compute_attribute_image.cc
create mode 100644 milena/tests/unit_test/mln_util_internal_edge_impl.cc
delete mode 100644 milena/tests/unit_test/mln_util_internal_graph_edge_impl.cc
delete mode 100644 milena/tests/unit_test/mln_util_internal_graph_vertex_impl.cc
create mode 100644 milena/tests/unit_test/mln_util_internal_vertex_impl.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index f7a76b9..e7eaf84 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,43 @@
+2008-12-03 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Various small fixes.
+
+ * doc/examples/graph.cc: update example. Improve graph output.
+
+ * mln/core/site_set/p_line2d.hh: add to_vec().
+
+ * mln/debug/draw_graph.hh: Add a specialization for line_graph.
+
+ * mln/labeling/relabel.hh: Add new overloads.
+
+ * mln/util/line_graph.hh: add graph().
+
+ * doc/tutorial/outputs/labeling-compute-1,
+ * doc/tutorial/outputs/labeling-compute.txt: update reference output
+ files for tutorial.
+
+ * mln/fun/l2l/relabel.hh: fix wrong namespace closure.
+
+ * tests/convert/Makefile.am: comment a test.
+
+ * tests/morpho/tree/Makefile.am: rename a test.
+
+ * tests/unit_test/Makefile.am,
+ * tests/unit_test/mln_accu_lor.cc,
+ * tests/unit_test/mln_accu_lor_basic.cc,
+ * tests/unit_test/mln_core_internal_image_if_base.cc,
+ * tests/unit_test/mln_level_domain.cc,
+ * tests/unit_test/mln_morpho_general.cc,
+ * tests/unit_test/mln_morpho_tree_compute_attribute_image.cc,
+ * tests/unit_test/mln_util_internal_edge_impl.cc,
+ * tests/unit_test/mln_util_internal_graph_edge_impl.cc,
+ * tests/unit_test/mln_util_internal_graph_vertex_impl.cc,
+ * tests/unit_test/mln_util_internal_vertex_impl.cc: update unit tests.
+
+ * Makefile.am: Uncomment targets.
+
+ * tests/util/Makefile.am: fix wrong target name.
+
2008-12-03 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add front computation of distance and influence zone.
diff --git a/milena/Makefile.am b/milena/Makefile.am
index 61e797e..90cc910 100644
--- a/milena/Makefile.am
+++ b/milena/Makefile.am
@@ -2,11 +2,11 @@
##FIXME
SUBDIRS = \
-## mesh \
+ mesh \
doc \
tests
-## tools \
-## apps
+ tools \
+ apps
.PHONY: doc
doc:
diff --git a/milena/doc/examples/graph.cc b/milena/doc/examples/graph.cc
index 08f0944..2330c29 100644
--- a/milena/doc/examples/graph.cc
+++ b/milena/doc/examples/graph.cc
@@ -25,7 +25,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-
+# include <cmath>
#include <mln/essential/2d.hh>
#include <mln/transform/influence_zone_geodesic.hh>
#include <mln/make/graph.hh>
@@ -34,35 +34,109 @@
#include <mln/debug/draw_graph.hh>
#include <mln/debug/colorize.hh>
-template <typename G>
-struct gcolor_t : public mln::Function< gcolor_t<G> >
+
+
+struct gcolor_t : public mln::Function< gcolor_t >
{
typedef mln::value::rgb8 result;
+ template <typename G>
mln::value::rgb8
- operator()(const mln::util::vertex<G>& v) const
+ operator()(const mln::util::vertex<G>&) const
{
return mln::literal::cyan;
}
+ template <typename G>
mln::value::rgb8
- operator()(const mln::util::edge<G>& e) const
+ operator()(const mln::util::edge<G>&) const
{
return mln::literal::magenta;
}
};
+struct gcolorarr_t : public mln::Function< gcolorarr_t >
+{
+ typedef mln::value::rgb8 result;
+
+ gcolorarr_t(unsigned n, const mln::value::rgb8& val)
+ : v_(n, val)
+ {
+ }
+
+ template <typename G>
+ const mln::value::rgb8&
+ operator()(const mln::util::vertex<G>& v) const
+ {
+ return v_[v.id()];
+ }
+
+ template <typename G>
+ const mln::value::rgb8&
+ operator()(const mln::util::edge<G>& e) const
+ {
+ return v_[e.id()];
+ }
+
+ template <typename G>
+ mln::value::rgb8&
+ operator()(const mln::util::vertex<G>& v)
+ {
+ return v_[v.id()];
+ }
+
+ template <typename G>
+ mln::value::rgb8&
+ operator()(const mln::util::edge<G>& e)
+ {
+ return v_[e.id()];
+ }
+
+ std::vector<mln::value::rgb8> v_;
+};
-int main(int, char *argv[])
+
+
+
+template <typename P>
+struct lg_vertex_values : public mln::Function_p2v< lg_vertex_values<P> >
+{
+ typedef float result;
+
+ float operator()(const P& p) const
+ {
+ mln::algebra::vec<2,float> v;
+ v[0] = 0;
+ v[1] = 1;
+ float norm = mln::math::sqrt(std::pow(p.to_vec()[0], 2)
+ + std::pow(p.to_vec()[1], 2));
+ // FIXME: missing proxy_impl for point and line2d?
+ float res = (v * p.to_vec()) / norm;
+ return res;
+ }
+
+};
+
+
+
+int main(int argc, char *argv[])
{
using namespace mln;
using value::label16;
using value::rgb8;
+ if (argc < 2)
+ {
+ std::cout << "Usage: " << argv[0] << " <image> <max cosinus>" << std::endl;
+ return 1;
+ }
+
+ float max_cos = atof(argv[2]);
+
image2d<bool> ima;
io::pbm::load(ima, argv[1]);
- //logical::not_inplace(ima);
+ logical::not_inplace(ima);
label16 nlabels;
image2d<label16> lbl = labeling::blobs(ima, c8(), nlabels);
@@ -77,40 +151,66 @@ int main(int, char *argv[])
io::ppm::save(debug::colorize(rgb8(), iz, nlabels), "02-iz.ppm");
#endif
- util::graph g = make::graph(iz, nlabels);
+ typedef util::graph G;
+ G g = make::graph(iz | (pw::value(iz) != pw::cst(0u)), nlabels);
- // Compute the components center and use them as vertex.
+ // Compute the component centers 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);
+ p_vertices<G, fv2p_t> pv(g, fv2p);
#ifndef NOUT
image2d<rgb8> gima = level::convert(rgb8(), ima);
- debug::draw_graph(gima, pv, gcolor_t<util::graph>());
+ debug::draw_graph(gima, pv, gcolor_t(), gcolor_t());
io::ppm::save(gima, "03-graph.ppm");
#endif
- typedef util::line_graph<util::graph> LG;
+ typedef util::line_graph<G> 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);
+ mln_edge_iter_(G) 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));
-/*
+ typedef p_vertices<LG, i2e_t> pvlg_t;
+ pvlg_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");
+ debug::draw_graph(lgima, pvlg, gcolor_t(), gcolor_t());
+ io::ppm::save(lgima, "04-line-graph.ppm");
+#endif
+
+ // Construct an image from a p_edges and a function mapping
+ // lines to angles.
+ typedef lg_vertex_values<p_line2d> lgv2v_t;
+ lgv2v_t lgv2v;
+
+ mln_VAR(lg_ima, lgv2v | pvlg);
+
+
+ // Colorize lg's vertices (i.e. g's edges) according their angle.
+ //
+ // literal::olive: cos(angle) < max_cos and cos(angle) > - max_cos
+ // literal::red: cos(angle) > max_cos or cos(angle) < - max_cos
+ gcolorarr_t ecolor(pvlg.nsites(), literal::olive);
+ mln_piter_(lg_ima_t) p(lg_ima.domain());
+ for_all (p)
+ if ((lg_ima(p) > max_cos) || (lg_ima(p) < - max_cos))
+ ecolor(p.element()) = literal::red;
+
+
+#ifndef NOUT
+ image2d<rgb8> lgima2 = level::convert(rgb8(), ima);
+ debug::draw_graph(lgima2, pvlg, gcolor_t(), ecolor);
+ io::ppm::save(lgima2, "05-line-graph-cleanup.ppm");
#endif
-*/
}
diff --git a/milena/doc/tutorial/outputs/labeling-compute-1 b/milena/doc/tutorial/outputs/labeling-compute-1
deleted file mode 100644
index 7bfa0e4c45344b8acdbefee7347dd890f15031a2..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 206
zcmWGA<5E^|Pt8j$N-RlDQAny(@XgFg%}Z1;)H6^}$S5f(u+rDh2Z`wA6s4r<r50qC
zB<iIV0d=_sc!oGC1f>?ICKe@UC?w{kD7d7SrRL-p<fi78DEK5M<pT}PFRE0~@CkBp
z)#Nf&Fyk^ZHRWPpU{F1m4n#l(1fX$Y!XR3Cra2G+8Idtz5H5rb<N^^y3Mc{r0K)t+
A#Q*>R
diff --git a/milena/doc/tutorial/outputs/labeling-compute.txt b/milena/doc/tutorial/outputs/labeling-compute.txt
index 8108b32..174807d 100644
--- a/milena/doc/tutorial/outputs/labeling-compute.txt
+++ b/milena/doc/tutorial/outputs/labeling-compute.txt
@@ -1,5 +1,3 @@
-// \{
[(0, 1)..(1, 2)]
[(3, 0)..(5, 1)]
[(3, 2)..(4, 4)]
-// \}
diff --git a/milena/mln/core/site_set/p_line2d.hh b/milena/mln/core/site_set/p_line2d.hh
index f521e3a..fcfb656 100644
--- a/milena/mln/core/site_set/p_line2d.hh
+++ b/milena/mln/core/site_set/p_line2d.hh
@@ -135,6 +135,9 @@ namespace mln
/// Return the corresponding std::vector of points.
const std::vector<point2d>& std_vector() const;
+ // Return the corresponding algebra::vec.
+ algebra::vec<2, float> to_vec() const;
+
protected:
p_array<point2d> arr_;
@@ -271,6 +274,17 @@ namespace mln
return arr_.std_vector();
}
+ // FIXME: make it more generic?
+ inline
+ algebra::vec<2, float>
+ p_line2d::to_vec() const
+ {
+ algebra::vec<2, float> res;
+ res[0] = end().row() - begin().row();
+ res[1] = end().col() - begin().col();
+ return res;
+ }
+
inline
const point2d&
p_line2d::operator[](unsigned i) const
diff --git a/milena/mln/debug/draw_graph.hh b/milena/mln/debug/draw_graph.hh
index f163923..1febe63 100644
--- a/milena/mln/debug/draw_graph.hh
+++ b/milena/mln/debug/draw_graph.hh
@@ -37,6 +37,7 @@
# include <mln/core/site_set/p_vertices.hh>
# include <mln/core/site_set/p_edges.hh>
+# include <mln/util/line_graph.hh>
# include <mln/draw/line.hh>
# include <mln/level/fill.hh>
@@ -62,10 +63,18 @@ namespace mln
mln_value(I) vertex_v, mln_value(I) edge_v);
- template <typename I, typename G, typename F, typename E>
+ template <typename I, typename G, typename F, typename V, typename E>
void
draw_graph(Image<I>& ima,
- const p_vertices<G, F>& pv, const Function<E>& fcolor);
+ const p_vertices<G, F>& pv,
+ const Function<V>& vcolor, const Function<E>& ecolor_);
+
+ template <typename I, typename G, typename F, typename V, typename E>
+ inline
+ void
+ draw_graph(Image<I>& ima,
+ const p_vertices<util::line_graph<G>, F>& pv,
+ const Function<V>& vcolor_, const Function<E>& ecolor_);
# ifndef MLN_INCLUDE_ONLY
@@ -98,26 +107,59 @@ namespace mln
}
// FIXME: Refactor + be more restrictive on the function type.
- template <typename I, typename G, typename F, typename E>
+ template <typename I, typename G, typename F, typename V, typename E>
inline
void
draw_graph(Image<I>& ima,
- const p_vertices<G, F>& pv, const Function<E>& fcolor_)
+ const p_vertices<G, F>& pv,
+ const Function<V>& vcolor_, const Function<E>& ecolor_)
{
- const E& fcolor = exact(fcolor_);
+ const V& vcolor = exact(vcolor_);
+ const E& ecolor = exact(ecolor_);
// Draw edges.
const G& g = pv.graph();
typedef p_vertices<G, F> pv_t;
mln_edge_iter(G) ei(g);
for_all(ei)
- draw::line(exact(ima), pv(ei.v1()), pv(ei.v2()), fcolor(ei));
+ draw::line(exact(ima), pv(ei.v1()), pv(ei.v2()), ecolor(ei.subj_()));
// Draw vertices.
mln_piter(pv_t) p(pv);
for_all(p)
if (exact(ima).has(p))
- exact(ima)(p) = fcolor(p.element());
+ exact(ima)(p) = vcolor(p.element());
+ }
+
+ // FIXME: Refactor + be more restrictive on the function type.
+ template <typename I, typename G, typename F, typename V, typename E>
+ inline
+ void
+ draw_graph(Image<I>& ima,
+ const p_vertices<util::line_graph<G>, F>& pv,
+ const Function<V>& vcolor_, const Function<E>& ecolor_)
+ {
+ const V& vcolor = exact(vcolor_);
+ const E& ecolor = exact(ecolor_);
+
+ typedef util::line_graph<G> LG;
+
+ const LG& lg = pv.graph();
+ const G& g = lg.graph();
+ typedef p_vertices<LG, F> pv_t;
+ mln_vertex_iter(LG) vi(lg);
+ for_all(vi)
+ {
+ p_line2d l = pv(vi.id());
+ // Draw edges (Line graph vertices).
+ draw::line(exact(ima), l.begin(), l.end(), ecolor(vi.subj_()));
+
+ // Draw vertices (graph vertices).
+ if (exact(ima).has(l.begin()))
+ exact(ima)(l.begin()) = vcolor(g.vertex(g.edge(vi).v1()));
+ if (exact(ima).has(l.end()))
+ exact(ima)(l.end()) = vcolor(g.vertex(g.edge(vi).v2()));
+ }
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/fun/l2l/relabel.hh b/milena/mln/fun/l2l/relabel.hh
index f4cd50a..fd28f68 100644
--- a/milena/mln/fun/l2l/relabel.hh
+++ b/milena/mln/fun/l2l/relabel.hh
@@ -110,7 +110,7 @@ namespace mln
};
- } // end of namespace mln::fun::i2v
+ } // end of namespace mln::fun::l2l
} // end of namespace mln::fun
@@ -196,14 +196,12 @@ namespace mln
mlc_converts_to(L, unsigned)::check();
}
-
-# endif // ! MLN_INCLUDE_ONLY
-
-
} // end of namespace mln::fun::l2l
} // end of namespace mln::fun
+# endif // ! MLN_INCLUDE_ONLY
+
} // end of namespace mln
diff --git a/milena/mln/labeling/relabel.hh b/milena/mln/labeling/relabel.hh
index 841cd1c..d906a38 100644
--- a/milena/mln/labeling/relabel.hh
+++ b/milena/mln/labeling/relabel.hh
@@ -49,6 +49,21 @@ namespace mln
/// \input[in] label the labeled image.
/// \input[in] nlabels the number of labels in \p label.
/// \input[out] new_nlabels the number of labels after relabeling.
+ /// \input[in] f function returning whether a label must be replaced
+ /// by the background.
+ ///
+ /// \return the relabeled image.
+ template <typename I, typename F>
+ mln_concrete(I)
+ relabel(const Image<I>& label,
+ const mln_value(I)& nlabels,
+ mln_value(I)& new_nlabels,
+ const Function_l2b<F>& fl2b);
+
+ /// Remove components and relabel a labeled image.
+ /// \input[in] label the labeled image.
+ /// \input[in] nlabels the number of labels in \p label.
+ /// \input[out] new_nlabels the number of labels after relabeling.
/// \input[in] f function returning the new component id for each pixel
/// value.
///
@@ -58,7 +73,19 @@ namespace mln
relabel(const Image<I>& label,
const mln_value(I)& nlabels,
mln_value(I)& new_nlabels,
- const Function_l2b<F>& fl2b);
+ const Function_l2l<F>& fl2l);
+
+ /// Remove components and relabel a labeled image inplace.
+ /// \input[in, out] label the labeled image.
+ /// \input[in, out] nlabels the number of labels in \p label.
+ /// \input[in] f function returning whether a label must be replaced
+ /// by the background.
+ ///
+ template <typename I, typename F>
+ void
+ relabel_inplace(Image<I>& label,
+ mln_value(I)& nlabels,
+ const Function_l2b<F>& fl2b);
/// Remove components and relabel a labeled image inplace.
/// \input[in, out] label the labeled image.
@@ -70,12 +97,51 @@ namespace mln
void
relabel_inplace(Image<I>& label,
mln_value(I)& nlabels,
- const Function_l2b<F>& fl2b);
+ const Function_l2l<F>& fl2l);
# ifndef MLN_INCLUDE_ONLY
+
+ namespace internal
+ {
+
+ template <typename I, typename F>
+ void
+ relabel_tests(const Image<I>& label,
+ const mln_value(I)& nlabels,
+ mln_value(I)& new_nlabels,
+ const Function<F>& f)
+ {
+ // FIXME: we may want to check that it is exactly a label.
+ mlc_is_a(mln_value(I), mln::value::Symbolic)::check();
+ mln_precondition(exact(label).has_data());
+ (void) label;
+ (void) nlabels;
+ (void) new_nlabels;
+ (void) f;
+ }
+
+ template <typename I, typename F>
+ inline
+ void
+ relabel_inplace_tests(Image<I>& label,
+ mln_value(I)& nlabels,
+ const Function<F>& f)
+ {
+ // FIXME: we may want to check that it is exactly a label.
+ mlc_is_a(mln_value(I), mln::value::Symbolic)::check();
+ mln_precondition(exact(label).has_data());
+ (void) label;
+ (void) nlabels;
+ (void) f;
+ }
+
+ } // end of namespace mln::labeling::internal
+
+
+
template <typename I, typename F>
inline
mln_concrete(I)
@@ -86,12 +152,30 @@ namespace mln
{
trace::entering("labeling::relabel");
- // FIXME: we may want to check that it is exactly a label.
- mlc_is_a(mln_value(I), mln::value::Symbolic)::check();
- mln_precondition(exact(label).has_data());
+ internal::relabel_tests(label, nlabels, new_nlabels, fl2b);
typedef fun::l2l::relabel<mln_value(I)> fl2l_t;
fl2l_t fl2l = make::relabelfun(fl2b, nlabels, new_nlabels);
+ mln_concrete(I) output = relabel(label, nlabels, new_nlabels, fl2b);
+
+ trace::exiting("labeling::relabel");
+ return output;
+ }
+
+
+
+ template <typename I, typename F>
+ inline
+ mln_concrete(I)
+ relabel(const Image<I>& label,
+ const mln_value(I)& nlabels,
+ mln_value(I)& new_nlabels,
+ const Function_l2l<F>& fl2l)
+ {
+ trace::entering("labeling::relabel");
+
+ internal::relabel_tests(label, nlabels, new_nlabels, fl2l);
+
mln_concrete(I) output = level::transform(label, fl2l);
trace::exiting("labeling::relabel");
@@ -99,6 +183,7 @@ namespace mln
}
+
template <typename I, typename F>
inline
void
@@ -106,17 +191,33 @@ namespace mln
mln_value(I)& nlabels,
const Function_l2b<F>& fl2b)
{
- trace::entering("labeling::relabel");
+ trace::entering("labeling::relabel_inplace");
- // FIXME: we may want to check that it is exactly a label.
- mlc_is_a(mln_value(I), mln::value::Symbolic)::check();
- mln_precondition(exact(label).has_data());
+ internal::relabel_inplace_tests(label, nlabels, fl2b);
typedef fun::l2l::relabel<mln_value(I)> fl2l_t;
fl2l_t fl2l = make::relabelfun(fl2b, nlabels, nlabels);
+ relabel_inplace(label, nlabels, fl2l);
+
+ trace::exiting("labeling::relabel_inplace");
+ }
+
+
+
+ template <typename I, typename F>
+ inline
+ void
+ relabel_inplace(Image<I>& label,
+ mln_value(I)& nlabels,
+ const Function_l2l<F>& fl2l)
+ {
+ trace::entering("labeling::relabel_inplace");
+
+ internal::relabel_inplace_tests(label, nlabels, fl2l);
+
level::transform_inplace(label, fl2l);
- trace::exiting("labeling::relabel");
+ trace::exiting("labeling::relabel_inplace");
}
diff --git a/milena/mln/util/line_graph.hh b/milena/mln/util/line_graph.hh
index 6ae1c5b..ae49cbc 100644
--- a/milena/mln/util/line_graph.hh
+++ b/milena/mln/util/line_graph.hh
@@ -213,6 +213,9 @@ namespace mln
/// Return true if g and *this have the same graph_id.
template <typename G2>
bool is_subgraph_of(const G2& g) const;
+
+ /// Return the underlying graph
+ const G& graph() const;
/// \}
protected:
@@ -463,6 +466,14 @@ namespace mln
return g.id() == this->id();
}
+ template <typename G>
+ inline
+ const G&
+ line_graph<G>::graph() const
+ {
+ return this->data_->g_;
+ }
+
// FIXME: move to graph_base
template <typename G>
inline
diff --git a/milena/tests/convert/Makefile.am b/milena/tests/convert/Makefile.am
index 252e377..7b8e9dc 100644
--- a/milena/tests/convert/Makefile.am
+++ b/milena/tests/convert/Makefile.am
@@ -13,7 +13,7 @@ check_PROGRAMS = \
to_image_SOURCES = to_image.cc
to_p_array_SOURCES = to_p_array.cc
to_p_set_SOURCES = to_p_set.cc
-to_tiles_SOURCES = to_tiles.cc
+#to_tiles_SOURCES = to_tiles.cc
to_window_SOURCES = to_window.cc
TESTS = $(check_PROGRAMS)
diff --git a/milena/tests/morpho/tree/Makefile.am b/milena/tests/morpho/tree/Makefile.am
index 4d2d285..7a51686 100644
--- a/milena/tests/morpho/tree/Makefile.am
+++ b/milena/tests/morpho/tree/Makefile.am
@@ -4,12 +4,12 @@ include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
compute_attribute_image \
- compute_tree \
+ compute_parent \
data \
max
compute_attribute_image_SOURCES = compute_attribute_image.cc
-compute_tree_SOURCES = compute_tree.cc
+compute_parent_SOURCES = compute_parent.cc
data_SOURCES = data.cc
max_SOURCES = max.cc
diff --git a/milena/tests/unit_test/Makefile.am b/milena/tests/unit_test/Makefile.am
index 3c30dc5..469cce2 100644
--- a/milena/tests/unit_test/Makefile.am
+++ b/milena/tests/unit_test/Makefile.am
@@ -74,14 +74,14 @@ mln_util_set\
mln_util_tree_to_image\
mln_util_lemmings\
mln_util_greater_point\
-mln_util_internal_graph_edge_impl\
mln_util_internal_graph_iter_base\
mln_util_internal_boost_graph_access\
mln_util_internal_boost_graph_structure\
mln_util_internal_graph_iter\
mln_util_internal_graph_nbh_iter\
+mln_util_internal_vertex_impl\
+mln_util_internal_edge_impl\
mln_util_internal_graph_base\
-mln_util_internal_graph_vertex_impl\
mln_util_internal_boost_graph\
mln_util_internal_graph_nbh_iter_base\
mln_util_internal_boost_graph_property\
@@ -319,6 +319,7 @@ mln_value_essential\
mln_accu_tuple\
mln_accu_min_h\
mln_accu_max\
+mln_accu_lor\
mln_accu_rank\
mln_accu_transform_stop\
mln_accu_maj_h\
@@ -348,6 +349,7 @@ mln_accu_min\
mln_accu_transform_directional\
mln_accu_compute\
mln_accu_mean\
+mln_accu_lor_basic\
mln_accu_transform_diagonal\
mln_accu_nil\
mln_accu_bbox\
@@ -373,7 +375,6 @@ mln_level_fill_with_image\
mln_level_transform\
mln_level_fill_with_value\
mln_level_stretch\
-mln_level_domain\
mln_level_was_median\
mln_level_compute\
mln_level_convert\
@@ -563,6 +564,7 @@ mln_morpho_line_gradient\
mln_morpho_hit_or_miss\
mln_morpho_closing_height\
mln_morpho_plus\
+mln_morpho_general\
mln_morpho_erosion_fast\
mln_morpho_internal_elementary\
mln_morpho_contrast\
@@ -584,6 +586,7 @@ mln_morpho_tree_compute_parent\
mln_morpho_tree_all\
mln_morpho_tree_utils\
mln_morpho_tree_data\
+mln_morpho_tree_compute_attribute_image\
mln_morpho_opening_area_on_vertices\
mln_morpho_min\
mln_morpho_closing\
@@ -703,7 +706,6 @@ mln_core_internal_exact\
mln_core_internal_p_complex_piter_base\
mln_core_internal_pixel_iterator_base\
mln_core_internal_classical_window_base\
-mln_core_internal_image_if_base\
mln_core_internal_data\
mln_core_internal_force_exact\
mln_core_internal_image_base\
@@ -1079,14 +1081,14 @@ mln_util_set_SOURCES = mln_util_set.cc
mln_util_tree_to_image_SOURCES = mln_util_tree_to_image.cc
mln_util_lemmings_SOURCES = mln_util_lemmings.cc
mln_util_greater_point_SOURCES = mln_util_greater_point.cc
-mln_util_internal_graph_edge_impl_SOURCES = mln_util_internal_graph_edge_impl.cc
mln_util_internal_graph_iter_base_SOURCES = mln_util_internal_graph_iter_base.cc
mln_util_internal_boost_graph_access_SOURCES = mln_util_internal_boost_graph_access.cc
mln_util_internal_boost_graph_structure_SOURCES = mln_util_internal_boost_graph_structure.cc
mln_util_internal_graph_iter_SOURCES = mln_util_internal_graph_iter.cc
mln_util_internal_graph_nbh_iter_SOURCES = mln_util_internal_graph_nbh_iter.cc
+mln_util_internal_vertex_impl_SOURCES = mln_util_internal_vertex_impl.cc
+mln_util_internal_edge_impl_SOURCES = mln_util_internal_edge_impl.cc
mln_util_internal_graph_base_SOURCES = mln_util_internal_graph_base.cc
-mln_util_internal_graph_vertex_impl_SOURCES = mln_util_internal_graph_vertex_impl.cc
mln_util_internal_boost_graph_SOURCES = mln_util_internal_boost_graph.cc
mln_util_internal_graph_nbh_iter_base_SOURCES = mln_util_internal_graph_nbh_iter_base.cc
mln_util_internal_boost_graph_property_SOURCES = mln_util_internal_boost_graph_property.cc
@@ -1324,6 +1326,7 @@ mln_value_essential_SOURCES = mln_value_essential.cc
mln_accu_tuple_SOURCES = mln_accu_tuple.cc
mln_accu_min_h_SOURCES = mln_accu_min_h.cc
mln_accu_max_SOURCES = mln_accu_max.cc
+mln_accu_lor_SOURCES = mln_accu_lor.cc
mln_accu_rank_SOURCES = mln_accu_rank.cc
mln_accu_transform_stop_SOURCES = mln_accu_transform_stop.cc
mln_accu_maj_h_SOURCES = mln_accu_maj_h.cc
@@ -1353,6 +1356,7 @@ mln_accu_min_SOURCES = mln_accu_min.cc
mln_accu_transform_directional_SOURCES = mln_accu_transform_directional.cc
mln_accu_compute_SOURCES = mln_accu_compute.cc
mln_accu_mean_SOURCES = mln_accu_mean.cc
+mln_accu_lor_basic_SOURCES = mln_accu_lor_basic.cc
mln_accu_transform_diagonal_SOURCES = mln_accu_transform_diagonal.cc
mln_accu_nil_SOURCES = mln_accu_nil.cc
mln_accu_bbox_SOURCES = mln_accu_bbox.cc
@@ -1378,7 +1382,6 @@ mln_level_fill_with_image_SOURCES = mln_level_fill_with_image.cc
mln_level_transform_SOURCES = mln_level_transform.cc
mln_level_fill_with_value_SOURCES = mln_level_fill_with_value.cc
mln_level_stretch_SOURCES = mln_level_stretch.cc
-mln_level_domain_SOURCES = mln_level_domain.cc
mln_level_was_median_SOURCES = mln_level_was_median.cc
mln_level_compute_SOURCES = mln_level_compute.cc
mln_level_convert_SOURCES = mln_level_convert.cc
@@ -1568,6 +1571,7 @@ mln_morpho_line_gradient_SOURCES = mln_morpho_line_gradient.cc
mln_morpho_hit_or_miss_SOURCES = mln_morpho_hit_or_miss.cc
mln_morpho_closing_height_SOURCES = mln_morpho_closing_height.cc
mln_morpho_plus_SOURCES = mln_morpho_plus.cc
+mln_morpho_general_SOURCES = mln_morpho_general.cc
mln_morpho_erosion_fast_SOURCES = mln_morpho_erosion_fast.cc
mln_morpho_internal_elementary_SOURCES = mln_morpho_internal_elementary.cc
mln_morpho_contrast_SOURCES = mln_morpho_contrast.cc
@@ -1589,6 +1593,7 @@ mln_morpho_tree_compute_parent_SOURCES = mln_morpho_tree_compute_parent.cc
mln_morpho_tree_all_SOURCES = mln_morpho_tree_all.cc
mln_morpho_tree_utils_SOURCES = mln_morpho_tree_utils.cc
mln_morpho_tree_data_SOURCES = mln_morpho_tree_data.cc
+mln_morpho_tree_compute_attribute_image_SOURCES = mln_morpho_tree_compute_attribute_image.cc
mln_morpho_opening_area_on_vertices_SOURCES = mln_morpho_opening_area_on_vertices.cc
mln_morpho_min_SOURCES = mln_morpho_min.cc
mln_morpho_closing_SOURCES = mln_morpho_closing.cc
@@ -1708,7 +1713,6 @@ mln_core_internal_exact_SOURCES = mln_core_internal_exact.cc
mln_core_internal_p_complex_piter_base_SOURCES = mln_core_internal_p_complex_piter_base.cc
mln_core_internal_pixel_iterator_base_SOURCES = mln_core_internal_pixel_iterator_base.cc
mln_core_internal_classical_window_base_SOURCES = mln_core_internal_classical_window_base.cc
-mln_core_internal_image_if_base_SOURCES = mln_core_internal_image_if_base.cc
mln_core_internal_data_SOURCES = mln_core_internal_data.cc
mln_core_internal_force_exact_SOURCES = mln_core_internal_force_exact.cc
mln_core_internal_image_base_SOURCES = mln_core_internal_image_base.cc
diff --git a/milena/tests/unit_test/mln_accu_lor.cc b/milena/tests/unit_test/mln_accu_lor.cc
new file mode 100644
index 0000000..19686e0
--- /dev/null
+++ b/milena/tests/unit_test/mln_accu_lor.cc
@@ -0,0 +1,8 @@
+// Unit test for mln/accu/lor.hh.
+// Generated file, do not modify.
+#include <mln/accu/lor.hh>
+
+int main()
+{
+ // Nothing.
+}
diff --git a/milena/tests/unit_test/mln_accu_lor_basic.cc b/milena/tests/unit_test/mln_accu_lor_basic.cc
new file mode 100644
index 0000000..6bb942a
--- /dev/null
+++ b/milena/tests/unit_test/mln_accu_lor_basic.cc
@@ -0,0 +1,8 @@
+// Unit test for mln/accu/lor_basic.hh.
+// Generated file, do not modify.
+#include <mln/accu/lor_basic.hh>
+
+int main()
+{
+ // Nothing.
+}
diff --git a/milena/tests/unit_test/mln_core_internal_image_if_base.cc b/milena/tests/unit_test/mln_core_internal_image_if_base.cc
deleted file mode 100644
index b39ce2b..0000000
--- a/milena/tests/unit_test/mln_core_internal_image_if_base.cc
+++ /dev/null
@@ -1,8 +0,0 @@
-// Unit test for mln/core/internal/image_if_base.hh.
-// Generated file, do not modify.
-#include <mln/core/internal/image_if_base.hh>
-
-int main()
-{
- // Nothing.
-}
diff --git a/milena/tests/unit_test/mln_level_domain.cc b/milena/tests/unit_test/mln_level_domain.cc
deleted file mode 100644
index c627745..0000000
--- a/milena/tests/unit_test/mln_level_domain.cc
+++ /dev/null
@@ -1,8 +0,0 @@
-// Unit test for mln/level/domain.hh.
-// Generated file, do not modify.
-#include <mln/level/domain.hh>
-
-int main()
-{
- // Nothing.
-}
diff --git a/milena/tests/unit_test/mln_morpho_general.cc b/milena/tests/unit_test/mln_morpho_general.cc
new file mode 100644
index 0000000..d4517ef
--- /dev/null
+++ b/milena/tests/unit_test/mln_morpho_general.cc
@@ -0,0 +1,8 @@
+// Unit test for mln/morpho/general.hh.
+// Generated file, do not modify.
+#include <mln/morpho/general.hh>
+
+int main()
+{
+ // Nothing.
+}
diff --git a/milena/tests/unit_test/mln_morpho_tree_compute_attribute_image.cc b/milena/tests/unit_test/mln_morpho_tree_compute_attribute_image.cc
new file mode 100644
index 0000000..8109a53
--- /dev/null
+++ b/milena/tests/unit_test/mln_morpho_tree_compute_attribute_image.cc
@@ -0,0 +1,8 @@
+// Unit test for mln/morpho/tree/compute_attribute_image.hh.
+// Generated file, do not modify.
+#include <mln/morpho/tree/compute_attribute_image.hh>
+
+int main()
+{
+ // Nothing.
+}
diff --git a/milena/tests/unit_test/mln_util_internal_edge_impl.cc b/milena/tests/unit_test/mln_util_internal_edge_impl.cc
new file mode 100644
index 0000000..ea7a740
--- /dev/null
+++ b/milena/tests/unit_test/mln_util_internal_edge_impl.cc
@@ -0,0 +1,8 @@
+// Unit test for mln/util/internal/edge_impl.hh.
+// Generated file, do not modify.
+#include <mln/util/internal/edge_impl.hh>
+
+int main()
+{
+ // Nothing.
+}
diff --git a/milena/tests/unit_test/mln_util_internal_graph_edge_impl.cc b/milena/tests/unit_test/mln_util_internal_graph_edge_impl.cc
deleted file mode 100644
index 32fad7d..0000000
--- a/milena/tests/unit_test/mln_util_internal_graph_edge_impl.cc
+++ /dev/null
@@ -1,8 +0,0 @@
-// Unit test for mln/util/internal/graph_edge_impl.hh.
-// Generated file, do not modify.
-#include <mln/util/internal/graph_edge_impl.hh>
-
-int main()
-{
- // Nothing.
-}
diff --git a/milena/tests/unit_test/mln_util_internal_graph_vertex_impl.cc b/milena/tests/unit_test/mln_util_internal_graph_vertex_impl.cc
deleted file mode 100644
index cf2f084..0000000
--- a/milena/tests/unit_test/mln_util_internal_graph_vertex_impl.cc
+++ /dev/null
@@ -1,8 +0,0 @@
-// Unit test for mln/util/internal/graph_vertex_impl.hh.
-// Generated file, do not modify.
-#include <mln/util/internal/graph_vertex_impl.hh>
-
-int main()
-{
- // Nothing.
-}
diff --git a/milena/tests/unit_test/mln_util_internal_vertex_impl.cc b/milena/tests/unit_test/mln_util_internal_vertex_impl.cc
new file mode 100644
index 0000000..7ada03f
--- /dev/null
+++ b/milena/tests/unit_test/mln_util_internal_vertex_impl.cc
@@ -0,0 +1,8 @@
+// Unit test for mln/util/internal/vertex_impl.hh.
+// Generated file, do not modify.
+#include <mln/util/internal/vertex_impl.hh>
+
+int main()
+{
+ // Nothing.
+}
diff --git a/milena/tests/util/Makefile.am b/milena/tests/util/Makefile.am
index 07abfab..0e9c5ab 100644
--- a/milena/tests/util/Makefile.am
+++ b/milena/tests/util/Makefile.am
@@ -11,7 +11,7 @@ check_PROGRAMS = \
graph \
lazy_set \
lemmings \
- ordpair \
+ ord_pair \
tree \
tree_fast \
tree_fast_to_image \
@@ -25,7 +25,7 @@ eat_SOURCES = eat.cc
graph_SOURCES = graph.cc
lazy_set_SOURCES = lazy_set.cc
lemmings_SOURCES = lemmings.cc
-ordpair_SOURCES = ordpair.cc
+ord_pair_SOURCES = ord_pair.cc
tree_SOURCES = tree.cc
tree_fast_SOURCES = tree_fast.cc
tree_fast_to_image_SOURCES = tree_to_image.cc
--
1.5.6.5
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add front computation of distance and influence zone.
* mln/transform/internal: New directory.
* mln/transform/internal/all.hh: New.
* mln/transform/distance_geodesic.hh: Copy to...
* mln/transform/distance_front.hh: ...this new file.
Update.
* mln/transform/distance_geodesic.hh
(distance_functor): Move into...
* mln/transform/internal/distance_functor.hh: ...this new file.
Split decl and def.
* mln/transform/influence_zone_geodesic.hh
(iz_functor): Move into...
* mln/transform/internal/influence_zone_functor.hh: ...this new
file.
(iz_functor): Rename as...
(influence_zone_functor): ...this.
Split decl and def.
* mln/transform/distance.hh: Remove.
* mln/transform/influence_zone_front.hh: New.
* mln/transform/all.hh: Update.
* mln/canvas/distance_front.hh: New.
* mln/canvas/all.hh: Update.
* tests/transform/distance.cc: Copy to...
* tests/transform/influence_zone_front.cc: ...this new file.
(vals): Rename as...
(ws): ...this less ambiguous name.
Update.
* tests/transform/distance.cc: Rename as...
* tests/transform/distance_front.cc: ...this.
Update.
* tests/transform/Makefile.am: Update.
mln/canvas/all.hh | 17 +-
mln/canvas/distance_front.hh | 136 +++++++++--------------
mln/transform/all.hh | 3
mln/transform/distance_front.hh | 61 +++-------
mln/transform/distance_geodesic.hh | 30 -----
mln/transform/influence_zone_front.hh | 93 +++++++++++++++
mln/transform/influence_zone_geodesic.hh | 53 +++-----
mln/transform/internal/all.hh | 53 ++++++++
mln/transform/internal/distance_functor.hh | 101 +++++++++++++++++
mln/transform/internal/influence_zone_functor.hh | 105 +++++++++++++++++
tests/transform/Makefile.am | 6 -
tests/transform/distance_front.cc | 16 +-
tests/transform/influence_zone_front.cc | 29 ++--
13 files changed, 486 insertions(+), 217 deletions(-)
Index: tests/transform/influence_zone_front.cc
--- tests/transform/influence_zone_front.cc (revision 2983)
+++ tests/transform/influence_zone_front.cc (working copy)
@@ -25,19 +25,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/transform/distance.cc
- *
- * \brief Test on mln::transform::distance.
- */
+/// \file tests/transform/influence_zone_front.cc
+///
+/// Test on mln::transform::influence_zone_front.
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/neighb2d.hh>
#include <mln/make/w_window2d_int.hh>
#include <mln/value/int_u8.hh>
-#include <mln/level/fill.hh>
#include <mln/debug/println.hh>
-#include <mln/transform/distance.hh>
+#include <mln/transform/influence_zone_front.hh>
int main()
@@ -45,17 +43,24 @@
using namespace mln;
using value::int_u8;
- image2d<bool> input(9, 9);
- level::fill(input, false);
- input.at(4, 4) = true;
+ int_u8 vals[] =
+ { 1, 1, 0, 0, 0, 0, 3,
+ 1, 1, 1, 0, 0, 0, 0,
+ 0, 1, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 0,
+ 0, 0, 0, 0, 2, 2, 0,
+ 0, 0, 0, 0, 0, 0, 0 };
+ image2d<int_u8> input = make::image2d(vals);
- int vals[] = { 0, 9, 0, 9, 0,
+ int ws[] = { 0, 9, 0, 9, 0,
9, 6, 4, 6, 9,
0, 4, 0, 4, 0,
9, 6, 4, 6, 9,
0, 9, 0, 9, 0 };
- image2d<int_u8> output = transform::distance(int_u8(), input,
- c4(), make::w_window2d_int(vals));
+ image2d<int_u8> output;
+ output = transform::influence_zone_front(input,
+ c4(), make::w_window2d_int(ws));
debug::println(output);
}
Property changes on: tests/transform/influence_zone_front.cc
___________________________________________________________________
Added: svn:mergeinfo
Index: tests/transform/distance_front.cc
--- tests/transform/distance_front.cc (revision 2981)
+++ tests/transform/distance_front.cc (working copy)
@@ -25,10 +25,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/transform/distance.cc
- *
- * \brief Test on mln::transform::distance.
- */
+/// \file tests/transform/distance_front.cc
+///
+/// Test on mln::transform::distance_front.
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/neighb2d.hh>
@@ -37,7 +36,7 @@
#include <mln/level/fill.hh>
#include <mln/debug/println.hh>
-#include <mln/transform/distance.hh>
+#include <mln/transform/distance_front.hh>
int main()
@@ -49,13 +48,14 @@
level::fill(input, false);
input.at(4, 4) = true;
- int vals[] = { 0, 9, 0, 9, 0,
+ int ws[] = { 0, 9, 0, 9, 0,
9, 6, 4, 6, 9,
0, 4, 0, 4, 0,
9, 6, 4, 6, 9,
0, 9, 0, 9, 0 };
- image2d<int_u8> output = transform::distance(int_u8(), input,
- c4(), make::w_window2d_int(vals));
+ image2d<int_u8> output = transform::distance_front(input,
+ c4(), make::w_window2d_int(ws),
+ int_u8(18));
debug::println(output);
}
Property changes on: tests/transform/distance_front.cc
___________________________________________________________________
Added: svn:mergeinfo
Index: tests/transform/Makefile.am
--- tests/transform/Makefile.am (revision 2984)
+++ tests/transform/Makefile.am (working copy)
@@ -3,12 +3,14 @@
include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
- distance \
+ distance_front \
distance_geodesic \
+ influence_zone_front \
influence_zone_geodesic
-distance_SOURCES = distance.cc
+distance_front_SOURCES = distance_front.cc
distance_geodesic_SOURCES = distance_geodesic.cc
+influence_zone_front_SOURCES = influence_zone_front.cc
influence_zone_geodesic_SOURCES = influence_zone_geodesic.cc
TESTS = $(check_PROGRAMS)
Index: mln/transform/distance_front.hh
--- mln/transform/distance_front.hh (revision 2981)
+++ mln/transform/distance_front.hh (working copy)
@@ -25,14 +25,15 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_TRANSFORM_DISTANCE_GEODESIC_HH
-# define MLN_TRANSFORM_DISTANCE_GEODESIC_HH
+#ifndef MLN_TRANSFORM_DISTANCE_FRONT_HH
+# define MLN_TRANSFORM_DISTANCE_FRONT_HH
-/// \file mln/transform/distance_geodesic.hh
+/// \file mln/transform/distance_front.hh
///
-/// Discrete geodesic distance transform.
+/// Discrete front distance transform.
-# include <mln/canvas/distance_geodesic.hh>
+# include <mln/canvas/distance_front.hh>
+# include <mln/transform/internal/distance_functor.hh>
@@ -42,58 +43,32 @@
namespace transform
{
- /// Discrete geodesic distance transform.
- template <typename I, typename N, typename D>
+ /// Discrete front distance transform.
+ template <typename I, typename N, typename W, typename D>
mln_ch_value(I, D)
- distance_geodesic(const Image<I>& input, const Neighborhood<N>& nbh, D max);
+ distance_front(const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win, D max);
# ifndef MLN_INCLUDE_ONLY
-
- namespace internal
- {
-
- template <typename I>
- struct distance_functor
- {
- typedef mln_value(I) V;
- typedef mln_site(I) P;
-
- void init(const I&)
- {
- }
- bool inqueue_p_wrt_input_p(const V& input_p)
- {
- return input_p == true;
- }
- bool inqueue_p_wrt_input_n(const V& input_n)
- {
- return input_n == false;
- }
- void process(const P&, const P&)
- {
- }
- };
-
- } // end of namespace mln::transform::internal
-
-
- template <typename I, typename N, typename D>
+ template <typename I, typename N, typename W, typename D>
inline
mln_ch_value(I, D)
- distance_geodesic(const Image<I>& input, const Neighborhood<N>& nbh, D max)
+ distance_front(const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win, D max)
{
- trace::entering("transform::distance_geodesic");
+ trace::entering("transform::distance_front");
mln_precondition(exact(input).has_data());
// mln_precondition(exact(nbh).is_valid());
+ // mln_precondition(exact(w_win).is_valid());
mln_ch_value(I, D) output;
internal::distance_functor<I> f;
- output = mln::canvas::distance_geodesic(input, nbh, max, f);
+ output = mln::canvas::distance_front(input, nbh, w_win, max, f);
- trace::exiting("transform::distance_geodesic");
+ trace::exiting("transform::distance_front");
return output;
}
@@ -104,4 +79,4 @@
} // end of namespace mln
-#endif // ! MLN_TRANSFORM_DISTANCE_GEODESIC_HH
+#endif // ! MLN_TRANSFORM_DISTANCE_FRONT_HH
Property changes on: mln/transform/distance_front.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/transform/influence_zone_geodesic.hh
--- mln/transform/influence_zone_geodesic.hh (revision 2984)
+++ mln/transform/influence_zone_geodesic.hh (working copy)
@@ -30,10 +30,10 @@
/// \file mln/transform/influence_zone_geodesic.hh
///
-/// Discrete geodesic distance transform.
+/// Geodesic influence zone transform.
# include <mln/canvas/distance_geodesic.hh>
-# include <mln/literal/zero.hh>
+# include <mln/transform/internal/influence_zone_functor.hh>
namespace mln
@@ -42,45 +42,21 @@
namespace transform
{
- /// Discrete geodesic distance transform.
+ /// Geodesic influence zone transform.
template <typename I, typename N, typename D>
mln_concrete(I)
- influence_zone_geodesic(const Image<I>& input, const Neighborhood<N>& nbh, D max);
+ influence_zone_geodesic(const Image<I>& input,
+ const Neighborhood<N>& nbh, D max);
-# ifndef MLN_INCLUDE_ONLY
-
- namespace internal
- {
-
- template <typename I>
- struct iz_functor
- {
- typedef mln_value(I) V;
- typedef mln_site(I) P;
-
- mln_concrete(I) output;
+ /// Geodesic influence zone transform.
+ template <typename I, typename N>
+ mln_concrete(I)
+ influence_zone_geodesic(const Image<I>& input, const Neighborhood<N>& nbh);
- void init(const I& input)
- {
- output = clone(input);
- }
- bool inqueue_p_wrt_input_p(const V& input_p)
- {
- return input_p != 0u;
- }
- bool inqueue_p_wrt_input_n(const V& input_n)
- {
- return input_n == 0u;
- }
- void process(const P& p, const P& n)
- {
- output(n) = output(p);
- }
- };
- } // end of namespace mln::transform::internal
+# ifndef MLN_INCLUDE_ONLY
template <typename I, typename N, typename D>
mln_concrete(I)
@@ -92,13 +68,20 @@
mln_precondition(exact(input).has_data());
// mln_precondition(exact(nbh).is_valid());
- internal::iz_functor<I> f;
+ internal::influence_zone_functor<I> f;
(void) mln::canvas::distance_geodesic(input, nbh, max, f);
trace::exiting("transform::influence_zone_geodesic");
return f.output;
}
+ template <typename I, typename N>
+ mln_concrete(I)
+ influence_zone_geodesic(const Image<I>& input, const Neighborhood<N>& nbh)
+ {
+ return influence_zone_geodesic(input, nbh, mln_max(unsigned));
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::transform
Index: mln/transform/all.hh
--- mln/transform/all.hh (revision 2984)
+++ mln/transform/all.hh (working copy)
@@ -42,8 +42,9 @@
} // end of namespace mln
-# include <mln/transform/distance.hh>
+# include <mln/transform/distance_front.hh>
# include <mln/transform/distance_geodesic.hh>
+# include <mln/transform/influence_zone_front.hh>
# include <mln/transform/influence_zone_geodesic.hh>
Index: mln/transform/influence_zone_front.hh
--- mln/transform/influence_zone_front.hh (revision 0)
+++ mln/transform/influence_zone_front.hh (revision 0)
@@ -0,0 +1,93 @@
+// 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_TRANSFORM_INFLUENCE_ZONE_FRONT_HH
+# define MLN_TRANSFORM_INFLUENCE_ZONE_FRONT_HH
+
+/// \file mln/transform/influence_zone_front.hh
+///
+/// Influence zone transform.
+
+# include <mln/canvas/distance_front.hh>
+# include <mln/transform/internal/influence_zone_functor.hh>
+
+
+namespace mln
+{
+
+ namespace transform
+ {
+
+ /// Influence zone transform.
+ template <typename I, typename N, typename W, typename D>
+ mln_concrete(I)
+ influence_zone_front(const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win, D max);
+
+ /// Influence zone transform.
+ template <typename I, typename N, typename W>
+ mln_concrete(I)
+ influence_zone_front(const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename N, typename W, typename D>
+ mln_concrete(I)
+ influence_zone_front(const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win, D max)
+ {
+ trace::entering("transform::influence_zone_front");
+
+ mln_precondition(exact(input).has_data());
+ // mln_precondition(exact(nbh).is_valid());
+ // mln_precondition(exact(w_win).is_valid());
+
+ internal::influence_zone_functor<I> f;
+ (void) mln::canvas::distance_front(input, nbh, w_win, max, f);
+
+ trace::exiting("transform::influence_zone_front");
+ return f.output;
+ }
+
+ template <typename I, typename N, typename W>
+ mln_concrete(I)
+ influence_zone_front(const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win)
+ {
+ return influence_zone_front(input, nbh, w_win, mln_max(unsigned));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::transform
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TRANSFORM_INFLUENCE_ZONE_FRONT_HH
Index: mln/transform/distance_geodesic.hh
--- mln/transform/distance_geodesic.hh (revision 2984)
+++ mln/transform/distance_geodesic.hh (working copy)
@@ -33,6 +33,7 @@
/// Discrete geodesic distance transform.
# include <mln/canvas/distance_geodesic.hh>
+# include <mln/transform/internal/distance_functor.hh>
@@ -50,35 +51,6 @@
# ifndef MLN_INCLUDE_ONLY
-
- namespace internal
- {
-
- template <typename I>
- struct distance_functor
- {
- typedef mln_value(I) V;
- typedef mln_site(I) P;
-
- void init(const I&)
- {
- }
- bool inqueue_p_wrt_input_p(const V& input_p)
- {
- return input_p == true;
- }
- bool inqueue_p_wrt_input_n(const V& input_n)
- {
- return input_n == false;
- }
- void process(const P&, const P&)
- {
- }
- };
-
- } // end of namespace mln::transform::internal
-
-
template <typename I, typename N, typename D>
inline
mln_ch_value(I, D)
Index: mln/transform/internal/influence_zone_functor.hh
--- mln/transform/internal/influence_zone_functor.hh (revision 0)
+++ mln/transform/internal/influence_zone_functor.hh (revision 0)
@@ -0,0 +1,105 @@
+// 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_TRANSFORM_INTERNAL_INFLUENCE_ZONE_FUNCTOR_HH
+# define MLN_TRANSFORM_INTERNAL_INFLUENCE_ZONE_FUNCTOR_HH
+
+/// \file mln/transform/internal/influence_zone_functor.hh
+///
+/// Influence zone functor.
+
+# include <mln/core/routine/clone.hh>
+
+
+
+namespace mln
+{
+
+ namespace transform
+ {
+
+ namespace internal
+ {
+
+ template <typename I>
+ struct influence_zone_functor
+ {
+ typedef mln_value(I) V;
+ typedef mln_site(I) P;
+
+ mln_concrete(I) output;
+
+ void init(const I& input);
+ bool inqueue_p_wrt_input_p(const V& input_p);
+ bool inqueue_p_wrt_input_n(const V& input_n);
+ void process(const P& p, const P& n);
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ inline
+ void
+ influence_zone_functor<I>::init(const I& input)
+ {
+ output = clone(input);
+ }
+
+ template <typename I>
+ inline
+ bool
+ influence_zone_functor<I>::inqueue_p_wrt_input_p(const V& input_p)
+ {
+ return input_p != 0u;
+ }
+
+ template <typename I>
+ inline
+ bool
+ influence_zone_functor<I>::inqueue_p_wrt_input_n(const V& input_n)
+ {
+ return input_n == 0u;
+ }
+
+ template <typename I>
+ inline
+ void influence_zone_functor<I>::process(const P& p, const P& n)
+ {
+ output(n) = output(p);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::transform::internal
+
+ } // end of namespace mln::transform
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TRANSFORM_INTERNAL_INFLUENCE_ZONE_FUNCTOR_HH
Index: mln/transform/internal/all.hh
--- mln/transform/internal/all.hh (revision 0)
+++ mln/transform/internal/all.hh (revision 0)
@@ -0,0 +1,53 @@
+// 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_TRANSFORM_INTERNAL_ALL_HH
+# define MLN_TRANSFORM_INTERNAL_ALL_HH
+
+/// \file mln/transform/internal/all.hh
+///
+/// File that includes all internals of mln/transform.
+
+
+namespace mln
+{
+
+ namespace transform
+ {
+
+ namespace internal {}
+
+ } // end of namespace mln::transform
+
+} // end of namespace mln
+
+
+# include <mln/transform/internal/distance_functor.hh>
+# include <mln/transform/internal/influence_zone_functor.hh>
+
+
+#endif // ! MLN_TRANSFORM_INTERNAL_ALL_HH
Index: mln/transform/internal/distance_functor.hh
--- mln/transform/internal/distance_functor.hh (revision 0)
+++ mln/transform/internal/distance_functor.hh (revision 0)
@@ -0,0 +1,101 @@
+// 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_TRANSFORM_INTERNAL_DISTANCE_FUNCTOR_HH
+# define MLN_TRANSFORM_INTERNAL_DISTANCE_FUNCTOR_HH
+
+/// \file mln/transform/internal/distance_functor.hh
+///
+/// Distance functor.
+
+# include <mln/core/macros.hh>
+
+
+
+namespace mln
+{
+
+ namespace transform
+ {
+
+ namespace internal
+ {
+
+ template <typename I>
+ struct distance_functor
+ {
+ typedef mln_value(I) V;
+ typedef mln_site(I) P;
+
+ void init(const I&);
+ bool inqueue_p_wrt_input_p(const V& input_p);
+ bool inqueue_p_wrt_input_n(const V& input_n);
+ void process(const P&, const P&);
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ inline
+ void
+ distance_functor<I>::init(const I&)
+ {
+ }
+
+ template <typename I>
+ inline
+ bool
+ distance_functor<I>::inqueue_p_wrt_input_p(const V& input_p)
+ {
+ return input_p == true;
+ }
+
+ template <typename I>
+ inline
+ bool
+ distance_functor<I>::inqueue_p_wrt_input_n(const V& input_n)
+ {
+ return input_n == false;
+ }
+
+ template <typename I>
+ inline
+ void distance_functor<I>::process(const P&, const P&)
+ {
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::transform::internal
+
+ } // end of namespace mln::transform
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TRANSFORM_INTERNAL_DISTANCE_FUNCTOR_HH
Index: mln/canvas/distance_front.hh
--- mln/canvas/distance_front.hh (revision 2981)
+++ mln/canvas/distance_front.hh (working copy)
@@ -25,14 +25,12 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_TRANSFORM_DISTANCE_HH
-# define MLN_TRANSFORM_DISTANCE_HH
+#ifndef MLN_CANVAS_DISTANCE_FRONT_HH
+# define MLN_CANVAS_DISTANCE_FRONT_HH
-/// \file mln/transform/distance.hh
+/// \file mln/canvas/distance_front.hh
///
-/// Discrete distance transform.
-///
-/// \todo Make a canvas out of it.
+/// Discrete distance canvas by front propagation.
# include <vector>
# include <mln/core/concept/image.hh>
@@ -42,78 +40,76 @@
# include <mln/accu/max.hh>
-
namespace mln
{
- namespace transform
+ namespace canvas
{
- /*! Discrete distance transform.
- *
- * FIXME: doc.
- */
- template <typename D, typename I, typename N, typename W>
+ /// Discrete distance canvas by front propagation.
+ template <typename I,
+ typename N, typename W, typename D,
+ typename F>
mln_ch_value(I, D)
- distance(D, const Image<I>& input,
- const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win);
+ distance_front(const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win, D max,
+ F& functor);
# ifndef MLN_INCLUDE_ONLY
- namespace impl
- {
-
- namespace generic
- {
- template <typename D, typename I, typename N, typename W>
+ template <typename I,
+ typename N, typename W, typename D,
+ typename F>
+ inline
mln_ch_value(I, D)
- distance(D, const Image<I>& input_,
- const Neighborhood<N>& nbh_, const Weighted_Window<W>& w_win_)
+ distance_front(const Image<I>& input_,
+ const Neighborhood<N>& nbh_, const Weighted_Window<W>& w_win_, D max,
+ F& functor)
{
- trace::entering("transform::impl::generic::distance");
+ trace::entering("canvas::distance_front");
const I& input = exact(input_);
const N& nbh = exact(nbh_);
const W& w_win = exact(w_win_);
mln_precondition(input.has_data());
-
- const D Max = mln_max(D);
+ // mln_precondition(w_win.is_valid());
typedef mln_site(I) P;
typedef std::vector<P> bucket_t;
- mln_ch_value(I, D) output;
- initialize(output, input);
- level::fill(output, Max);
+ // Distance map.
+ mln_ch_value(I, D) dmap;
+ initialize(dmap, input);
+ level::fill(dmap, max);
- // Modulus determination.
+ // Mod determination.
unsigned mod;
{
- mln::accu::max<unsigned> accu;
- P p;
- mln_qiter(W) q(w_win, p);
- for_all(q)
- accu.take(q.w());
- mod = accu.to_result() + 1;
+ accu::max<unsigned> m;
+ for (unsigned i = 0; i < w_win.size(); ++i)
+ m.take(w_win.w(i));
+ mod = unsigned(m) + 1;
}
- std::vector<bucket_t> bucket;
- bucket.resize(mod);
+ // Aux data.
+ std::vector<bucket_t> bucket(mod);
unsigned bucket_size = 0;
// Initialization.
{
+ functor.init(input); // <-- init
mln_piter(I) p(input.domain());
mln_niter(N) n(nbh, p);
for_all(p)
- if (input(p) == true)
+ if (functor.inqueue_p_wrt_input_p(input(p))) // <-- inqueue_p_wrt_input_p
{
- output(p) = literal::zero;
+ dmap(p) = 0;
for_all(n)
- if (input.domain().has(n) && input(n) == false)
+ if (input.domain().has(n) &&
+ functor.inqueue_p_wrt_input_n(input(n))) // <-- inqueue_p_wrt_input_n
{
bucket[0].push_back(p);
++bucket_size;
@@ -126,30 +122,32 @@
{
P p;
mln_qiter(W) q(w_win, p);
-
for (unsigned d = 0; bucket_size != 0; ++d)
{
bucket_t& bucket_d = bucket[d % mod];
for (unsigned i = 0; i < bucket_d.size(); ++i)
{
p = bucket_d[i];
- if (output(p) < d)
+
+ if (dmap(p) == max)
+ {
+ // Saturation so stop.
+ bucket_size = bucket_d.size(); // So at end bucket_size == 0.
+ break;
+ }
+
+ if (dmap(p) < d)
+ // p has already been processed, having a distance less than d.
continue;
for_all(q)
- if (output.domain().has(q) && output(q) > d)
+ if (dmap.domain().has(q) && dmap(q) > d)
{
- if (unsigned(Max - q.w()) < d) // Saturation => Stop!
- {
- // trace::warning...
- trace::exiting("transform::impl::generic::distance");
- return output;
- }
unsigned d_ = d + q.w();
-
- if (d_ < output(q))
+ if (d_ < dmap(q))
{
- output(q) = d_;
+ dmap(q) = d_;
+ functor.process(p, q); // <- process
bucket[d_ % mod].push_back(q);
++bucket_size;
}
@@ -158,41 +156,17 @@
bucket_size -= bucket_d.size();
bucket_d.clear();
}
- }
-
- trace::exiting("transform::impl::generic::distance");
- return output;
+ trace::exiting("canvas::distance_front");
+ return dmap;
}
-
- } // end of namespace mln::transform::impl::generic
-
- } // end of namespace mln::transform::impl
-
-
- // Facade.
-
- template <typename D, typename I, typename N, typename W>
- inline
- mln_ch_value(I, D)
- distance(D, const Image<I>& input,
- const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win)
- {
- trace::entering("transform::distance");
-
- // FIXME: tests.
- mln_ch_value(I, D) output = impl::generic::distance(D(), input,
- nbh, w_win);
-
- trace::exiting("transform::distance");
- return output;
}
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::transform
+ } // end of namespace mln::canvas
} // end of namespace mln
-#endif // ! MLN_TRANSFORM_DISTANCE_HH
+#endif // ! MLN_CANVAS_DISTANCE_FRONT_HH
Property changes on: mln/canvas/distance_front.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/canvas/all.hh
--- mln/canvas/all.hh (revision 2984)
+++ mln/canvas/all.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_CANVAS_ALL_HH
# define MLN_CANVAS_ALL_HH
-/*! \file mln/canvas/all.hh
- *
- * \brief File that includes all canvas-related routines.
- */
+/// \file mln/canvas/all.hh
+///
+/// File that includes all canvas-related routines.
namespace mln
@@ -40,15 +40,20 @@
/// Namespace of canvas.
namespace canvas
{
+
/// Implementation namespace of canvas namespace.
namespace impl {}
- }
}
+}
+
# include <mln/canvas/browsing/all.hh>
# include <mln/canvas/morpho/all.hh>
# include <mln/canvas/chamfer.hh>
+# include <mln/canvas/distance_front.hh>
+# include <mln/canvas/distance_geodesic.hh>
# include <mln/canvas/labeling.hh>
+
#endif // ! MLN_CANVAS_ALL_HH
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Update n_cmpt3.
* jardonnet/n_cmpt/n_cmpt3.hh: Minor change.
* jardonnet/n_cmpt/test3.cc: Display output image.
* jardonnet/igr/src/igr.cc: Fix call to closing.
igr/src/igr.cc | 3 +--
n_cmpt/n_cmpt3.hh | 31 +++++++++----------------------
n_cmpt/test3.cc | 10 ++++++++--
3 files changed, 18 insertions(+), 26 deletions(-)
Index: jardonnet/n_cmpt/n_cmpt3.hh
--- jardonnet/n_cmpt/n_cmpt3.hh (revision 2983)
+++ jardonnet/n_cmpt/n_cmpt3.hh (working copy)
@@ -81,6 +81,7 @@
{
unsigned label;
+ std::cout << "/ima/" << std::endl;
debug::println(ima);
// get /ima/ regional minima
@@ -97,6 +98,7 @@
morpho::tree::data<I,S> t(ima, sp, nbh);
V volume = morpho::tree::compute_attribute_image(A(), t);
sp = level::sort_psites_increasing(volume);
+ std::cout << "/volume/" << std::endl;
debug::println(volume);
// get /volume/ regional minima
@@ -140,6 +142,8 @@
mln_niter(N) n(nbh, p);
for_all(p)
{
+ //if (volume(p) > lambda)
+ // goto step2;
for_all(n)
{
if (volume.domain().has(n) && deja_vu(n))
@@ -148,28 +152,6 @@
P r = find_root(parent, n);
if (r != p)
{
- if (volume(p) > lambda)
- goto step2;
-// if (volume(r) != volume(p) && (data(p).to_result() > lambda))
-// {
-// data(p).set_value(lambda);
-// continue;
-// }
-
-// if (volume(r) != volume(p))
-// {
-// std::cout << "1: volume"<<r<<" != volume"<<p<<"" << " with data"<<p<< " = " <<
-// data(p).to_result() << std::endl;
-// if (not volume_set(p).is_empty())
-// {
-// std::cout << "2: not volume_set"<<p<<".is_empty()" << std::endl;
-// if (volume_set(p) != volume_set(r))
-// {
-// std::cout << "3: volume_set"<<p<<" != volume_set"<<r<< std::endl;
-// cmpts--;
-// }
-// }
-// }
// propagate set
volume_set(p).insert(volume_set(r));
// build tree
@@ -181,6 +163,7 @@
}
debug::println(volume_set);
+
step2:
// std::cout << "Nb cmpts after processing : " << cmpts << std::endl;
@@ -195,6 +178,10 @@
output(p) = output(parent(p));
}
+ std::cout << "/output/" << std::endl;
+ debug::println(output);
+ assert(output != input);
+
return output;
}
Index: jardonnet/n_cmpt/test3.cc
--- jardonnet/n_cmpt/test3.cc (revision 2983)
+++ jardonnet/n_cmpt/test3.cc (working copy)
@@ -8,6 +8,9 @@
#include <mln/io/pgm/save.hh>
#include <mln/morpho/closing_volume.hh>
+#include <mln/core/var.hh>
+
+#include <mln/debug/println.hh>
using namespace mln;
using namespace mln::value;
@@ -31,6 +34,9 @@
io::pgm::load(ima, argv[1]);
unsigned lambda = atoi(argv[2]);
- io::pgm::save(morpho::closing_volume(ima, c4(), lambda),
- "out.pgm");
+ mln_VAR(out, morpho::closing_volume(ima, c4(), lambda));
+
+ debug::println(out);
+
+ io::pgm::save(out,"out.pgm");
}
Index: jardonnet/igr/src/igr.cc
--- jardonnet/igr/src/igr.cc (revision 2983)
+++ jardonnet/igr/src/igr.cc (working copy)
@@ -87,8 +87,7 @@
// Volume Closing
///////////////////
- image2d<int_u8> o_ima(mg_ima.domain());
- morpho::closing_volume(mg_ima, c4(), lambda, o_ima);
+ image2d<int_u8> o_ima = morpho::closing_volume(mg_ima, c4(), lambda);
io::pgm::save(o_ima, "o_ima.ppm");
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Check correct filtering.
* jardonnet/n_cmpt/n_cmpt3.hh: Update, Fix, Remove.
* jardonnet/n_cmpt/test3.cc: Volume closing.
n_cmpt3.hh | 91 ++++++++++++++++++++++++++++---------------------------------
test3.cc | 36 ++++++++++++++++++++++++
2 files changed, 78 insertions(+), 49 deletions(-)
Index: jardonnet/n_cmpt/n_cmpt3.hh
--- jardonnet/n_cmpt/n_cmpt3.hh (revision 2982)
+++ jardonnet/n_cmpt/n_cmpt3.hh (working copy)
@@ -50,21 +50,6 @@
# ifndef MLN_INCLUDE_ONLY
template<typename I>
- mln_ch_value(I, util::set<mln_psite(I)>)
- minima_sets(const I& ima)
- {
- mln_ch_value(I, util::set<mln_psite(I)>) ima_set(ima.domain());
-
- mln_piter(I) p(ima.domain());
- for_all(p)
- {
- if (ima(p) != literal::zero)
- ima_set(p).insert(p);
- }
- return ima_set;
- }
-
- template <typename I>
inline
mln_psite(I)
find_root(I& parent,
@@ -96,6 +81,8 @@
{
unsigned label;
+ debug::println(ima);
+
// get /ima/ regional minima
mln_ch_value(I, unsigned) min = labeling::regional_minima(ima, nbh, label);
std::cout << "/ima/ regional minima" << std::endl;
@@ -105,9 +92,12 @@
typedef p_array<mln_psite(I)> S;
typedef image2d<unsigned> V;
typedef accu::volume<I> A;
+
S sp = level::sort_psites_decreasing(ima);
morpho::tree::data<I,S> t(ima, sp, nbh);
V volume = morpho::tree::compute_attribute_image(A(), t);
+ sp = level::sort_psites_increasing(volume);
+ debug::println(volume);
// get /volume/ regional minima
mln_ch_value(I, unsigned) min_v = labeling::regional_minima(volume, nbh, label);
@@ -117,38 +107,39 @@
// tester minima de ima == minima de attr
//mln_assertion(min == min_v);
- mln_ch_value(I, util::set<mln_psite(I)>) volume_set = minima_sets(volume);
+ mln_ch_value(I, util::set<unsigned>) volume_set;
+ initialize(volume_set, min_v);
// number of minima
- int cmpts = count_minima(min_v);
+ int cmpts = label;
std::cout << "Nb of regionnal minima : " << cmpts << std::endl;
// prepare union find
typedef mln_psite(V) P;
//data
- mln_ch_value(V, accu::volume<V>) data;
- initialize(data, volume);
+ mln_ch_value(V, accu::volume<V>) data(volume.domain());
//deja_vu
- mln_ch_value(V, bool) deja_vu;
- initialize(deja_vu, volume);
+ mln_ch_value(V, bool) deja_vu(volume.domain());
mln::level::fill(deja_vu, false);
//parent
- mln_ch_value(V, P) parent;
- initialize(parent, volume);
+ mln_ch_value(V, P) parent(volume.domain());
{
mln_fwd_piter(S) p(sp);
for_all(p)
+ {
parent(p) = p;
+ if (min_v(p) != 0) // p in a reg min of the attribute image
+ volume_set(p).insert(min_v(p));
+ }
}
+ debug::println(volume_set);
// union find sur volume
mln_fwd_piter(S) p(sp);
mln_niter(N) n(nbh, p);
for_all(p)
{
- // Make set.
- data(p).take_as_init(make::pix(volume, p));
for_all(n)
{
if (volume.domain().has(n) && deja_vu(n))
@@ -157,31 +148,30 @@
P r = find_root(parent, n);
if (r != p)
{
- if (volume(r) != volume(p) && (data(p).to_result() > lambda))
- {
- data(p).set_value(lambda);
- continue;
- }
-
- if (volume(r) != volume(p))
- {
- std::cout << "1: volume"<<r<<" != volume"<<p<<"" << " with data"<<p<< " = " <<
- data(p).to_result() << std::endl;
- if (not volume_set(p).is_empty())
- {
- std::cout << "2: not volume_set"<<p<<".is_empty()" << std::endl;
- if (volume_set(p) != volume_set(r))
- {
- std::cout << "3: volume_set"<<p<<" != volume_set"<<r<< std::endl;
- cmpts--;
- }
- }
- }
+ if (volume(p) > lambda)
+ goto step2;
+// if (volume(r) != volume(p) && (data(p).to_result() > lambda))
+// {
+// data(p).set_value(lambda);
+// continue;
+// }
+
+// if (volume(r) != volume(p))
+// {
+// std::cout << "1: volume"<<r<<" != volume"<<p<<"" << " with data"<<p<< " = " <<
+// data(p).to_result() << std::endl;
+// if (not volume_set(p).is_empty())
+// {
+// std::cout << "2: not volume_set"<<p<<".is_empty()" << std::endl;
+// if (volume_set(p) != volume_set(r))
+// {
+// std::cout << "3: volume_set"<<p<<" != volume_set"<<r<< std::endl;
+// cmpts--;
+// }
+// }
+// }
// propagate set
volume_set(p).insert(volume_set(r));
- assert(data(p).to_result() != 0);
- // propagate attribute
- data(p).take(data(r));
// build tree
parent(r) = p;
}
@@ -190,7 +180,9 @@
deja_vu(p) = true;
}
- std::cout << "Nb cmpts after processing : " << cmpts << std::endl;
+ debug::println(volume_set);
+ step2:
+// std::cout << "Nb cmpts after processing : " << cmpts << std::endl;
// second pass
I output(ima.domain());
@@ -202,6 +194,7 @@
else
output(p) = output(parent(p));
}
+
return output;
}
Index: jardonnet/n_cmpt/test3.cc
--- jardonnet/n_cmpt/test3.cc (revision 0)
+++ jardonnet/n_cmpt/test3.cc (revision 0)
@@ -0,0 +1,36 @@
+
+#include <iostream>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/morpho/closing_volume.hh>
+
+using namespace mln;
+using namespace mln::value;
+
+bool usage(int argc, char ** argv)
+{
+ if (argc != 3)
+ {
+ std::cout << argv[0] << " ima.pgm lambda" << std::endl;
+ return false;
+ }
+ return true;
+}
+
+int main(int argc, char ** argv)
+{
+ if (not usage(argc,argv))
+ return 1;
+
+ image2d<int_u8> ima;
+ io::pgm::load(ima, argv[1]);
+ unsigned lambda = atoi(argv[2]);
+
+ io::pgm::save(morpho::closing_volume(ima, c4(), lambda),
+ "out.pgm");
+}
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Update n_cmpt3.
* jardonnet/n_cmpt/n_cmpt3.hh: Minor fix and display.
n_cmpt3.hh | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)
Index: jardonnet/n_cmpt/n_cmpt3.hh
--- jardonnet/n_cmpt/n_cmpt3.hh (revision 2981)
+++ jardonnet/n_cmpt/n_cmpt3.hh (working copy)
@@ -117,7 +117,7 @@
// tester minima de ima == minima de attr
//mln_assertion(min == min_v);
- mln_ch_value(I, util::set<mln_psite(I)>) ima_set = minima_sets(volume);
+ mln_ch_value(I, util::set<mln_psite(I)>) volume_set = minima_sets(volume);
// number of minima
int cmpts = count_minima(min_v);
@@ -126,13 +126,16 @@
// prepare union find
typedef mln_psite(V) P;
+ //data
+ mln_ch_value(V, accu::volume<V>) data;
+ initialize(data, volume);
+ //deja_vu
mln_ch_value(V, bool) deja_vu;
- initialize(deja_vu, ima);
- mln_ch_value(V, P) parent;
- initialize(parent, ima);
- mln_ch_value(V, A) data;
- initialize(data, ima);
+ initialize(deja_vu, volume);
mln::level::fill(deja_vu, false);
+ //parent
+ mln_ch_value(V, P) parent;
+ initialize(parent, volume);
{
mln_fwd_piter(S) p(sp);
for_all(p)
@@ -145,7 +148,7 @@
for_all(p)
{
// Make set.
- data(p).take_as_init(make::pix(ima, p));
+ data(p).take_as_init(make::pix(volume, p));
for_all(n)
{
if (volume.domain().has(n) && deja_vu(n))
@@ -154,26 +157,32 @@
P r = find_root(parent, n);
if (r != p)
{
- if (ima(r) != ima(p) && (data(p).to_result() > lambda))
+ if (volume(r) != volume(p) && (data(p).to_result() > lambda))
{
data(p).set_value(lambda);
continue;
}
- if (ima(r) != ima(p))
+ if (volume(r) != volume(p))
{
- std::cout << "1: ima(r) != ima(p)" << std::endl;
- if (not ima_set(p).is_empty())
+ std::cout << "1: volume"<<r<<" != volume"<<p<<"" << " with data"<<p<< " = " <<
+ data(p).to_result() << std::endl;
+ if (not volume_set(p).is_empty())
{
- std::cout << "2: not ima_set(p).is_empty()" << std::endl;
- if (ima_set(p) != ima_set(r))
+ std::cout << "2: not volume_set"<<p<<".is_empty()" << std::endl;
+ if (volume_set(p) != volume_set(r))
{
- std::cout << "3: ima_set(p) != ima_set(r)" << std::endl;
+ std::cout << "3: volume_set"<<p<<" != volume_set"<<r<< std::endl;
cmpts--;
}
}
}
- ima_set(p).insert(ima_set(r));
+ // propagate set
+ volume_set(p).insert(volume_set(r));
+ assert(data(p).to_result() != 0);
+ // propagate attribute
+ data(p).take(data(r));
+ // build tree
parent(r) = p;
}
}
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Attribute filtering v3.
* jardonnet/n_cmpt/n_cmpt3.hh: Make use of an image of set.
* jardonnet/n_cmpt/n_cmpt3.cc: New.
* jardonnet/n_cmpt/Makefile: Add rule.
* jardonnet/n_cmpt/check/test4.pgm: New test image.
Makefile | 6 +
n_cmpt3.cc | 37 ++++++++++
n_cmpt3.hh | 206 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 247 insertions(+), 2 deletions(-)
Index: jardonnet/n_cmpt/n_cmpt3.hh
--- jardonnet/n_cmpt/n_cmpt3.hh (revision 0)
+++ jardonnet/n_cmpt/n_cmpt3.hh (revision 0)
@@ -0,0 +1,206 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_N_CMPT3_HH
+# define MLN_N_CMPT3_HH
+
+# include <mln/labeling/regional_minima.hh>
+# include <mln/core/alias/neighb2d.hh>
+# include <mln/util/set.hh>
+
+# include <mln/debug/println.hh>
+
+# include <mln/accu/volume.hh>
+# include <mln/morpho/tree/data.hh>
+# include <mln/morpho/tree/compute_attribute_image.hh>
+
+namespace mln
+{
+
+ namespace n_cmpt
+ {
+
+ template < typename I >
+ void n_cmpt3(const I& (((((((ima))))))));
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template<typename I>
+ mln_ch_value(I, util::set<mln_psite(I)>)
+ minima_sets(const I& ima)
+ {
+ mln_ch_value(I, util::set<mln_psite(I)>) ima_set(ima.domain());
+
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ {
+ if (ima(p) != literal::zero)
+ ima_set(p).insert(p);
+ }
+ return ima_set;
+ }
+
+ template <typename I>
+ inline
+ mln_psite(I)
+ find_root(I& parent,
+ const mln_psite(I)& x)
+ {
+ if (parent(x) == x)
+ return x;
+ else
+ return parent(x) = find_root(parent, parent(x));
+ }
+
+ template < typename I >
+ unsigned count_minima(const I& ima)
+ {
+ unsigned cmpt = 0;
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ {
+ if (ima(p) != literal::zero)
+ cmpt++;
+ }
+ return cmpt;
+ }
+
+ template < typename I, typename N>
+ I
+ n_cmpt3(const I& ima, const N& nbh,
+ unsigned lambda)
+ {
+ unsigned label;
+
+ // get /ima/ regional minima
+ mln_ch_value(I, unsigned) min = labeling::regional_minima(ima, nbh, label);
+ std::cout << "/ima/ regional minima" << std::endl;
+ debug::println(min);
+
+ // compute volume image
+ typedef p_array<mln_psite(I)> S;
+ typedef image2d<unsigned> V;
+ typedef accu::volume<I> A;
+ S sp = level::sort_psites_decreasing(ima);
+ morpho::tree::data<I,S> t(ima, sp, nbh);
+ V volume = morpho::tree::compute_attribute_image(A(), t);
+
+ // get /volume/ regional minima
+ mln_ch_value(I, unsigned) min_v = labeling::regional_minima(volume, nbh, label);
+ std::cout << "/volume/ regional minima" << std::endl;
+ debug::println(min_v);
+
+ // tester minima de ima == minima de attr
+ //mln_assertion(min == min_v);
+
+ mln_ch_value(I, util::set<mln_psite(I)>) ima_set = minima_sets(volume);
+
+ // number of minima
+ int cmpts = count_minima(min_v);
+
+ std::cout << "Nb of regionnal minima : " << cmpts << std::endl;
+
+ // prepare union find
+ typedef mln_psite(V) P;
+ mln_ch_value(V, bool) deja_vu;
+ initialize(deja_vu, ima);
+ mln_ch_value(V, P) parent;
+ initialize(parent, ima);
+ mln_ch_value(V, A) data;
+ initialize(data, ima);
+ mln::level::fill(deja_vu, false);
+ {
+ mln_fwd_piter(S) p(sp);
+ for_all(p)
+ parent(p) = p;
+ }
+
+ // union find sur volume
+ mln_fwd_piter(S) p(sp);
+ mln_niter(N) n(nbh, p);
+ for_all(p)
+ {
+ // Make set.
+ data(p).take_as_init(make::pix(ima, p));
+ for_all(n)
+ {
+ if (volume.domain().has(n) && deja_vu(n))
+ {
+ //do_union(n, p);
+ P r = find_root(parent, n);
+ if (r != p)
+ {
+ if (ima(r) != ima(p) && (data(p).to_result() > lambda))
+ {
+ data(p).set_value(lambda);
+ continue;
+ }
+
+ if (ima(r) != ima(p))
+ {
+ std::cout << "1: ima(r) != ima(p)" << std::endl;
+ if (not ima_set(p).is_empty())
+ {
+ std::cout << "2: not ima_set(p).is_empty()" << std::endl;
+ if (ima_set(p) != ima_set(r))
+ {
+ std::cout << "3: ima_set(p) != ima_set(r)" << std::endl;
+ cmpts--;
+ }
+ }
+ }
+ ima_set(p).insert(ima_set(r));
+ parent(r) = p;
+ }
+ }
+ }
+ deja_vu(p) = true;
+ }
+
+ std::cout << "Nb cmpts after processing : " << cmpts << std::endl;
+
+ // second pass
+ I output(ima.domain());
+ {
+ mln_bkd_piter(S) p(sp);
+ for_all(p)
+ if (parent(p) == p) // p is root.
+ output(p) = ima(p);
+ else
+ output(p) = output(parent(p));
+ }
+ return output;
+ }
+
+ } // end of namespace n_cmpt
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif /* MLN_N_CMPT3_HH */
+
Index: jardonnet/n_cmpt/n_cmpt3.cc
--- jardonnet/n_cmpt/n_cmpt3.cc (revision 0)
+++ jardonnet/n_cmpt/n_cmpt3.cc (revision 0)
@@ -0,0 +1,37 @@
+
+#include <iostream>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include "n_cmpt3.hh"
+
+using namespace mln;
+using namespace mln::value;
+
+bool usage(int argc, char ** argv)
+{
+ if (argc != 3)
+ {
+ std::cout << argv[0] << " ima.pgm lambda" << std::endl;
+ return false;
+ }
+ return true;
+}
+
+int main(int argc, char ** argv)
+{
+ if (not usage(argc,argv))
+ return 1;
+
+ image2d<int_u8> ima;
+ io::pgm::load(ima, argv[1]);
+ unsigned lambda = atoi(argv[2]);
+
+ io::pgm::save(n_cmpt::n_cmpt3(ima, c4(), lambda),
+ "out.pgm");
+}
Index: jardonnet/n_cmpt/Makefile
--- jardonnet/n_cmpt/Makefile (revision 2980)
+++ jardonnet/n_cmpt/Makefile (working copy)
@@ -4,8 +4,14 @@
n_cmpt2: n_cmpt2.hh n_cmpt2.cc
g++ -I../../.. -Wall -W -Wextra n_cmpt2.cc -DNDEBUG -O1 -o n_cmpt2
+n_cmpt3: n_cmpt3.hh n_cmpt3.cc
+ g++ -I../../.. -Wall -W -Wextra n_cmpt3.cc -DNDEBUG -O1 -o n_cmpt3
+
debug: n_cmpt.hh n_cmpt.cc
- g++ -I../../.. -Wall -W -Wextra n_cmpt.cc -g -g3 -DNDEBUG -o n_cmpt
+ g++ -I../../.. -Wall -W -Wextra n_cmpt.cc -g -g3 -o n_cmpt
debug2: n_cmpt2.hh n_cmpt2.cc
- g++ -I../../.. -Wall -W -Wextra n_cmpt2.cc -g -g3 -DNDEBUG -o n_cmpt2
\ No newline at end of file
+ g++ -I../../.. -Wall -W -Wextra n_cmpt2.cc -g -g3 -o n_cmpt2
+
+debug3: n_cmpt3.hh n_cmpt3.cc
+ g++ -I../../.. -Wall -W -Wextra n_cmpt3.cc -g -g3 -o n_cmpt3
Index: jardonnet/n_cmpt/check/test4.pgm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: jardonnet/n_cmpt/check/test4.pgm
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
1
0
* canvas/browsing/dir_struct_elt_incr_update.hh,
* core/image/image1d.hh,
* core/image/image2d.hh,
* core/internal/image_base.hh,
* geom/max_col.hh,
* geom/max_ind.hh,
* geom/max_row.hh,
* geom/max_sli.hh,
* geom/min_col.hh,
* geom/min_ind.hh,
* geom/min_row.hh,
* geom/min_sli.hh,
* io/pbm/load.hh,
* io/pfm/load.hh,
* io/pfm/save.hh,
* io/pnm/load.hh,
* linear/gaussian.hh,
* subsampling/gaussian_subsampling.hh,
* subsampling/subsampling.hh: Use mln_deduce(I, site, coord) instead
of mln_coord(I) which is not valid anymore.
---
milena/ChangeLog | 25 +++++++++++++
.../canvas/browsing/dir_struct_elt_incr_update.hh | 2 +-
milena/mln/core/image/image1d.hh | 3 --
milena/mln/core/image/image2d.hh | 15 +++-----
milena/mln/core/internal/image_base.hh | 3 --
milena/mln/geom/max_col.hh | 12 +++---
milena/mln/geom/max_ind.hh | 14 ++++----
milena/mln/geom/max_row.hh | 18 +++++-----
milena/mln/geom/max_sli.hh | 14 ++++----
milena/mln/geom/min_col.hh | 18 +++++-----
milena/mln/geom/min_ind.hh | 14 ++++----
milena/mln/geom/min_row.hh | 12 +++---
milena/mln/geom/min_sli.hh | 14 ++++----
milena/mln/io/pbm/load.hh | 39 +++++++++-----------
milena/mln/io/pfm/load.hh | 4 +-
milena/mln/io/pfm/save.hh | 4 +-
milena/mln/io/pnm/load.hh | 2 +-
milena/mln/linear/gaussian.hh | 31 ++++++++--------
milena/mln/subsampling/gaussian_subsampling.hh | 19 ++++------
milena/mln/subsampling/subsampling.hh | 24 +++++-------
20 files changed, 146 insertions(+), 141 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 8fa2f02..c4ee716 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,30 @@
2008-12-02 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Fix wrong use of mln_coord().
+
+ * canvas/browsing/dir_struct_elt_incr_update.hh,
+ * core/image/image1d.hh,
+ * core/image/image2d.hh,
+ * core/internal/image_base.hh,
+ * geom/max_col.hh,
+ * geom/max_ind.hh,
+ * geom/max_row.hh,
+ * geom/max_sli.hh,
+ * geom/min_col.hh,
+ * geom/min_ind.hh,
+ * geom/min_row.hh,
+ * geom/min_sli.hh,
+ * io/pbm/load.hh,
+ * io/pfm/load.hh,
+ * io/pfm/save.hh,
+ * io/pnm/load.hh,
+ * linear/gaussian.hh,
+ * subsampling/gaussian_subsampling.hh,
+ * subsampling/subsampling.hh: Use mln_deduce(I, site, coord) instead
+ of mln_coord(I) which is not valid anymore.
+
+2008-12-02 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Fix tutorial generation.
* doc/Doxyfile.in: add a missing example path.
diff --git a/milena/mln/canvas/browsing/dir_struct_elt_incr_update.hh b/milena/mln/canvas/browsing/dir_struct_elt_incr_update.hh
index a5cc7fd..b62ddfe 100644
--- a/milena/mln/canvas/browsing/dir_struct_elt_incr_update.hh
+++ b/milena/mln/canvas/browsing/dir_struct_elt_incr_update.hh
@@ -110,7 +110,7 @@ namespace mln
pmin = f.input.domain().pmin(),
pmax = f.input.domain().pmax();
- const mln_coord(I)
+ const mln_deduce(I, site, coord)
pmin_dir = pmin[f.dir],
pmax_dir = pmax[f.dir],
pmin_dir_plus_half_length = pmin_dir + f.length / 2,
diff --git a/milena/mln/core/image/image1d.hh b/milena/mln/core/image/image1d.hh
index 27f7d39..4e5bbf5 100644
--- a/milena/mln/core/image/image1d.hh
+++ b/milena/mln/core/image/image1d.hh
@@ -130,9 +130,6 @@ namespace mln
{
typedef internal::image_primary< T, mln::box1d, image1d<T> > super_;
- /// Coordinate associated type.
- typedef int coord;
-
/// Value associated type.
typedef T value;
diff --git a/milena/mln/core/image/image2d.hh b/milena/mln/core/image/image2d.hh
index e1a6e5a..b58dfed 100644
--- a/milena/mln/core/image/image2d.hh
+++ b/milena/mln/core/image/image2d.hh
@@ -123,21 +123,18 @@ namespace mln
- /*! \brief Basic 2D image class.
- *
- * The parameter \c T is the type of pixel values. This image class
- * stores data in memory and has a virtual border with constant
- * thickness around data.
- */
+ /// Basic 2D image class.
+ ///
+ /// The parameter \c T is the type of pixel values. This image class
+ /// stores data in memory and has a virtual border with constant
+ /// thickness around data.
+ ///
template <typename T>
class image2d : public internal::image_primary< T, mln::box2d, image2d<T> >
{
typedef internal::image_primary< T, mln::box2d, image2d<T> > super_;
public:
- /// Coordinate associated type.
- typedef int coord;
-
/// Value associated type.
typedef T value;
diff --git a/milena/mln/core/internal/image_base.hh b/milena/mln/core/internal/image_base.hh
index 20eb39b..d940291 100644
--- a/milena/mln/core/internal/image_base.hh
+++ b/milena/mln/core/internal/image_base.hh
@@ -84,9 +84,6 @@ namespace mln
public image_checked_<E>
{
- /// Coordinate associated type.
- typedef mln_deduce(S, site, coord) coord;
-
/// Value associated type.
typedef T value;
diff --git a/milena/mln/geom/max_col.hh b/milena/mln/geom/max_col.hh
index 31cbb9a..ca7c305 100644
--- a/milena/mln/geom/max_col.hh
+++ b/milena/mln/geom/max_col.hh
@@ -1,4 +1,5 @@
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_GEOM_MAX_COL_HH
# define MLN_GEOM_MAX_COL_HH
-/*! \file mln/geom/max_col.hh
- *
- * \brief Give the maximum column of an image.
- */
+/// \file mln/geom/max_col.hh
+///
+/// Give the maximum column of an image.
# include <mln/core/concept/image.hh>
# include <mln/geom/bbox.hh>
@@ -49,7 +49,7 @@ namespace mln
/// Give the maximum col of an box 2d or 3d.
template <typename B>
- mln_coord(B::point) max_col(const Box<B>& b);
+ mln_deduce(B, point, coord) max_col(const Box<B>& b);
# ifndef MLN_INCLUDE_ONLY
@@ -64,7 +64,7 @@ namespace mln
template <typename B>
inline
- mln_coord(B::point) max_col(const Box<B>& b)
+ mln_deduce(B, point, coord) max_col(const Box<B>& b)
{
metal::not_<metal::equal<metal::int_<B::dim>, metal::int_<1> > >::check();
return exact(b).pmax().col();
diff --git a/milena/mln/geom/max_ind.hh b/milena/mln/geom/max_ind.hh
index 4ff4303..9a794e0 100644
--- a/milena/mln/geom/max_ind.hh
+++ b/milena/mln/geom/max_ind.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_GEOM_MAX_IND_HH
# define MLN_GEOM_MAX_IND_HH
-/*! \file mln/geom/max_ind.hh
- *
- * \brief Give the maximum ind of an image.
- */
+/// \file mln/geom/max_ind.hh
+///
+/// Give the maximum ind of an image.
# include <mln/core/concept/image.hh>
@@ -44,14 +44,14 @@ namespace mln
/// Give the maximum ind of an image.
template <typename I>
- mln_coord(I) max_ind(const Image<I>& ima);
+ mln_deduce(I, site, coord) max_ind(const Image<I>& ima);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
inline
- mln_coord(I) max_ind(const Image<I>& ima)
+ mln_deduce(I, site, coord) max_ind(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
return exact(ima).bbox().pmax().ind();
diff --git a/milena/mln/geom/max_row.hh b/milena/mln/geom/max_row.hh
index 5697a4a..ba6bc00 100644
--- a/milena/mln/geom/max_row.hh
+++ b/milena/mln/geom/max_row.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_GEOM_MAX_ROW_HH
# define MLN_GEOM_MAX_ROW_HH
-/*! \file mln/geom/max_row.hh
- *
- * \brief Give the maximum row of an image.
- */
+/// \file mln/geom/max_row.hh
+///
+/// Give the maximum row of an image.
# include <mln/core/concept/image.hh>
# include <mln/geom/bbox.hh>
@@ -45,18 +45,18 @@ namespace mln
/// Give the maximum row of an image.
template <typename I>
- mln_coord(I) max_row(const Image<I>& ima);
+ mln_deduce(I, site, coord) max_row(const Image<I>& ima);
/// Give the maximum row of an box 2d or 3d.
template <typename B>
- mln_coord(B::point) max_row(const Box<B>& b);
+ mln_deduce(B, point, coord) max_row(const Box<B>& b);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
inline
- mln_coord(I) max_row(const Image<I>& ima)
+ mln_deduce(I, site, coord) max_row(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
return geom::bbox(ima).pmax().row();
@@ -65,7 +65,7 @@ namespace mln
template <typename B>
inline
- mln_coord(B::point) max_row(const Box<B>& b)
+ mln_deduce(B, point, coord) max_row(const Box<B>& b)
{
metal::not_<metal::equal<metal::int_<B::dim>, metal::int_<1> > >::check();
return exact(b).pmax().row();
diff --git a/milena/mln/geom/max_sli.hh b/milena/mln/geom/max_sli.hh
index 86deba5..2556d78 100644
--- a/milena/mln/geom/max_sli.hh
+++ b/milena/mln/geom/max_sli.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_GEOM_MAX_SLI_HH
# define MLN_GEOM_MAX_SLI_HH
-/*! \file mln/geom/max_sli.hh
- *
- * \brief Give the maximum sli of an image.
- */
+/// \file mln/geom/max_sli.hh
+///
+/// Give the maximum sli of an image.
# include <mln/core/concept/image.hh>
@@ -44,14 +44,14 @@ namespace mln
/// Give the maximum sli of an image.
template <typename I>
- mln_coord(I) max_sli(const Image<I>& ima);
+ mln_deduce(I, site, coord) max_sli(const Image<I>& ima);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
inline
- mln_coord(I) max_sli(const Image<I>& ima)
+ mln_deduce(I, site, coord) max_sli(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
return exact(ima).bbox().pmax().sli();
diff --git a/milena/mln/geom/min_col.hh b/milena/mln/geom/min_col.hh
index 6993d6f..1e01a93 100644
--- a/milena/mln/geom/min_col.hh
+++ b/milena/mln/geom/min_col.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_GEOM_MIN_COL_HH
# define MLN_GEOM_MIN_COL_HH
-/*! \file mln/geom/min_col.hh
- *
- * \brief Give the minimum column of an image.
- */
+/// \file mln/geom/min_col.hh
+///
+/// Give the minimum column of an image.
# include <mln/core/concept/image.hh>
# include <mln/geom/bbox.hh>
@@ -45,18 +45,18 @@ namespace mln
/// Give the minimum column of an image.
template <typename I>
- mln_coord(I) min_col(const Image<I>& ima);
+ mln_deduce(I, site, coord) min_col(const Image<I>& ima);
/// Give the minimum column of an box 2d or 3d.
template <typename B>
- mln_coord(B::point) min_col(const Box<B>& b);
+ mln_deduce(B, point, coord) min_col(const Box<B>& b);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
inline
- mln_coord(I) min_col(const Image<I>& ima)
+ mln_deduce(I, site, coord) min_col(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
return geom::bbox(ima).pmin().col();
@@ -65,7 +65,7 @@ namespace mln
template <typename B>
inline
- mln_coord(B::point) min_col(const Box<B>& b)
+ mln_deduce(B, point, coord) min_col(const Box<B>& b)
{
metal::not_<metal::equal<metal::int_<B::dim>, metal::int_<1> > >::check();
return exact(b).pmin().col();
diff --git a/milena/mln/geom/min_ind.hh b/milena/mln/geom/min_ind.hh
index ce84967..abf4ecd 100644
--- a/milena/mln/geom/min_ind.hh
+++ b/milena/mln/geom/min_ind.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_GEOM_MIN_IND_HH
# define MLN_GEOM_MIN_IND_HH
-/*! \file mln/geom/min_ind.hh
- *
- * \brief Give the minimum ind of an image.
- */
+/// \file mln/geom/min_ind.hh
+///
+/// Give the minimum ind of an image.
# include <mln/core/concept/image.hh>
@@ -44,14 +44,14 @@ namespace mln
/// Give the minimum ind of an image.
template <typename I>
- mln_coord(I) min_ind(const Image<I>& ima);
+ mln_deduce(I, site, coord) min_ind(const Image<I>& ima);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
inline
- mln_coord(I) min_ind(const Image<I>& ima)
+ mln_deduce(I, site, coord) min_ind(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
return exact(ima).bbox().pmin().ind();
diff --git a/milena/mln/geom/min_row.hh b/milena/mln/geom/min_row.hh
index 5f2c191..e0878de 100644
--- a/milena/mln/geom/min_row.hh
+++ b/milena/mln/geom/min_row.hh
@@ -1,4 +1,5 @@
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_GEOM_MIN_ROW_HH
# define MLN_GEOM_MIN_ROW_HH
-/*! \file mln/geom/min_row.hh
- *
- * \brief Give the minimum row of an image.
- */
+/// \file mln/geom/min_row.hh
+///
+/// Give the minimum row of an image.
# include <mln/core/concept/image.hh>
# include <mln/geom/bbox.hh>
@@ -52,7 +52,7 @@ namespace mln
/// Give the minimum row of an box 2d or 3d.
template <typename B>
- mln_coord(B::point) min_row(const Box<B>& b);
+ mln_deduce(B, point, coord) min_row(const Box<B>& b);
# ifndef MLN_INCLUDE_ONLY
@@ -68,7 +68,7 @@ namespace mln
template <typename B>
inline
- mln_coord(B::point) min_row(const Box<B>& b)
+ mln_deduce(B, point, coord) min_row(const Box<B>& b)
{
metal::not_<metal::equal<metal::int_<B::dim>, metal::int_<1> > >::check();
return exact(b).pmin().row();
diff --git a/milena/mln/geom/min_sli.hh b/milena/mln/geom/min_sli.hh
index 303117d..a01de7d 100644
--- a/milena/mln/geom/min_sli.hh
+++ b/milena/mln/geom/min_sli.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_GEOM_MIN_SLI_HH
# define MLN_GEOM_MIN_SLI_HH
-/*! \file mln/geom/min_sli.hh
- *
- * \brief Give the minimum sli of an image.
- */
+/// \file mln/geom/min_sli.hh
+///
+/// Give the minimum sli of an image.
# include <mln/core/concept/image.hh>
@@ -44,14 +44,14 @@ namespace mln
/// Give the minimum sli of an image.
template <typename I>
- mln_coord(I) min_sli(const Image<I>& ima);
+ mln_deduce(I, site, coord) min_sli(const Image<I>& ima);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
inline
- mln_coord(I) min_sli(const Image<I>& ima)
+ mln_deduce(I, site, coord) min_sli(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
return exact(ima).bbox().pmin().sli();
diff --git a/milena/mln/io/pbm/load.hh b/milena/mln/io/pbm/load.hh
index b2ba586..9a16638 100644
--- a/milena/mln/io/pbm/load.hh
+++ b/milena/mln/io/pbm/load.hh
@@ -1,5 +1,5 @@
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 EPITA
-// Research and Development Laboratory
+// Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -29,13 +29,10 @@
#ifndef MLN_IO_PBM_LOAD_HH
# define MLN_IO_PBM_LOAD_HH
-/*!
- * \file mln/io/pbm/load.hh
- *
- * \brief Define a function which loads an image of kind pbm with
- * given path.
- *
- */
+/// \file mln/io/pbm/load.hh
+///
+/// Define a function which loads an image of kind pbm with
+/// given path.
# include <iostream>
@@ -55,21 +52,21 @@ namespace mln
{
- /*! Load a pbm image in a Milena image.
- *
- * \param[out] ima A reference to the image2d<bool> which will receive
- * data.
- * \param[in] filename The source.
- */
+ /// Load a pbm image in a Milena image.
+ ///
+ /// \param[out] ima A reference to the image2d<bool> which will receive
+ /// data.
+ /// \param[in] filename The source.
+ ///
void load(image2d<bool>& ima,
const std::string& filename);
- /*! Load a pbm image in a image2d<float>.
- *
- * \param[in] filename The image source.
- *
- * \return An image2d<float> which contains loaded data.
- */
+ /// Load a pbm image in a image2d<float>.
+ ///
+ /// \param[in] filename The image source.
+ ///
+ /// \return An image2d<float> which contains loaded data.
+ ///
image2d<bool> load(const std::string& filename);
# ifndef MLN_INCLUDE_ONLY
@@ -102,7 +99,7 @@ namespace mln
{
point2d p = point2d(0, ima.domain().pmin().col());
typedef mln_value(I) V;
- const mln_coord(I)
+ const mln_deduce(I, site, coord)
min_row = geom::min_row(ima),
max_row = geom::max_row(ima),
min_col = geom::min_col(ima),
diff --git a/milena/mln/io/pfm/load.hh b/milena/mln/io/pfm/load.hh
index 96bc20d..5ea3a23 100644
--- a/milena/mln/io/pfm/load.hh
+++ b/milena/mln/io/pfm/load.hh
@@ -1,5 +1,5 @@
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 EPITA
-// Research and Development Laboratory
+// 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
@@ -124,7 +124,7 @@ namespace mln
{
point2d p = point2d(0, 0);
- const mln_coord(I)
+ const mln_deduce(I, site, coord)
min_row = geom::min_row(ima),
max_row = geom::max_row(ima);
diff --git a/milena/mln/io/pfm/save.hh b/milena/mln/io/pfm/save.hh
index 53f18e6..1743e20 100644
--- a/milena/mln/io/pfm/save.hh
+++ b/milena/mln/io/pfm/save.hh
@@ -1,5 +1,5 @@
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 EPITA
-// Research and Development Laboratory
+// 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
@@ -89,7 +89,7 @@ namespace mln
unsigned int
ncols = geom::ncols(ima);
- const mln_coord(I)
+ const mln_deduce(I, site, coord)
min_row = geom::min_row(ima),
max_row = geom::max_row(ima);
diff --git a/milena/mln/io/pnm/load.hh b/milena/mln/io/pnm/load.hh
index d2c2f6b..ed5e3c5 100644
--- a/milena/mln/io/pnm/load.hh
+++ b/milena/mln/io/pnm/load.hh
@@ -123,7 +123,7 @@ namespace mln
{
point2d p = point2d(0, ima.domain().pmin().col());
typedef mln_value(I) V;
- const mln_coord(I)
+ const mln_deduce(I, site, coord)
min_row = geom::min_row(ima),
max_row = geom::max_row(ima);
diff --git a/milena/mln/linear/gaussian.hh b/milena/mln/linear/gaussian.hh
index 70efc64..88f30a2 100644
--- a/milena/mln/linear/gaussian.hh
+++ b/milena/mln/linear/gaussian.hh
@@ -1,5 +1,5 @@
// Copyright (C) 2001, 2002, 2003, 2004, 2008 EPITA Research and
-// Laboratory
+// Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -29,13 +29,12 @@
#ifndef MLN_LINEAR_GAUSSIAN_HH
# define MLN_LINEAR_GAUSSIAN_HH
-/*! \file mln/linear/gaussian.hh
- *
- * \brief Gaussian filter.
- *
- * \todo Add a clean reference David Deriche
- * Recursively implementing the gaussian and its derivatives (1993)
- */
+/// \file mln/linear/gaussian.hh
+///
+/// Gaussian filter.
+///
+/// \todo Add a clean reference David Deriche
+/// Recursively implementing the gaussian and its derivatives (1993)
# include <mln/core/concept/image.hh>
# include <mln/core/alias/point2d.hh>
@@ -61,10 +60,10 @@ namespace mln
namespace linear
{
- /*! Gaussian filter of an image \p input
- *
- * \pre output.domain = input.domain
- */
+ /// Gaussian filter of an image \p input
+ ///
+ /// \pre output.domain = input.domain
+ ///
template <class I>
mln_concrete(I)
gaussian(const Image<I>& input, float sigma);
@@ -84,9 +83,9 @@ namespace mln
struct recursivefilter_coef_
{
- /*!
- ** \brief Constructor.
- */
+ ///
+ /// Constructor.
+ ///
recursivefilter_coef_(float a0, float a1,
float b0, float b1,
float c0, float c1,
@@ -205,7 +204,7 @@ namespace mln
- c.d[3] * tmp1[0];
mln_psite(I) current(start + d + d + d + d);
- for (mln_coord(I) i = 4; i < len; ++i)
+ for (mln_deduce(I, site, coord) i = 4; i < len; ++i)
{
tmp1[i] =
c.n[0] * ima(current)
diff --git a/milena/mln/subsampling/gaussian_subsampling.hh b/milena/mln/subsampling/gaussian_subsampling.hh
index 09d8e53..b4aa2e0 100644
--- a/milena/mln/subsampling/gaussian_subsampling.hh
+++ b/milena/mln/subsampling/gaussian_subsampling.hh
@@ -1,4 +1,5 @@
// Copyright (C) 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_SUBSAMPLING_GAUSSIAN_SUBSAMPLING_HH
# define MLN_SUBSAMPLING_GAUSSIAN_SUBSAMPLING_HH
-/*! \file mln/binarization/threshold.hh
- *
- * \brief Produce a subsampled image
- */
+/// \file mln/binarization/threshold.hh
+///
+/// Produce a subsampled image
# include <mln/geom/ncols.hh>
# include <mln/geom/nrows.hh>
@@ -46,18 +46,15 @@ namespace mln
{
namespace subsampling
- {
+ {
- /*! Gaussian subsampling FIXME : doxy
- *
- *
- */
+ /// Gaussian subsampling FIXME : doxy
template <typename I>
inline
mln_concrete(I)
gaussian_subsampling(const Image<I>& input, float sigma
const mln_dpsite(I)& first_p,
- const mln_coord(I)& gap);
+ const mln_deduce(I, site, coord)& gap);
# ifndef MLN_INCLUDE_ONLY
@@ -67,7 +64,7 @@ namespace mln
mln_concrete(I)
gaussian_subsampling(const Image<I>& input, float sigma,
const mln_dpsite(I)& first_p,
- const mln_coord(I)& gap)
+ const mln_deduce(I, site, coord)& gap)
{
trace::entering("subsampling::gaussian_subsampling");
mln_precondition(exact(input).has_data());
diff --git a/milena/mln/subsampling/subsampling.hh b/milena/mln/subsampling/subsampling.hh
index cc36334..11a5944 100644
--- a/milena/mln/subsampling/subsampling.hh
+++ b/milena/mln/subsampling/subsampling.hh
@@ -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,10 +28,9 @@
#ifndef MLN_SUBSAMPLING_SUBSAMPLING_HH
# define MLN_SUBSAMPLING_SUBSAMPLING_HH
-/*! \file mln/binarization/threshold.hh
- *
- * \brief Produce a subsampled image
- */
+/// \file mln/binarization/threshold.hh
+///
+/// Produce a subsampled image
# include <mln/geom/ncols.hh>
# include <mln/geom/nrows.hh>
@@ -41,18 +40,15 @@ namespace mln
{
namespace subsampling
- {
+ {
- /*! Subsampling FIXME : doxy
- *
- *
- */
+ /// Subsampling FIXME : doxy
template <typename I>
inline
mln_concrete(I)
subsampling(const Image<I>& input,
const mln_deduce(I, site, delta)& first_p,
- const mln_coord(I)& gap);
+ const mln_deduce(I, site, coord)& gap);
# ifndef MLN_INCLUDE_ONLY
@@ -77,7 +73,7 @@ namespace mln
{
point2d p1(i, j);
point2d p2(first_p[0] + i * gap, first_p[1] + j * gap);
-
+
output(p1) = input(p2);
}
@@ -93,14 +89,14 @@ namespace mln
mln_concrete(I)
subsampling(const Image<I>& input,
const mln_deduce(I, site, delta)& first_p,
- const mln_coord(I)& gap)
+ const mln_deduce(I, site, coord)& gap)
{
trace::entering("subsampling::subsampling");
mln_precondition(exact(input).has_data());
mln_concrete(I) output(geom::nrows(input) / gap,
geom::ncols(input) / gap); // FIXME: only 2d here
-
+
output = impl::subsampling_(exact(input), first_p, gap);
trace::exiting("subsampling::subsampling");
--
1.5.6.5
1
0
* doc/Doxyfile.in: add a missing example path.
* doc/tutorial/outputs/ima2d-decl-2-blobs.txt: remove since
generated.
* doc/tutorial/tutorial.tex: fix wrong includes.
---
milena/ChangeLog | 14 +++++++-
milena/doc/Doxyfile.in | 1 +
milena/doc/tutorial/outputs/ima2d-decl-2-blobs.txt | 7 ----
milena/doc/tutorial/tutorial.tex | 36 ++++++++++----------
4 files changed, 32 insertions(+), 26 deletions(-)
delete mode 100644 milena/doc/tutorial/outputs/ima2d-decl-2-blobs.txt
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 6913b27..8fa2f02 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,15 @@
+2008-12-02 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Fix tutorial generation.
+
+ * doc/Doxyfile.in: add a missing example path.
+
+ * doc/tutorial/outputs/ima2d-decl-2-blobs.txt: remove since
+ generated.
+
+ * doc/tutorial/tutorial.tex: fix wrong includes.
+
+
2008-12-01 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Make doc examples tuto_one compile again.
@@ -52,7 +64,7 @@
Fix more tests.
* mln/accu/count_adjacent_vertices.hh: make it work with the
-new graph images.
+ new graph images.
* mln/accu/median_alt.hh: fix compilation issue.
diff --git a/milena/doc/Doxyfile.in b/milena/doc/Doxyfile.in
index e56c529..bc28c77 100644
--- a/milena/doc/Doxyfile.in
+++ b/milena/doc/Doxyfile.in
@@ -86,6 +86,7 @@ EXCLUDE_SYMLINKS = YES
EXCLUDE_PATTERNS = *spe.hh
EXCLUDE_SYMBOLS =
EXAMPLE_PATH = @top_srcdir@/milena/doc/tutorial/samples \
+ @top_builddir@/milena/doc/tutorial/samples \
@top_builddir@/milena/doc/tutorial/outputs \
@top_builddir@/milena/doc/tutorial/outputs/splitted \
@top_srcdir@/milena/doc/tutorial/outputs
diff --git a/milena/doc/tutorial/outputs/ima2d-decl-2-blobs.txt b/milena/doc/tutorial/outputs/ima2d-decl-2-blobs.txt
deleted file mode 100644
index b48c715..0000000
--- a/milena/doc/tutorial/outputs/ima2d-decl-2-blobs.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-0 1 1 0 0
-0 1 1 0 0
-0 0 0 0 0
-2 2 0 3 0
-2 0 3 3 3
-2 0 0 0 0
-
diff --git a/milena/doc/tutorial/tutorial.tex b/milena/doc/tutorial/tutorial.tex
index 49ef8a1..1c4bb16 100644
--- a/milena/doc/tutorial/tutorial.tex
+++ b/milena/doc/tutorial/tutorial.tex
@@ -94,9 +94,9 @@ showstringspaces=false,linewidth=14cm}
\backslash htmlonly%
}
-\newcommand{\doxyfigure}[2]{
+\newcommand{\doxyfigure}[3][1]{
\backslash endhtmlonly%
-\backslash image html #1.png%
+\backslash image html #2-#1.png%
\backslash htmlonly%
}
@@ -122,8 +122,8 @@ $$
\renewcommand{\doxyrawcode}[1]{\lstinputlisting[frame=single]{samples/#1.cc.raw}}
\renewcommand{\doxyoutput}[1]{\lstinputlisting[frame=single]{outputs/#1.txt}}
\renewcommand{\doxymoutput}[2][1]{\lstinputlisting[frame=single]{outputs/splitted/#2-#1.txt}}
-\renewcommand{\doxyfigure}[2]{%
-\pgfimage[width=#2]{figures/#1}%
+\renewcommand{\doxyfigure}[3][1]{%
+\pgfimage[width=#3]{figures/#2-#1}%
\label{#1}%
}
\renewenvironment{doxymath}
@@ -800,7 +800,7 @@ Output:
\bigskip
\begin{tabular}{c c}
-\doxyfigure{ima2d-rot-1}{3cm} & \doxyfigure{ima2d-rot-2}{3cm} \\
+\doxyfigure[1]{ima2d-rot}{3cm} & \doxyfigure[2]{ima2d-rot}{3cm} \\
\multicolumn{2}{c}{\var{ima1} and its border before rotation (left) and \var{ima2}
and its border after rotation (right).} \\
\end{tabular}
@@ -1053,7 +1053,7 @@ These predefined neighborhood can be passed directly to a function. The headers
located in \header{mln/core/alias/neigh*.hh}.
Use case example:
-\doxycode{ima2d-decl-2-blobs}
+\doxycode[2]{labeling-compute}
\doxysubsection{customse}{Custom structural elements}
@@ -1439,7 +1439,7 @@ Consider the following image:
Output: \\
\begin{center}
-\doxyfigure{labeling-compute-1}{3cm}
+\doxyfigure[1]{labeling-compute}{3cm}
\end{center}
Then label this image thanks to \code{labeling::blobs()}:
@@ -1448,7 +1448,7 @@ Then label this image thanks to \code{labeling::blobs()}:
Output: \\
\begin{center}
-\doxyfigure{labeling-compute-2}{3cm}
+\doxyfigure[2]{labeling-compute}{3cm}
\end{center}
Note that this routine returns the number of components in its third parameter.
@@ -1480,14 +1480,14 @@ Example:
Make a binary image:
\doxycode[1]{logical-not}
\begin{center}
-\doxyfigure{logical-not-1}{3cm}
+\doxyfigure[1]{logical-not}{3cm}
\end{center}
Return the result in a new image:
\doxycode[2]{logical-not}
\begin{center}
\begin{tabular}{c c}
-\doxyfigure{logical-not-1}{3cm} & \doxyfigure{logical-not-2}{3cm} \\
+\doxyfigure[1]{logical-not}{3cm} & \doxyfigure[2]{logical-not}{3cm} \\
\multicolumn{2}{c}{\var{ima} (left) and \var{ima_neg} (right) after having
called logical::not\_().} \\
\end{tabular}
@@ -1497,7 +1497,7 @@ Or, work in place:
\doxycode[3]{logical-not}
Then, \var{ima} looks like:
\begin{center}
-\doxyfigure{logical-not-3}{3cm}
+\doxyfigure[3]{logical-not}{3cm}
\end{center}
@@ -1590,7 +1590,7 @@ Consider the following image:
Then label this image thanks to \code{labeling::blobs()}:
\doxycode[2]{labeling-compute}
Output:
-\doxymoutput[1]{labeling-compute}
+\doxyfigure[2]{labeling-compute}{3cm}
Then, use \code{labeling::compute()} with the bbox accumulator:
\doxycode[3]{labeling-compute}
@@ -1603,7 +1603,7 @@ In this case, it returns an array of \type{box2d}.
set the background to 0, we will want to iterate from 1 to nlabels included.
\doxycode[4]{labeling-compute}
Output:
-\doxymoutput[2]{labeling-compute}
+\doxyoutput{labeling-compute}
\subsection{Routines based on accumulators and *::compute()}
@@ -1670,7 +1670,7 @@ following declaration:
\doxycode[1]{fill-part-image}
Output:
\begin{center}
-\doxyfigure{fill-subdomain-1}{3cm}
+\doxyfigure[1]{fill-subdomain}{3cm}
\end{center}
\doxysubsection{restrictsiteset}{Restrict an image with a site set}
@@ -1688,7 +1688,7 @@ First, find and label the components.
\doxycode[2]{fill-subdomain}
Output:
\begin{center}
-\doxyfigure{fill-subdomain-2}{3cm}
+\doxyfigure[2]{fill-subdomain}{3cm}
\end{center}
Then, restrict the image to the sites being part of component 2.
@@ -1696,7 +1696,7 @@ Then, restrict the image to the sites being part of component 2.
\var{lbl\_2} is a new image. \var{lbl\_2} looks like:
\begin{center}
-\doxyfigure{fill-subdomain-3}{3cm}
+\doxyfigure[3]{fill-subdomain}{3cm}
\end{center}
Finally, create a new color image, fill it with black and fill the sites part of
@@ -1704,7 +1704,7 @@ component 2 with red.
\doxycode[4]{fill-subdomain}
Output:
\begin{center}
-\doxyfigure{fill-subdomain-4}{3cm}
+\doxyfigure[4]{fill-subdomain}{3cm}
\end{center}
The previous example can be written more quickly:
@@ -1722,7 +1722,7 @@ Restrict the image with it:
Output:
\begin{center}
-\doxyfigure{fill-subimage-cfun-1}{3cm}
+\doxyfigure[1]{fill-subimage-cfun}{3cm}
\end{center}
%
\medskip
--
1.5.6.5
1
0
* scribo/demat.hh: Remove components which does not include more than
3 bounding boxes.
---
milena/sandbox/ChangeLog | 7 +++
milena/sandbox/scribo/demat.hh | 84 ++++++++++++++++++++++++++++++---------
2 files changed, 71 insertions(+), 20 deletions(-)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index c2d4117..26a5bb7 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,3 +1,10 @@
+2008-12-02 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Improve component cleanup.
+
+ * scribo/demat.hh: Remove components which does not include more than
+ 3 bounding boxes.
+
2008-12-01 Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
N components extraction based on value iterator.
diff --git a/milena/sandbox/scribo/demat.hh b/milena/sandbox/scribo/demat.hh
index 8b59a11..88ae58a 100644
--- a/milena/sandbox/scribo/demat.hh
+++ b/milena/sandbox/scribo/demat.hh
@@ -82,6 +82,7 @@ namespace scribo
unsigned max_dist_lines;
int max_txt_box_height;
unsigned rank_filter;
+ bool treat_tables;
};
@@ -159,7 +160,7 @@ namespace scribo
void save_lbl_image(const image2d<V>& lbl, unsigned nlabels,
const char *filename)
{
- image2d<rgb8> output = debug::colorize<image2d<rgb8>, image2d<V> >(lbl, nlabels);
+ image2d<rgb8> output = debug::colorize(rgb8(), lbl, nlabels);
io::ppm::save(output, output_file(filename));
}
@@ -318,12 +319,12 @@ namespace scribo
/// Connect lines if they are close to each other.
void
- connect_lines(const image2d<bool>& in,
- const util::array<int>& aligned_lines,
+ connect_lines(const util::array<int>& aligned_lines,
util::array<box2d>& boxes,
- unsigned dim)
+ unsigned dim,
+ unsigned dim_size)
{
- image1d<int> l(in.nrows());
+ image1d<int> l(dim_size);
level::fill(l, -1);
for_all_elements(i, aligned_lines)
@@ -360,8 +361,8 @@ namespace scribo
geom::max_col(in), tblboxes.first,
1);
- connect_lines(in, rows, tblboxes.first, 0);
- connect_lines(in, cols, tblboxes.second, 1);
+ connect_lines(rows, tblboxes.first, 0, in.nrows());
+ connect_lines(cols, tblboxes.second, 1, in.ncols());
image2d<bool> res;
initialize(res, in);
@@ -534,7 +535,7 @@ namespace scribo
// Lignes verticales
std::cout << "Removing vertical lines" << std::endl;
win::vline2d vline(settings.ero_line_width);
- image2d<bool> vfilter = morpho::rank_filter(in, win_c4p(), settings.rank_filter);
+ image2d<bool> vfilter = morpho::rank_filter(in, vline, settings.rank_filter);
#ifndef NOUT
io::pbm::save(vfilter, output_file("vertical-erosion.pbm"));
@@ -622,7 +623,7 @@ namespace scribo
/// Return false if the components is smaller than a given size.
bool operator()(const label16& l) const
{
- return nsitecomp_[l].first >= settings.min_comp_size;
+ return nsitecomp_[l] >= settings.min_comp_size;
}
const util::array<R>& nsitecomp_;
@@ -656,24 +657,27 @@ namespace scribo
void
cleanup_components(image2d<label16>& lbl,
- label16& nlabels, bool treat_tables)
+ label16& nlabels)
{
std::cout << "Cleanup components..." << std::endl;
typedef accu::count<mln_psite_(image2d<label16>)> accu_count_t;
typedef accu::bbox<mln_psite_(image2d<label16>)> accu_bbox_t;
typedef accu::pair<accu_count_t, accu_bbox_t> accu_pair_t;
- typedef mln_result_(accu_pair_t) accu_res_t;
- typedef util::array<accu_res_t> nsitecomp_t;
+ typedef mln_result_(accu_pair_t) accu_pair_res_t;
+ typedef mln_result_(accu_count_t) accu_count_res_t;
- nsitecomp_t nsitecomp = labeling::compute(accu_pair_t(), lbl, nlabels);
- if (treat_tables)
+ if (settings.treat_tables)
{
- remove_small_comps<accu_res_t> fl2b(nsitecomp);
+ typedef util::array<accu_count_res_t> nsitecomp_t;
+ nsitecomp_t nsitecomp = labeling::compute(accu_count_t(), lbl, nlabels);
+ remove_small_comps<accu_count_res_t> fl2b(nsitecomp);
labeling::relabel_inplace(lbl, nlabels, fl2b);
} else
{
- remove_smallandlarge_comps<accu_res_t> fl2b(nsitecomp);
+ typedef util::array<accu_pair_res_t> nsitecomp_t;
+ nsitecomp_t nsitecomp = labeling::compute(accu_pair_t(), lbl, nlabels);
+ remove_smallandlarge_comps<accu_pair_res_t> fl2b(nsitecomp);
labeling::relabel_inplace(lbl, nlabels, fl2b);
}
}
@@ -693,17 +697,54 @@ namespace scribo
tboxes[relabel_fun(i)].take(cboxes[i]);
//Update labels
+ //FIXME: use labeling::Relabel
level::transform_inplace(lbl, relabel_fun);
#ifndef NOUT
save_lbl_image(lbl, ncomp, "lbl-grouped-boxes.pgm");
#endif
+ //FIXME: use from_to
util::array<box2d> result;
for_all_ncomponents(i, ncomp)
if (tboxes[i].is_valid())
result.append(tboxes[i].to_result());
+#ifndef NOUT
+ image2d<label16> lbl2 = clone(lbl);
+ util::array<unsigned> treated(g.v_nmax(), mln_max(unsigned));
+ util::set<unsigned> comp_vertices;
+ mln_vertex_iter_(util::graph) v(g);
+ for_all(v)
+ if (treated[v.id()] == mln_max(unsigned))
+ {
+ std::queue<unsigned> queue;
+ queue.push(v.id());
+ comp_vertices.insert(v.id());
+ while (!queue.empty())
+ {
+ util::vertex<util::graph> current_v = g.vertex(queue.front());
+ queue.pop();
+ for (unsigned nv = 0; nv < current_v.nmax_nbh_vertices(); ++nv)
+ if (!comp_vertices.has(current_v.ith_nbh_vertex(nv)))
+ {
+ comp_vertices.insert(current_v.ith_nbh_vertex(nv));
+ queue.push(current_v.ith_nbh_vertex(nv));
+ }
+ }
+ unsigned compsize = comp_vertices.nelements();
+ for (unsigned i = 0; i < comp_vertices.nelements(); ++i)
+ treated[comp_vertices[i]] = compsize;
+ comp_vertices.clear();
+ }
+
+ for_all_ncomponents(i, ncomp)
+ if (tboxes[i].is_valid())
+ if (treated[i] < 3)
+ level::fill((lbl2 | (tboxes[i].to_result() | (pw::value(lbl2) == pw::cst(i)))).rw(), 0u);
+ save_lbl_image(lbl2, ncomp, "lbl-grouped-boxes-cleaned.pgm");
+#endif
+
return result;
}
@@ -789,7 +830,7 @@ namespace scribo
std::cout << "map text to cells" << std::endl;
label16 nlabels;
image2d<label16> tblelbl = labeling::background(table, c8(), nlabels);
- image2d<rgb8> color = debug::colorize<image2d<rgb8>, image2d<label16> >(tblelbl, nlabels);
+ image2d<rgb8> color = debug::colorize(rgb8(), tblelbl, nlabels);
# ifndef NOUT
io::ppm::save(color, output_file("cells-labels.ppm"));
@@ -826,10 +867,13 @@ namespace scribo
using value::rgb8;
using value::label16;
+
+ //Useful debug variables
border::thickness = 3;
trace::quiet = true;
- //Useful debug variables
+
+ internal::settings.treat_tables = treat_tables;
internal::input_file = basename(argv[1]);
//Load image
@@ -846,7 +890,7 @@ namespace scribo
//Label and remove small components.
label16 nlabels;
image2d<label16> lbl = labeling::blobs(in, c8(), nlabels);
- internal::cleanup_components(lbl, nlabels, treat_tables);
+ internal::cleanup_components(lbl, nlabels);
std::pair<util::array<box2d>,
util::array<box2d> > tblboxes;
@@ -859,7 +903,7 @@ namespace scribo
table = internal::rebuild_table(in, tblboxes);
lbl = labeling::blobs(in, c8(), nlabels);
- internal::cleanup_components(lbl, nlabels, treat_tables);
+ internal::cleanup_components(lbl, nlabels);
#ifndef NOUT
internal::save_lbl_image(lbl, nlabels, "lbl-small-comps-removed.pgm");
--
1.5.6.5
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Make doc examples tuto_one compile again.
* mln/core/concept/window.hh (mln_is_fastest_IW): New.
* mln/accu/transform_directional.hh,
* mln/accu/transform_diagonal.hh,
* mln/accu/transform.hh,
* mln/accu/transform_stop.hh,
* mln/accu/transform_snake.hh: Check in dispatch that win is
simple to choose the fastest specialization.
accu/transform.hh | 6 +++---
accu/transform_diagonal.hh | 12 ++++++------
accu/transform_directional.hh | 6 +++---
accu/transform_snake.hh | 6 +++---
accu/transform_stop.hh | 6 +++---
core/concept/window.hh | 7 +++++++
6 files changed, 25 insertions(+), 18 deletions(-)
Index: mln/core/concept/window.hh
--- mln/core/concept/window.hh (revision 2976)
+++ mln/core/concept/window.hh (working copy)
@@ -60,6 +60,13 @@
mln::trait::window::definition::unique) > >
+# define mln_is_fastest_IW(I, W) \
+ \
+mlc_and(mlc_is(mln_trait_image_speed(I), \
+ trait::image::speed::fastest), \
+ mln_is_simple_window(W))
+
+
namespace mln
{
Index: mln/accu/transform_directional.hh
--- mln/accu/transform_directional.hh (revision 2976)
+++ mln/accu/transform_directional.hh (working copy)
@@ -253,7 +253,7 @@
template <typename A, typename I, typename W>
inline
mln_ch_value(I, mln_result(A))
- transform_directional_dispatch(trait::image::speed::any,
+ transform_directional_dispatch(metal::false_,
const Accumulator<A>& a,
const Image<I>& input, const Window<W>& win,
unsigned dir)
@@ -267,7 +267,7 @@
template <typename A, typename I, typename W>
inline
mln_ch_value(I, mln_result(A))
- transform_directional_dispatch(trait::image::speed::fastest,
+ transform_directional_dispatch(metal::true_,
const Accumulator<A>& a,
const Image<I>& input, const Window<W>& win,
unsigned dir)
@@ -285,7 +285,7 @@
const Image<I>& input, const Window<W>& win,
unsigned dir)
{
- return transform_directional_dispatch(mln_trait_image_speed(I)(),
+ return transform_directional_dispatch(mln_is_fastest_IW(I, W)(),
a, input, win, dir);
}
Index: mln/accu/transform_diagonal.hh
--- mln/accu/transform_diagonal.hh (revision 2976)
+++ mln/accu/transform_diagonal.hh (working copy)
@@ -357,7 +357,7 @@
template <typename A, typename I>
inline
mln_ch_value(I, mln_result(A))
- transform_diagonal_dispatch(trait::image::speed::any,
+ transform_diagonal_dispatch(metal::false_,
const Accumulator<A>& a,
const Image<I>& input, const win::diag2d& win)
{
@@ -367,10 +367,10 @@
return f.output;
}
- template <typename A, typename I>
+ template <typename B, typename A, typename I>
inline
mln_ch_value(I, mln_result(A))
- transform_diagonal_dispatch(trait::image::speed::any,
+ transform_diagonal_dispatch(metal::false_,
const Accumulator<A>& a,
const Image<I>& input, const win::backdiag2d& win)
{
@@ -383,7 +383,7 @@
template <typename A, typename I>
inline
mln_ch_value(I, mln_result(A))
- transform_diagonal_dispatch(trait::image::speed::fastest,
+ transform_diagonal_dispatch(metal::true_,
const Accumulator<A>& a,
const Image<I>& input, const win::diag2d& win)
{
@@ -396,7 +396,7 @@
template <typename A, typename I>
inline
mln_ch_value(I, mln_result(A))
- transform_diagonal_dispatch(trait::image::speed::fastest,
+ transform_diagonal_dispatch(metal::true_,
const Accumulator<A>& a,
const Image<I>& input, const win::backdiag2d& win)
{
@@ -412,7 +412,7 @@
transform_diagonal_dispatch(const Accumulator<A>& a,
const Image<I>& input, const Window<W>& win)
{
- return transform_diagonal_dispatch(mln_trait_image_speed(I)(),
+ return transform_diagonal_dispatch(mln_is_fastest_IW(I, W)(),
a, input, exact(win));
}
Index: mln/accu/transform.hh
--- mln/accu/transform.hh (revision 2976)
+++ mln/accu/transform.hh (working copy)
@@ -154,7 +154,7 @@
template <typename I, typename A, typename W>
mln_ch_value(I, mln_result(A))
- transform_dispatch(trait::image::speed::any,
+ transform_dispatch(metal::false_,
const Image<I>& input, const Accumulator<A>& a, const Window<W>& win)
{
return impl::generic::transform(input, a, win);
@@ -162,7 +162,7 @@
template <typename I, typename A, typename W>
mln_ch_value(I, mln_result(A))
- transform_dispatch(trait::image::speed::fastest,
+ transform_dispatch(metal::true_,
const Image<I>& input, const Accumulator<A>& a, const Window<W>& win)
{
return impl::transform_fastest(input, a, win);
@@ -172,7 +172,7 @@
mln_ch_value(I, mln_result(A))
transform_dispatch(const Image<I>& input, const Accumulator<A>& a, const Window<W>& win)
{
- return transform_dispatch(mln_trait_image_speed(I)(),
+ return transform_dispatch(mln_is_fastest_IW(I, W)(),
input, a, win);
}
Index: mln/accu/transform_stop.hh
--- mln/accu/transform_stop.hh (revision 2976)
+++ mln/accu/transform_stop.hh (working copy)
@@ -158,7 +158,7 @@
template <typename I, typename A, typename W>
mln_ch_value(I, mln_result(A))
- transform_stop_dispatch(trait::image::speed::any,
+ transform_stop_dispatch(metal::false_,
const Image<I>& input, const Accumulator<A>& a, const Window<W>& win)
{
return impl::generic::transform_stop(input, a, win);
@@ -166,7 +166,7 @@
template <typename I, typename A, typename W>
mln_ch_value(I, mln_result(A))
- transform_stop_dispatch(trait::image::speed::fastest,
+ transform_stop_dispatch(metal::true_,
const Image<I>& input, const Accumulator<A>& a, const Window<W>& win)
{
return impl::transform_stop_fastest(input, a, win);
@@ -176,7 +176,7 @@
mln_ch_value(I, mln_result(A))
transform_stop_dispatch(const Image<I>& input, const Accumulator<A>& a, const Window<W>& win)
{
- return transform_stop_dispatch(mln_trait_image_speed(I)(),
+ return transform_stop_dispatch(mln_is_fastest_IW(I, W)(),
input, a, win);
}
Index: mln/accu/transform_snake.hh
--- mln/accu/transform_snake.hh (revision 2976)
+++ mln/accu/transform_snake.hh (working copy)
@@ -395,7 +395,7 @@
template <typename A, typename I, typename W>
inline
mln_ch_value(I, mln_result(A))
- transform_snake_dispatch(trait::image::speed::any,
+ transform_snake_dispatch(metal::false_,
const Accumulator<A>& a,
const Image<I>& input, const Window<W>& win)
{
@@ -408,7 +408,7 @@
template <typename A, typename I, typename W>
inline
mln_ch_value(I, mln_result(A))
- transform_snake_dispatch(trait::image::speed::fastest,
+ transform_snake_dispatch(metal::true_,
const Accumulator<A>& a,
const Image<I>& input, const Window<W>& win)
{
@@ -424,7 +424,7 @@
transform_snake_dispatch(const Accumulator<A>& a,
const Image<I>& input, const Window<W>& win)
{
- return transform_snake_dispatch(mln_trait_image_speed(I)(),
+ return transform_snake_dispatch(mln_is_fastest_IW(I, W)(),
a, input, win);
}
1
0