* 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