
* tests/core/image/graph_image.cc: Update. Move the morpho-related part... * tests/morpho/graph_image_morpho.cc: ...here (new test). * tests/core/image/Makefile.am (check_PROGRAMS): Re-enable graph_image. (graph_image_SOURCES): Re-enable. * tests/morpho/Makefile.am (check_PROGRAMS): Add graph_image_morpho (as a disabled test). (graph_image_morpho_SOURCES): New. --- milena/ChangeLog | 14 ++++ milena/tests/core/image/Makefile.am | 4 +- milena/tests/core/image/graph_image.cc | 26 ++++----- milena/tests/morpho/Makefile.am | 2 + .../graph_image_morpho.cc} | 64 ++------------------ 5 files changed, 35 insertions(+), 75 deletions(-) copy milena/tests/{core/image/graph_image.cc => morpho/graph_image_morpho.cc} (63%) diff --git a/milena/ChangeLog b/milena/ChangeLog index a648fe5..d0e326d 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,19 @@ 2008-09-22 Roland Levillain <roland@lrde.epita.fr> + Update tests exercising graph image. + + * tests/core/image/graph_image.cc: Update. + Move the morpho-related part... + * tests/morpho/graph_image_morpho.cc: ...here (new test). + * tests/core/image/Makefile.am (check_PROGRAMS): Re-enable + graph_image. + (graph_image_SOURCES): Re-enable. + * tests/morpho/Makefile.am (check_PROGRAMS): Add + graph_image_morpho (as a disabled test). + (graph_image_morpho_SOURCES): New. + +2008-09-22 Roland Levillain <roland@lrde.epita.fr> + Update graph image. * mln/core/image/graph_image.hh diff --git a/milena/tests/core/image/Makefile.am b/milena/tests/core/image/Makefile.am index 583cbba..bf39e2b 100644 --- a/milena/tests/core/image/Makefile.am +++ b/milena/tests/core/image/Makefile.am @@ -9,7 +9,7 @@ check_PROGRAMS = \ decorated_image \ flat_image \ ## hexa \ -## graph_image \ + graph_image \ ## graph_image_wst \ image1d \ image2d \ @@ -35,7 +35,7 @@ check_PROGRAMS = \ cast_image_SOURCES = cast_image.cc complex_image_SOURCES = complex_image.cc decorated_image_SOURCES = decorated_image.cc -##graph_image_SOURCES = graph_image.cc +graph_image_SOURCES = graph_image.cc ##graph_image_wst_SOURCES = graph_image_wst.cc flat_image_SOURCES = flat_image.cc ##hexa_SOURCES = hexa.cc diff --git a/milena/tests/core/image/graph_image.cc b/milena/tests/core/image/graph_image.cc index bc08b22..7913589 100644 --- a/milena/tests/core/image/graph_image.cc +++ b/milena/tests/core/image/graph_image.cc @@ -30,13 +30,13 @@ #include <vector> +#include <mln/accu/bbox.hh> +#include <mln/core/alias/box2d.hh> #include <mln/core/alias/point2d.hh> #include <mln/core/image/graph_image.hh> #include <mln/core/image/graph_elt_window.hh> #include <mln/core/image/graph_window_piter.hh> -#include <mln/morpho/dilation.hh> - #include <mln/draw/graph.hh> #include <mln/debug/iota.hh> #include <mln/debug/println.hh> @@ -109,6 +109,14 @@ int main() ima_t ima(pg, values); // Initialize values. debug::iota(ima); + // 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 @@ -127,7 +135,7 @@ int main() The current solution is a mix between draw::graph and hand-made iterations. */ - image2d<int> ima_rep(ima.bbox()); + image2d<int> ima_rep(bbox); // We use the value 9 in draw::graph instead of the default (which is // 1) to represent edges to distinguish it from vertices holding a // value of 1. @@ -156,16 +164,4 @@ int main() std::cout << " " << q << " (level = " << ima(q) << ")" << std::endl; } std::cout << std::endl; - - /*--------------------------. - | Processing graph images. | - `--------------------------*/ - - graph_image<point2d, int> ima_dil = morpho::dilation(ima, win); - draw::graph(ima_rep, ima_dil, 9); - debug::println(ima_rep); - - graph_image<point2d, int> ima_ero = morpho::erosion(ima, win); - draw::graph(ima_rep, ima_ero, 9); - debug::println(ima_rep); } diff --git a/milena/tests/morpho/Makefile.am b/milena/tests/morpho/Makefile.am index 8955692..2bce281 100644 --- a/milena/tests/morpho/Makefile.am +++ b/milena/tests/morpho/Makefile.am @@ -15,6 +15,7 @@ check_PROGRAMS = \ erosion_min_h \ gradient \ gradient_elementary \ +## graph_image_morpho \ hit_or_miss \ laplacian \ ## lena_line_graph_image_wst1 \ @@ -52,6 +53,7 @@ hit_or_miss_SOURCES = hit_or_miss.cc laplacian_SOURCES = laplacian.cc thinning_SOURCES = thinning.cc +graph_image_morpho_SOURCES = graph_image_morpho.cc line_graph_image_morpho_SOURCES = line_graph_image_morpho.cc line_graph_image_wst_SOURCES = line_graph_image_wst.cc meyer_wst_SOURCES = meyer_wst.cc diff --git a/milena/tests/core/image/graph_image.cc b/milena/tests/morpho/graph_image_morpho.cc similarity index 63% copy from milena/tests/core/image/graph_image.cc copy to milena/tests/morpho/graph_image_morpho.cc index bc08b22..2acc5a5 100644 --- a/milena/tests/core/image/graph_image.cc +++ b/milena/tests/morpho/graph_image_morpho.cc @@ -25,11 +25,13 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/// \file tests/core/image/graph_image.cc -/// \brief Tests on mln::graph_image. +/// \file tests/morpho/graph_image_morpho.cc +/// \brief Tests on mln::graph_image with morphological filters. #include <vector> +#include <mln/accu/bbox.hh> +#include <mln/core/alias/box2d.hh> #include <mln/core/alias/point2d.hh> #include <mln/core/image/graph_image.hh> #include <mln/core/image/graph_elt_window.hh> @@ -91,16 +93,9 @@ int main() p_graph<point2d> pg(g); - // Check adjacencies of vertex 1. - mln_assertion( pg.adjacent(1, 0)); - mln_assertion(!pg.adjacent(1, 1)); - mln_assertion( pg.adjacent(1, 2)); - mln_assertion( pg.adjacent(1, 3)); - mln_assertion(!pg.adjacent(1, 4)); - - /*-------------. + /*--------------. | Graph image. | - `-------------*/ + `--------------*/ // Values ("empty" vector). std::vector<int> values(5); @@ -109,53 +104,6 @@ int main() ima_t ima(pg, values); // Initialize values. debug::iota(ima); - // 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(ima.bbox()); - // We use the value 9 in draw::graph instead of the default (which is - // 1) to represent edges to distinguish it from vertices holding a - // value of 1. - draw::graph (ima_rep, ima, 9); - debug::println (ima_rep); - - - /*------------. - | Iterators. | - `------------*/ - - // Manual iteration over the domain of IMA. - mln_piter_(ima_t) p(ima.domain()); - for_all (p) - std::cout << "ima (" << p << ") = " << ima(p) << std::endl; - - // Manual iterations over the neighborhoods of each point site of IMA. - typedef graph_elt_window<point2d> win_t; - win_t win; - mln_qiter_(win_t) q(win, p); - for_all (p) - { - std::cout << "neighbors of " << p << " (" << ima(p) << "), " - << "including the site itself:" << std::endl; - for_all (q) - std::cout << " " << q << " (level = " << ima(q) << ")" << std::endl; - } - std::cout << std::endl; /*--------------------------. | Processing graph images. | -- 1.5.6.5