* mln/value/label_16.hh
* mln/value/label_8.hh
* tests/labeling/relabel.cc
* tests/morpho/meyer_wst_long.cc
* doc/examples/erosion.cc
* doc/examples/graph.cc
* doc/tutorial/samples/fill-part-image.cc
* doc/tutorial/samples/fill-subdomain-shorter.cc
* doc/tutorial/samples/fill-subdomain.cc
* doc/tutorial/samples/fill-subimage-cfun.cc
* doc/tutorial/samples/labeling-compute.cc: rename label8 to label_8
and label16 to label_16.
* doc/tutorial/tutorial.tex: fix wrong include.
* mln/core/site_set/p_graph_piter.hh: add a conversion toward the
graph element id.
* mln/debug/draw_graph.hh: update.
* mln/level/fill_with_value.hh: fix comments.
---
milena/ChangeLog | 26 ++++++
milena/doc/examples/erosion.cc | 6 +-
milena/doc/examples/graph.cc | 91 ++++----------------
milena/doc/tutorial/samples/fill-part-image.cc | 2 +-
.../doc/tutorial/samples/fill-subdomain-shorter.cc | 6 +-
milena/doc/tutorial/samples/fill-subdomain.cc | 8 +-
milena/doc/tutorial/samples/fill-subimage-cfun.cc | 2 +-
milena/doc/tutorial/samples/labeling-compute.cc | 6 +-
milena/doc/tutorial/tutorial.tex | 2 +-
milena/mln/core/site_set/p_graph_piter.hh | 10 ++
milena/mln/debug/draw_graph.hh | 10 +-
milena/mln/level/fill_with_value.hh | 20 ++--
milena/mln/value/label_16.hh | 6 +-
milena/mln/value/label_8.hh | 6 +-
milena/tests/labeling/relabel.cc | 24 +++---
milena/tests/morpho/meyer_wst_long.cc | 2 +-
16 files changed, 104 insertions(+), 123 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 1efcb92..9460b41 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,31 @@
2008-12-08 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Various small fixes.
+
+ * mln/value/label_16.hh
+ * mln/value/label_8.hh
+ * tests/labeling/relabel.cc
+ * tests/morpho/meyer_wst_long.cc
+ * doc/examples/erosion.cc
+ * doc/examples/graph.cc
+ * doc/tutorial/samples/fill-part-image.cc
+ * doc/tutorial/samples/fill-subdomain-shorter.cc
+ * doc/tutorial/samples/fill-subdomain.cc
+ * doc/tutorial/samples/fill-subimage-cfun.cc
+ * doc/tutorial/samples/labeling-compute.cc: rename label8 to label_8
+ and label16 to label_16.
+
+ * doc/tutorial/tutorial.tex: fix wrong include.
+
+ * mln/core/site_set/p_graph_piter.hh: add a conversion toward the
+ graph element id.
+
+ * mln/debug/draw_graph.hh: update.
+
+ * mln/level/fill_with_value.hh: fix comments.
+
+2008-12-08 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Allow construction of pw images using Function_v2v.
* mln/core/internal/graph_psite_base.hh: Add conversion to graph
diff --git a/milena/doc/examples/erosion.cc b/milena/doc/examples/erosion.cc
index 890fd81..b11d574 100644
--- a/milena/doc/examples/erosion.cc
+++ b/milena/doc/examples/erosion.cc
@@ -62,10 +62,10 @@ void clean_lines(mln::image2d<bool>& in,
unsigned bbox_larger)
{
using namespace mln;
- using value::label8;
+ using value::label_8;
- label8 nlabels;
- image2d<label8> lbl = labeling::blobs(ima, c4(), nlabels);
+ label_8 nlabels;
+ image2d<label_8> lbl = labeling::blobs(ima, c4(), nlabels);
for (unsigned i = nlabels; i > 0; --i)
{
diff --git a/milena/doc/examples/graph.cc b/milena/doc/examples/graph.cc
index 2330c29..499a877 100644
--- a/milena/doc/examples/graph.cc
+++ b/milena/doc/examples/graph.cc
@@ -35,70 +35,6 @@
#include <mln/debug/colorize.hh>
-
-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>&) const
- {
- return mln::literal::cyan;
- }
-
- template <typename G>
- mln::value::rgb8
- 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_;
-};
-
-
-
-
template <typename P>
struct lg_vertex_values : public mln::Function_p2v< lg_vertex_values<P> >
{
@@ -123,7 +59,7 @@ struct lg_vertex_values : public mln::Function_p2v<
lg_vertex_values<P> >
int main(int argc, char *argv[])
{
using namespace mln;
- using value::label16;
+ using value::label_16;
using value::rgb8;
if (argc < 2)
@@ -138,14 +74,14 @@ int main(int argc, char *argv[])
io::pbm::load(ima, argv[1]);
logical::not_inplace(ima);
- label16 nlabels;
- image2d<label16> lbl = labeling::blobs(ima, c8(), nlabels);
+ label_16 nlabels;
+ image2d<label_16> lbl = labeling::blobs(ima, c8(), nlabels);
#ifndef NOUT
io::ppm::save(debug::colorize(rgb8(), lbl, nlabels), "01-lbl.ppm");
#endif
- image2d<label16> iz = transform::influence_zone_geodesic(lbl, c8(),
mln_max(int));
+ image2d<label_16> iz = transform::influence_zone_geodesic(lbl, c8(),
mln_max(int));
#ifndef NOUT
io::ppm::save(debug::colorize(rgb8(), iz, nlabels), "02-iz.ppm");
@@ -165,7 +101,10 @@ int main(int argc, char *argv[])
#ifndef NOUT
image2d<rgb8> gima = level::convert(rgb8(), ima);
- debug::draw_graph(gima, pv, gcolor_t(), gcolor_t());
+ debug::draw_graph(gima,
+ pv,
+ pw::cst(literal::cyan),
+ pw::cst(literal::olive));
io::ppm::save(gima, "03-graph.ppm");
#endif
@@ -185,7 +124,10 @@ int main(int argc, char *argv[])
#ifndef NOUT
image2d<rgb8> lgima = level::convert(rgb8(), ima);
- debug::draw_graph(lgima, pvlg, gcolor_t(), gcolor_t());
+ debug::draw_graph(lgima,
+ pvlg,
+ pw::cst(literal::cyan),
+ pw::cst(literal::olive));
io::ppm::save(lgima, "04-line-graph.ppm");
#endif
@@ -201,16 +143,19 @@ int main(int argc, char *argv[])
//
// 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);
+ typedef fun::i2v::array<value::rgb8> lgcolor_t;
+ lgcolor_t ecolor(pvlg.nsites());
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;
+ ecolor(p) = literal::red;
+ else
+ ecolor(p) = literal::olive;
#ifndef NOUT
image2d<rgb8> lgima2 = level::convert(rgb8(), ima);
- debug::draw_graph(lgima2, pvlg, gcolor_t(), ecolor);
+ debug::draw_graph(lgima2, pvlg, pw::cst(literal::cyan), ecolor);
io::ppm::save(lgima2, "05-line-graph-cleanup.ppm");
#endif
}
diff --git a/milena/doc/tutorial/samples/fill-part-image.cc
b/milena/doc/tutorial/samples/fill-part-image.cc
index c3bc89e..0c90f35 100644
--- a/milena/doc/tutorial/samples/fill-part-image.cc
+++ b/milena/doc/tutorial/samples/fill-part-image.cc
@@ -3,7 +3,7 @@ int main()
{
using namespace mln;
using value::int_u8;
- using value::label8;
+ using value::label_8;
// \{
diff --git a/milena/doc/tutorial/samples/fill-subdomain-shorter.cc
b/milena/doc/tutorial/samples/fill-subdomain-shorter.cc
index a5f7e9f..da3ce7b 100644
--- a/milena/doc/tutorial/samples/fill-subdomain-shorter.cc
+++ b/milena/doc/tutorial/samples/fill-subdomain-shorter.cc
@@ -3,7 +3,7 @@ int main()
{
using namespace mln;
using value::rgb8;
- using value::label8;
+ using value::label_8;
// \{
@@ -21,8 +21,8 @@ int main()
// Find and label the different components.
// Fill the sites of component 2 with red.
// \{
- label8 nlabels;
- image2d<label8> lab = labeling::blobs(ima, c4(), nlabels);
+ label_8 nlabels;
+ image2d<label_8> lab = labeling::blobs(ima, c4(), nlabels);
image2d<rgb8> ima2;
initialize(ima2, ima);
diff --git a/milena/doc/tutorial/samples/fill-subdomain.cc
b/milena/doc/tutorial/samples/fill-subdomain.cc
index 124a663..efe8d58 100644
--- a/milena/doc/tutorial/samples/fill-subdomain.cc
+++ b/milena/doc/tutorial/samples/fill-subdomain.cc
@@ -4,7 +4,7 @@ int main()
{
using namespace mln;
using value::rgb8;
- using value::label8;
+ using value::label_8;
// \{
@@ -23,8 +23,8 @@ int main()
// Find and label the different components.
// \{
- label8 nlabels;
- image2d<label8> lbl = labeling::blobs(ima, c4(), nlabels);
+ label_8 nlabels;
+ image2d<label_8> lbl = labeling::blobs(ima, c4(), nlabels);
// \}
doc::ppmsave(debug::colorize(rgb8(), lbl, nlabels), "fill-subdomain");
@@ -34,7 +34,7 @@ int main()
mln_VAR(lbl_2, lbl | (pw::value(lbl) == pw::cst(2u)));
// \}
- image2d<label8> tmp;
+ image2d<label_8> tmp;
initialize(tmp, lbl);
level::fill(tmp, 0);
level::fill((tmp | lbl_2.domain()).rw(), 1);
diff --git a/milena/doc/tutorial/samples/fill-subimage-cfun.cc
b/milena/doc/tutorial/samples/fill-subimage-cfun.cc
index 6deabf3..6f3a4dd 100644
--- a/milena/doc/tutorial/samples/fill-subimage-cfun.cc
+++ b/milena/doc/tutorial/samples/fill-subimage-cfun.cc
@@ -10,7 +10,7 @@ int main()
{
using namespace mln;
using value::rgb8;
- using value::label8;
+ using value::label_8;
// \{
diff --git a/milena/doc/tutorial/samples/labeling-compute.cc
b/milena/doc/tutorial/samples/labeling-compute.cc
index 381c401..c91fc05 100644
--- a/milena/doc/tutorial/samples/labeling-compute.cc
+++ b/milena/doc/tutorial/samples/labeling-compute.cc
@@ -4,7 +4,7 @@ int main()
{
using namespace mln;
using value::rgb8;
- using value::label8;
+ using value::label_8;
// \{
@@ -21,8 +21,8 @@ int main()
doc::pbmsave(ima, "labeling-compute");
// \{
- label8 nlabels;
- image2d<label8> lbl = labeling::blobs(ima, c4(), nlabels);
+ label_8 nlabels;
+ image2d<label_8> lbl = labeling::blobs(ima, c4(), nlabels);
// \}
doc::ppmsave(debug::colorize(rgb8(), lbl, nlabels),
"labeling-compute");
diff --git a/milena/doc/tutorial/tutorial.tex b/milena/doc/tutorial/tutorial.tex
index 1c4bb16..8b69fcf 100644
--- a/milena/doc/tutorial/tutorial.tex
+++ b/milena/doc/tutorial/tutorial.tex
@@ -75,7 +75,7 @@ showstringspaces=false,linewidth=14cm}
\newcommand{\doxyrawcode}[1]{
\backslash endhtmlonly%
-\backslash include #1.cc%
+\backslash include #1.cc.raw%
\backslash htmlonly%
}
diff --git a/milena/mln/core/site_set/p_graph_piter.hh
b/milena/mln/core/site_set/p_graph_piter.hh
index 543a817..2b02ed4 100644
--- a/milena/mln/core/site_set/p_graph_piter.hh
+++ b/milena/mln/core/site_set/p_graph_piter.hh
@@ -88,6 +88,9 @@ namespace mln
/// Return the underlying iterator.
const iter& hook_iter_() const;
+ /// Convert towards the graph element id.
+ operator unsigned() const;
+
private:
/// Update the psite corresponding to this iterator.
@@ -189,6 +192,13 @@ namespace mln
template <typename S, typename I>
inline
+ p_graph_piter<S,I>::operator unsigned() const
+ {
+ return iter_.id();
+ }
+
+ template <typename S, typename I>
+ inline
void
p_graph_piter<S,I>::update_()
{
diff --git a/milena/mln/debug/draw_graph.hh b/milena/mln/debug/draw_graph.hh
index 1febe63..ae7fcad 100644
--- a/milena/mln/debug/draw_graph.hh
+++ b/milena/mln/debug/draw_graph.hh
@@ -122,13 +122,13 @@ namespace mln
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()), ecolor(ei.subj_()));
+ draw::line(exact(ima), pv(ei.v1()), pv(ei.v2()), ecolor(ei.id()));
// Draw vertices.
mln_piter(pv_t) p(pv);
for_all(p)
if (exact(ima).has(p))
- exact(ima)(p) = vcolor(p.element());
+ exact(ima)(p) = vcolor(p);
}
// FIXME: Refactor + be more restrictive on the function type.
@@ -152,13 +152,13 @@ namespace mln
{
p_line2d l = pv(vi.id());
// Draw edges (Line graph vertices).
- draw::line(exact(ima), l.begin(), l.end(), ecolor(vi.subj_()));
+ draw::line(exact(ima), l.begin(), l.end(), ecolor(vi.id()));
// Draw vertices (graph vertices).
if (exact(ima).has(l.begin()))
- exact(ima)(l.begin()) = vcolor(g.vertex(g.edge(vi).v1()));
+ exact(ima)(l.begin()) = vcolor(g.edge(vi).v1());
if (exact(ima).has(l.end()))
- exact(ima)(l.end()) = vcolor(g.vertex(g.edge(vi).v2()));
+ exact(ima)(l.end()) = vcolor(g.edge(vi).v2());
}
}
diff --git a/milena/mln/level/fill_with_value.hh b/milena/mln/level/fill_with_value.hh
index 3abf2d5..f81b6a6 100644
--- a/milena/mln/level/fill_with_value.hh
+++ b/milena/mln/level/fill_with_value.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,15 +29,14 @@
#ifndef MLN_LEVEL_FILL_WITH_VALUE_HH
# define MLN_LEVEL_FILL_WITH_VALUE_HH
-/*! \file mln/level/fill_with_value.hh
- *
- * \brief Fill an image with a value, that is, set all pixel values to
- * the given value.
- *
- * \todo Move specializations in a extra file.
- * \toto Activate fill_with_value_cell_wise.
- * \todo Optimize when \p ima is large and sizeof(mln_value(I)) > 1.
- */
+/// \file mln/level/fill_with_value.hh
+///
+/// Fill an image with a value, that is, set all pixel values to
+/// the given value.
+///
+/// \todo Move specializations in a extra file.
+/// \todo Activate fill_with_value_cell_wise.
+/// \todo Optimize when \p ima is large and sizeof(mln_value(I)) > 1.
# include <cstdlib>
@@ -54,7 +54,7 @@ namespace mln
namespace level
{
- /// \brief Fill the whole image \p ima with the single value \p v.
+ /// Fill the whole image \p ima with the single value \p v.
///
/// \param[in,out] ima The image to be filled.
/// \param[in] val The value to assign to all sites.
diff --git a/milena/mln/value/label_16.hh b/milena/mln/value/label_16.hh
index c7d4e13..4fc1792 100644
--- a/milena/mln/value/label_16.hh
+++ b/milena/mln/value/label_16.hh
@@ -28,9 +28,9 @@
#ifndef MLN_VALUE_LABEL_16_HH
# define MLN_VALUE_LABEL_16_HH
-/// \file mln/value/label16.hh
+/// \file mln/value/label_16.hh
///
-/// Define the alias value::label16.
+/// Define the alias value::label_16.
# include <mln/value/label.hh>
@@ -43,7 +43,7 @@ namespace mln
/// Alias for 16-bit integers.
- typedef label<16> label16;
+ typedef label<16> label_16;
} // end of namespace mln::value
diff --git a/milena/mln/value/label_8.hh b/milena/mln/value/label_8.hh
index 2a27179..7f1a8b3 100644
--- a/milena/mln/value/label_8.hh
+++ b/milena/mln/value/label_8.hh
@@ -28,9 +28,9 @@
#ifndef MLN_VALUE_LABEL_8_HH
# define MLN_VALUE_LABEL_8_HH
-/// \file mln/value/label8.hh
+/// \file mln/value/label_8.hh
///
-/// Define the alias value::label8.
+/// Define the alias value::label_8.
# include <mln/value/label.hh>
@@ -43,7 +43,7 @@ namespace mln
/// Alias for 8-bit labels.
- typedef mln::value::label<8> label8;
+ typedef mln::value::label<8> label_8;
} // end of namespace mln::value
diff --git a/milena/tests/labeling/relabel.cc b/milena/tests/labeling/relabel.cc
index 409ded7..ac1f612 100644
--- a/milena/tests/labeling/relabel.cc
+++ b/milena/tests/labeling/relabel.cc
@@ -39,14 +39,14 @@
struct not_to_removed : public mln::Function_l2b< not_to_removed >
{
- bool operator()(const mln::value::label16& l) const
+ bool operator()(const mln::value::label_16& l) const
{
- return l < mln::value::label16(3);
+ return l < mln::value::label_16(3);
}
};
-bool is_valid(const mln::value::label16& l)
+bool is_valid(const mln::value::label_16& l)
{
return l == 0u|| l == 1u || l == 2u;
}
@@ -56,9 +56,9 @@ bool is_valid(const mln::value::label16& l)
int main()
{
using namespace mln;
- using value::label16;
+ using value::label_16;
- label16 vals[6][5] = {
+ label_16 vals[6][5] = {
{0, 1, 1, 0, 0},
{0, 1, 1, 4, 0},
{0, 0, 0, 0, 0},
@@ -67,29 +67,29 @@ int main()
{2, 5, 5, 0, 0}
};
- image2d<label16> lbl = make::image(vals);
- label16 nlabels = 5;
+ image2d<label_16> lbl = make::image(vals);
+ label_16 nlabels = 5;
{
- label16 new_nlabels;
- image2d<label16> lbl2 = labeling::relabel(lbl,
+ label_16 new_nlabels;
+ image2d<label_16> lbl2 = labeling::relabel(lbl,
nlabels,
new_nlabels,
not_to_removed());
mln_assertion(new_nlabels == 2u);
- mln_piter_(image2d<label16>) p(lbl2.domain());
+ mln_piter_(image2d<label_16>) p(lbl2.domain());
for_all(p)
mln_assertion(is_valid(lbl2(p)));
}
{
- label16 new_nlabels;
+ label_16 new_nlabels;
labeling::relabel_inplace(lbl,
nlabels,
not_to_removed());
mln_assertion(nlabels == 2u);
- mln_piter_(image2d<label16>) p(lbl.domain());
+ mln_piter_(image2d<label_16>) p(lbl.domain());
for_all(p)
mln_assertion(is_valid(lbl(p)));
}
diff --git a/milena/tests/morpho/meyer_wst_long.cc
b/milena/tests/morpho/meyer_wst_long.cc
index b938985..34a1822 100644
--- a/milena/tests/morpho/meyer_wst_long.cc
+++ b/milena/tests/morpho/meyer_wst_long.cc
@@ -68,7 +68,7 @@ int main()
clo = morpho::closing_area(grad, c4(), 200);
// Perform a Watershed Transform.
- typedef value::label16 L;
+ typedef value::label_16 L;
L nbasins;
image2d<L> ws = morpho::meyer_wst(clo, c4(), nbasins);
--
1.5.6.5