
* tests/morpho/Makefile.am (check_PROGRAMS): Re-enable graph_image_morpho, lena_line_graph_image_wst1, line_graph_image_wst and line_graph_image_morpho. * tests/morpho/graph_image_morpho.cc * tests/morpho/line_graph_image_morpho.cc: Add missing code from tests/core/image/graph_image.cc and tests/core/image/line_graph_image.cc to have this test pass again. * tests/morpho/lena_line_graph_image_wst1.cc: Catch up with util::ord usage and domain's has() semantics. --- milena/ChangeLog | 14 ++++++++ milena/tests/core/image/Makefile.am | 3 ++ milena/tests/morpho/Makefile.am | 8 ++-- milena/tests/morpho/graph_image_morpho.cc | 36 +++++++++++++++++++++ milena/tests/morpho/lena_line_graph_image_wst1.cc | 7 +++- milena/tests/morpho/line_graph_image_morpho.cc | 3 ++ 6 files changed, 65 insertions(+), 6 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index abe1c4e..193a46d 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,19 @@ 2008-09-23 Roland Levillain <roland@lrde.epita.fr> + Fix more morphological tests on graph-based images. + + * tests/morpho/Makefile.am (check_PROGRAMS): Re-enable + graph_image_morpho, lena_line_graph_image_wst1, + line_graph_image_wst and line_graph_image_morpho. + * tests/morpho/graph_image_morpho.cc + * tests/morpho/line_graph_image_morpho.cc: + Add missing code from tests/core/image/graph_image.cc and + tests/core/image/line_graph_image.cc to have this test pass again. + * tests/morpho/lena_line_graph_image_wst1.cc: Catch up with + util::ord usage and domain's has() semantics. + +2008-09-23 Roland Levillain <roland@lrde.epita.fr> + Have morphological erosion work on non-classical image types. * mln/morpho/erosion.spe.hh diff --git a/milena/tests/core/image/Makefile.am b/milena/tests/core/image/Makefile.am index bf39e2b..dc247cc 100644 --- a/milena/tests/core/image/Makefile.am +++ b/milena/tests/core/image/Makefile.am @@ -36,6 +36,9 @@ cast_image_SOURCES = cast_image.cc complex_image_SOURCES = complex_image.cc decorated_image_SOURCES = decorated_image.cc graph_image_SOURCES = graph_image.cc +### FIXME: graph_image_wst is almost a clone of graph_image: move it +### into tests/morpho and turn it into a real test on the WST (see +### line_graph_image_wst). ##graph_image_wst_SOURCES = graph_image_wst.cc flat_image_SOURCES = flat_image.cc ##hexa_SOURCES = hexa.cc diff --git a/milena/tests/morpho/Makefile.am b/milena/tests/morpho/Makefile.am index 36f11dd..48e3a82 100644 --- a/milena/tests/morpho/Makefile.am +++ b/milena/tests/morpho/Makefile.am @@ -15,13 +15,13 @@ check_PROGRAMS = \ erosion_min_h \ gradient \ gradient_elementary \ -## graph_image_morpho \ + graph_image_morpho \ hit_or_miss \ laplacian \ -## lena_line_graph_image_wst1 \ + lena_line_graph_image_wst1 \ lena_line_graph_image_wst2 \ -## line_graph_image_wst \ -## line_graph_image_morpho \ + line_graph_image_wst \ + line_graph_image_morpho \ meyer_wst \ meyer_wst_long \ opening_area \ diff --git a/milena/tests/morpho/graph_image_morpho.cc b/milena/tests/morpho/graph_image_morpho.cc index 2acc5a5..0653953 100644 --- a/milena/tests/morpho/graph_image_morpho.cc +++ b/milena/tests/morpho/graph_image_morpho.cc @@ -38,6 +38,7 @@ #include <mln/core/image/graph_window_piter.hh> #include <mln/morpho/dilation.hh> +#include <mln/morpho/erosion.hh> #include <mln/draw/graph.hh> #include <mln/debug/iota.hh> @@ -105,10 +106,45 @@ int main() // Initialize values. debug::iota(ima); + /*-------------------------------------. + | Image representation/visualization. | + `-------------------------------------*/ + + // Compute the bounding box of IMA. + /* FIXME: mln::graph_image should automatically feature a bbox when + its parameter P is akin to a point. */ + accu::bbox<point2d> a; + for (std::vector<point2d>::const_iterator i = points.begin(); + i != points.end(); ++i) + a.take(*i); + box2d bbox = a.to_result(); + // Print the image. + /* FIXME: Unfortunately, displaying graph images is not easy right + now (2008-02-05). We could use + + debug::println(ima); + + but there's not specialization working for graph_image; the one + selected by the compiler is based on a 2-D bbox, and expects the + interface of graph_image to work with points (not psites). + Moreover, this implementation only shows *values*, not the graph + itslef. + + An alternative is to use draw::graph (which, again, is misnamed), + but it doesn't show the values, only the vertices and edges of the + graph. + + The current solution is a mix between draw::graph and hand-made + iterations. */ + image2d<int> ima_rep(bbox); + /*--------------------------. | Processing graph images. | `--------------------------*/ + typedef graph_elt_window<point2d> win_t; + win_t win; + graph_image<point2d, int> ima_dil = morpho::dilation(ima, win); draw::graph(ima_rep, ima_dil, 9); debug::println(ima_rep); diff --git a/milena/tests/morpho/lena_line_graph_image_wst1.cc b/milena/tests/morpho/lena_line_graph_image_wst1.cc index 0af7832..d60980f 100644 --- a/milena/tests/morpho/lena_line_graph_image_wst1.cc +++ b/milena/tests/morpho/lena_line_graph_image_wst1.cc @@ -46,8 +46,11 @@ in it, interpolating inter-pixel points; \li print the watershed on lines into that same image, and save it. */ +#include <map> #include <vector> +#include <mln/util/ord.hh> + #include <mln/core/image/image2d.hh> #include <mln/core/alias/point2d.hh> #include <mln/core/alias/window2d.hh> @@ -112,7 +115,7 @@ int main() exhibits the lack of a service from util::graph (or a another, missing tool) regarding the retrieval of vertex ids from points. */ - std::map<point2d, util::vertex_id> points; + std::map<point2d, util::vertex_id, util::ord<point2d> > points; util::vertex_id id = 0; // Vertices. @@ -136,7 +139,7 @@ int main() mln_fwd_qiter_(window2d) q(next_c4_win, p); for_all (p) for_all (q) - if (work.has(q)) + if (work.domain().has(q)) { g.add_edge(points[p], points[q]); edge_values.push_back(math::max(work(p), work(q))); diff --git a/milena/tests/morpho/line_graph_image_morpho.cc b/milena/tests/morpho/line_graph_image_morpho.cc index a3c74cf..43bf66b 100644 --- a/milena/tests/morpho/line_graph_image_morpho.cc +++ b/milena/tests/morpho/line_graph_image_morpho.cc @@ -109,6 +109,9 @@ int main() | Processing graph images. | `--------------------------*/ + typedef line_graph_elt_window<point2d> win_t; + win_t win; + line_graph_image<point2d, int> ima_dil = morpho::dilation(ima, win); // Manual iteration over the domain of IMA_DIL. mln_piter_(ima_t) p_dil(ima_dil.domain()); -- 1.6.0.1