
* tests/core/routine/extend.cc, * tests/extract/blue.cc, * tests/extract/green.cc, * tests/extract/red.cc, * tests/labeling/blobs.cc, * tests/morpho/artificial_line_graph_image_wst.cc, * tests/morpho/elementary/gradient.cc, * tests/morpho/elementary/gradient_external.cc, * tests/morpho/elementary/gradient_internal.cc, * tests/morpho/elementary/laplacian.cc, * tests/morpho/lena_line_graph_image_wst1.cc, * tests/morpho/lena_line_graph_image_wst2.cc, * tests/morpho/skeleton_constrained.cc, * tests/morpho/tree/compute_parent.cc, * tests/pw/image.cc: Use the proper type for variables instead of mln_VAR. --- milena/ChangeLog | 23 ++++++++- milena/tests/core/routine/extend.cc | 13 +++-- milena/tests/extract/blue.cc | 6 ++- milena/tests/extract/green.cc | 6 ++- milena/tests/extract/red.cc | 6 ++- milena/tests/labeling/blobs.cc | 10 ++-- .../morpho/artificial_line_graph_image_wst.cc | 17 ++++-- milena/tests/morpho/elementary/gradient.cc | 43 ++++++++------- .../tests/morpho/elementary/gradient_external.cc | 40 ++++++++------- .../tests/morpho/elementary/gradient_internal.cc | 42 ++++++++------- milena/tests/morpho/elementary/laplacian.cc | 15 +++--- milena/tests/morpho/lena_line_graph_image_wst1.cc | 13 +++-- milena/tests/morpho/lena_line_graph_image_wst2.cc | 15 ++++-- milena/tests/morpho/skeleton_constrained.cc | 52 +++++++++++++------ milena/tests/morpho/tree/compute_parent.cc | 54 ++++++++++++++++--- milena/tests/pw/image.cc | 9 ++- 16 files changed, 234 insertions(+), 130 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index fabb854..58919f4 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,8 +1,29 @@ 2009-02-23 Guillaume Lazzara <z@lrde.epita.fr> + Do not use mln_VAR in tests. + + * tests/core/routine/extend.cc, + * tests/extract/blue.cc, + * tests/extract/green.cc, + * tests/extract/red.cc, + * tests/labeling/blobs.cc, + * tests/morpho/artificial_line_graph_image_wst.cc, + * tests/morpho/elementary/gradient.cc, + * tests/morpho/elementary/gradient_external.cc, + * tests/morpho/elementary/gradient_internal.cc, + * tests/morpho/elementary/laplacian.cc, + * tests/morpho/lena_line_graph_image_wst1.cc, + * tests/morpho/lena_line_graph_image_wst2.cc, + * tests/morpho/skeleton_constrained.cc, + * tests/morpho/tree/compute_parent.cc, + * tests/pw/image.cc: Use the proper type for variables instead of + mln_VAR. + +2009-02-23 Guillaume Lazzara <z@lrde.epita.fr> + Fix ambiguity in morpho::elementary::gradient dispatch. - * mln/morpho/elementary/gradient.hh: Ambiguity with images both + * mln/morpho/elementary/gradient.hh: Fix ambiguity with images both fastest and logic. 2009-02-23 Guillaume Lazzara <z@lrde.epita.fr> diff --git a/milena/tests/core/routine/extend.cc b/milena/tests/core/routine/extend.cc index c6144af..93b2a0e 100644 --- a/milena/tests/core/routine/extend.cc +++ b/milena/tests/core/routine/extend.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory +// Copyright (C) 2008, 2009 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 @@ -25,10 +26,9 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/*! \file tests/core/routine/extend.cc - * - * \brief Tests on mln::extend. - */ +/// \file tests/core/routine/extend.cc +/// +/// Tests on mln::extend. #include <mln/core/var.hh> @@ -58,7 +58,8 @@ int main() debug::println(ima); debug::println(extended_to(ima, bb)); - mln_VAR(ima_, extend(ima | make::box2d(2,2), 7)); + typedef extension_val<const sub_image<image2d<int>, box2d> > ima_t_; + ima_t_ ima_ = extend(ima | make::box2d(2,2), 7); debug::println(ima_); debug::println(extended_to(ima_, BB)); diff --git a/milena/tests/extract/blue.cc b/milena/tests/extract/blue.cc index 2748fa3..5c6ec69 100644 --- a/milena/tests/extract/blue.cc +++ b/milena/tests/extract/blue.cc @@ -33,12 +33,14 @@ int main() { using namespace mln; + using value::rgb8; - image2d<value::rgb8> ima(2,2); + typedef image2d<rgb8> I; + I ima(2,2); point2d p(1,1); ima(p) = value::rgb8(200, 230, 240); - mln_VAR(ima_blue, extract::blue(ima)); + fun_image<meta::blue<rgb8>,I> ima_blue = extract::blue(ima); mln_assertion(ima(p).blue() == ima_blue(p)); } diff --git a/milena/tests/extract/green.cc b/milena/tests/extract/green.cc index 59a8c28..adadc00 100644 --- a/milena/tests/extract/green.cc +++ b/milena/tests/extract/green.cc @@ -33,12 +33,14 @@ int main() { using namespace mln; + using value::rgb8; - image2d<value::rgb8> ima(2,2); + typedef image2d<rgb8> I; + I ima(2,2); point2d p(1,1); ima(p) = value::rgb8(200, 230, 240); - mln_VAR(ima_green, extract::green(ima)); + fun_image<meta::green<rgb8>,I> ima_green = extract::green(ima); mln_assertion(ima(p).green() == ima_green(p)); } diff --git a/milena/tests/extract/red.cc b/milena/tests/extract/red.cc index de2facb..3bfb551 100644 --- a/milena/tests/extract/red.cc +++ b/milena/tests/extract/red.cc @@ -33,12 +33,14 @@ int main() { using namespace mln; + using value::rgb8; - image2d<value::rgb8> ima(2,2); + typedef image2d<rgb8> I; + I ima(2,2); point2d p(1,1); ima(p) = value::rgb8(200, 230, 240); - mln_VAR(ima_red, extract::red(ima)); + fun_image<meta::red<rgb8>,I> ima_red = extract::red(ima); mln_assertion(ima(p).red() == ima_red(p)); } diff --git a/milena/tests/labeling/blobs.cc b/milena/tests/labeling/blobs.cc index 549e3c4..7ba41d1 100644 --- a/milena/tests/labeling/blobs.cc +++ b/milena/tests/labeling/blobs.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2007, 2008, 2009 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 @@ -25,10 +26,9 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/*! \file tests/labeling/blobs.cc - * - * \brief Test on mln::labeling::blobs. - */ +/// \file tests/labeling/blobs.cc +/// +/// Test on mln::labeling::blobs. #include <mln/core/image/image2d.hh> #include <mln/io/pbm/load.hh> diff --git a/milena/tests/morpho/artificial_line_graph_image_wst.cc b/milena/tests/morpho/artificial_line_graph_image_wst.cc index 415ad87..d6434cf 100644 --- a/milena/tests/morpho/artificial_line_graph_image_wst.cc +++ b/milena/tests/morpho/artificial_line_graph_image_wst.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008, 2009 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 @@ -108,15 +109,17 @@ int main() ((r / square_length) % 2 == (c / square_length) % 2) ? mln_min(input_val_t) : mln_max(input_val_t); - std::cout << "nvertices = " << nrows * ncols << std::endl - << "nedges = " << 2 * nrows * ncols - (nrows + ncols) << std::endl; + mln_assertion((nrows * ncols) == 10000); + mln_assertion((2 * nrows * ncols - (rows + ncols)) == 19800); /*----------------. | Line gradient. | `----------------*/ // Line graph image. - mln_VAR(lg_ima, morpho::line_gradient(input)); + typedef pw::image<fun::i2v::array<input_val_t>, p_edges<util::graph, + fun::i2v::array< util::site_pair<point2d> > > > lg_ima_t; + lg_ima_t lg_ima = morpho::line_gradient(input); /*------. | WST. | @@ -126,9 +129,11 @@ int main() nbh_t nbh; // Perform a Watershed Transform. + typedef pw::image<fun::i2v::array<unsigned>, p_edges<util::graph, + fun::i2v::array< util::site_pair<point2d> > > > wshed_t; unsigned nbasins; - mln_VAR(wshed, morpho::meyer_wst(lg_ima, nbh, nbasins)); - std::cout << "nbasins = " << nbasins << std::endl; + wshed_t wshed = morpho::meyer_wst(lg_ima, nbh, nbasins); + mln_assertion(nbasins == 1155); /*---------. | Output. | diff --git a/milena/tests/morpho/elementary/gradient.cc b/milena/tests/morpho/elementary/gradient.cc index d690c8e..02b9e20 100644 --- a/milena/tests/morpho/elementary/gradient.cc +++ b/milena/tests/morpho/elementary/gradient.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008, 2009 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 @@ -25,10 +26,9 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/*! \file tests/morpho/elementary/gradient.cc - * - * \brief Test on mln::morpho::elementary::gradient. - */ +/// \file tests/morpho/elementary/gradient.cc +/// +/// Test on mln::morpho::elementary::gradient. #include <mln/core/image/image2d.hh> #include <mln/core/image/sub_image.hh> @@ -41,33 +41,36 @@ #include <mln/morpho/elementary/gradient.hh> - int main() { using namespace mln; using value::int_u8; -// trace::quiet = false; - image2d<int_u8> ima(3, 3, 0); debug::iota(ima); - debug::println(ima); - - mln_VAR(b, ima.domain()); { - mln_VAR(gra, - morpho::elementary::gradient(ima | b, c4())); - debug::println(gra); + int_u8 ref_[9] = { 3, 4, 4, + 6, 6, 6, + 4, 4, 3 }; + image2d<int_u8> ref = make::image2d(ref_); + + image2d<int_u8> gra = morpho::elementary::gradient(ima, c4()); + mln_assertion(gra == ref); } - image2d<bool> msk(3, 3, 0); - data::fill(msk, pw::value(ima) >= pw::cst(5u)); - debug::println(msk); { - mln_VAR(gra, - morpho::elementary::gradient(msk | b, c4())); - debug::println(gra); + bool ref_[9] = { 0, 1, 1, + 1, 1, 1, + 1, 0, 0 }; + image2d<bool> ref = make::image2d(ref_); + + image2d<bool> msk(3, 3, 0); + data::fill(msk, pw::value(ima) >= pw::cst(5u)); + + image2d<bool> gra = morpho::elementary::gradient(msk, c4()); + + mln_assertion(gra == ref); } } diff --git a/milena/tests/morpho/elementary/gradient_external.cc b/milena/tests/morpho/elementary/gradient_external.cc index 1a91ff4..bc064cc 100644 --- a/milena/tests/morpho/elementary/gradient_external.cc +++ b/milena/tests/morpho/elementary/gradient_external.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008, 2009 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 @@ -25,10 +26,9 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/*! \file tests/morpho/elementary/gradient_external.cc - * - * \brief Test on mln::morpho::elementary::gradient_external. - */ +/// \file tests/morpho/elementary/gradient_external.cc +/// +/// Test on mln::morpho::elementary::gradient_external. #include <mln/core/image/image2d.hh> #include <mln/core/image/sub_image.hh> @@ -47,27 +47,29 @@ int main() using namespace mln; using value::int_u8; -// trace::quiet = false; - image2d<int_u8> ima(3, 3, 0); debug::iota(ima); - debug::println(ima); - - mln_VAR(b, ima.domain()); { - mln_VAR(gra, - morpho::elementary::gradient_external(ima | b, c4())); - debug::println(gra); + int_u8 ref_[9] = { 3, 3, 3, + 3, 3, 3, + 1, 1, 0 }; + image2d<int_u8> ref = make::image2d(ref_); + + image2d<int_u8> gra = morpho::elementary::gradient_external(ima, c4()); + mln_assertion(gra == ref); } - image2d<bool> msk(3, 3, 0); - data::fill(msk, pw::value(ima) >= pw::cst(5u)); - debug::println(msk); { - mln_VAR(gra, - morpho::elementary::gradient_external(msk | b, c4())); - debug::println(gra); + bool ref_[9] = { 0, 1, 1, + 1, 0, 0, + 0, 0, 0 }; + image2d<bool> ref = make::image2d(ref_); + + image2d<bool> msk(3, 3, 0); + data::fill(msk, pw::value(ima) >= pw::cst(5u)); + image2d<bool> gra = morpho::elementary::gradient_external(msk, c4()); + mln_assertion(gra == ref); } } diff --git a/milena/tests/morpho/elementary/gradient_internal.cc b/milena/tests/morpho/elementary/gradient_internal.cc index 91b1c14..3e72d4e 100644 --- a/milena/tests/morpho/elementary/gradient_internal.cc +++ b/milena/tests/morpho/elementary/gradient_internal.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008, 2009 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 @@ -25,19 +26,18 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/*! \file tests/morpho/elementary/gradient_internal.cc - * - * \brief Test on mln::morpho::elementary::gradient_internal. - */ +/// \file tests/morpho/elementary/gradient_internal.cc +/// +/// Test on mln::morpho::elementary::gradient_internal. #include <mln/core/image/image2d.hh> #include <mln/core/image/sub_image.hh> #include <mln/core/alias/neighb2d.hh> #include <mln/core/var.hh> #include <mln/value/int_u8.hh> +#include <mln/make/image2d.hh> #include <mln/debug/iota.hh> -#include <mln/debug/println.hh> #include <mln/morpho/elementary/gradient_internal.hh> @@ -47,27 +47,29 @@ int main() using namespace mln; using value::int_u8; -// trace::quiet = false; - image2d<int_u8> ima(3, 3, 0); debug::iota(ima); - debug::println(ima); - - mln_VAR(b, ima.domain()); { - mln_VAR(gra, - morpho::elementary::gradient_internal(ima | b, c4())); - debug::println(gra); + int_u8 ref_[9] = { 0, 1, 1, + 3, 3, 3, + 3, 3, 3 }; + image2d<int_u8> ref = make::image2d(ref_); + + image2d<int_u8> gra = morpho::elementary::gradient_internal(ima, c4()); + mln_assertion(gra == ref); } - image2d<bool> msk(3, 3, 0); - data::fill(msk, pw::value(ima) >= pw::cst(5u)); - debug::println(msk); { - mln_VAR(gra, - morpho::elementary::gradient_internal(msk | b, c4())); - debug::println(gra); + bool ref_[9] = { 0, 0, 0, + 0, 1, 1, + 1, 0, 0 }; + image2d<bool> ref = make::image2d(ref_); + + image2d<bool> msk(3, 3, 0); + data::fill(msk, pw::value(ima) >= pw::cst(5u)); + image2d<bool> gra = morpho::elementary::gradient_internal(msk, c4()); + mln_assertion(gra == ref); } } diff --git a/milena/tests/morpho/elementary/laplacian.cc b/milena/tests/morpho/elementary/laplacian.cc index 537abae..dbe9303 100644 --- a/milena/tests/morpho/elementary/laplacian.cc +++ b/milena/tests/morpho/elementary/laplacian.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008, 2009 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 @@ -25,10 +26,9 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/*! \file tests/morpho/elementary/laplacian.cc - * - * \brief Test on mln::morpho::elementary::laplacian. - */ +/// \file tests/morpho/elementary/laplacian.cc +/// +/// Test on mln::morpho::elementary::laplacian. #include <mln/core/image/image2d.hh> #include <mln/core/alias/neighb2d.hh> @@ -46,13 +46,12 @@ int main() using namespace mln; using value::int_u8; -// trace::quiet = false; - image2d<int_u8> ima(3, 3, 0); debug::iota(ima); debug::println(ima); - mln_VAR(lap, morpho::elementary::laplacian(ima, c4())); + typedef image2d<int> lap_t; + lap_t lap = morpho::elementary::laplacian(ima, c4()); mln_assertion(lap.border() == 1); debug::println(lap); diff --git a/milena/tests/morpho/lena_line_graph_image_wst1.cc b/milena/tests/morpho/lena_line_graph_image_wst1.cc index aa2d257..fee2d1c 100644 --- a/milena/tests/morpho/lena_line_graph_image_wst1.cc +++ b/milena/tests/morpho/lena_line_graph_image_wst1.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008, 2009 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 @@ -149,8 +150,8 @@ int main() pe_t pe(g, edge_sites); // Line graph image - typedef pw::image<edge_values_t, pe_t> ima_t; - mln_VAR(lg_ima, (edge_values | pe)); + typedef pw::image<edge_values_t, pe_t> lg_ima_t; + lg_ima_t lg_ima = (edge_values | pe); /*------. | WST. | @@ -161,8 +162,10 @@ int main() // Perform a Watershed Transform. int_u8 nbasins; - mln_VAR(wshed, morpho::meyer_wst(lg_ima, nbh, nbasins)); - std::cout << "nbasins = " << nbasins << std::endl; + typedef pw::image<fun::i2v::array<int_u8>, p_edges<util::graph, + fun::i2v::array< util::site_pair<point2d> > > > wshed_t; + wshed_t wshed = morpho::meyer_wst(lg_ima, nbh, nbasins); + mln_assertion(nbasins == 5); /*---------. | Output. | diff --git a/milena/tests/morpho/lena_line_graph_image_wst2.cc b/milena/tests/morpho/lena_line_graph_image_wst2.cc index ba822fa..f704f90 100644 --- a/milena/tests/morpho/lena_line_graph_image_wst2.cc +++ b/milena/tests/morpho/lena_line_graph_image_wst2.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008, 2009 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 @@ -103,7 +104,9 @@ int main() `----------------*/ // Line graph image. - mln_VAR(lg_ima, morpho::line_gradient(input)); + typedef pw::image<fun::i2v::array<input_val_t>, p_edges<util::graph, + fun::i2v::array< util::site_pair<point2d> > > > lg_ima_t; + lg_ima_t lg_ima = morpho::line_gradient(input); /*-----------------. | Simplification. | @@ -112,7 +115,7 @@ int main() typedef line_graph_elt_neighborhood<util::graph, lg_ima_t::pset::fun_t> nbh_t; nbh_t nbh; - mln_VAR(closed_lg_ima, morpho::closing_area_on_vertices(lg_ima, nbh, 20)); + lg_ima_t closed_lg_ima = morpho::closing_area_on_vertices(lg_ima, nbh, 20); /*------. | WST. | @@ -120,8 +123,10 @@ int main() // Perform a Watershed Transform. unsigned nbasins; - mln_VAR(wshed, morpho::meyer_wst(closed_lg_ima, nbh, nbasins)); - std::cout << "nbasins = " << nbasins << std::endl; + typedef pw::image<fun::i2v::array<unsigned>, p_edges<util::graph, + fun::i2v::array< util::site_pair<point2d> > > > wshed_t; + wshed_t wshed = morpho::meyer_wst(closed_lg_ima, nbh, nbasins); + mln_assertion(nbasins == 46); /*---------. | Output. | diff --git a/milena/tests/morpho/skeleton_constrained.cc b/milena/tests/morpho/skeleton_constrained.cc index 5024f66..7ce78dc 100644 --- a/milena/tests/morpho/skeleton_constrained.cc +++ b/milena/tests/morpho/skeleton_constrained.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008, 2009 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 @@ -42,8 +43,6 @@ #include <mln/io/pbm/load.hh> #include <mln/io/pbm/save.hh> #include <mln/data/fill.hh> -#include <mln/debug/println.hh> -#include <mln/debug/println_with_border.hh> #include <mln/pw/value.hh> #include <mln/core/image/image_if.hh> @@ -53,6 +52,8 @@ #include <mln/arith/revert.hh> #include <mln/transform/distance_geodesic.hh> +#include <mln/level/compare.hh> + #include "tests/data.hh" @@ -65,8 +66,6 @@ namespace mln { extension::adjust_duplicate(ima, nbh); - debug::println_with_border(ima); - image2d<unsigned> when_true(ima.domain()), when_false(ima.domain()); mln_piter(box2d) p(ima.domain()); for_all(p) @@ -74,13 +73,34 @@ namespace mln when_true(p) = connectivity_number_2d(ima, nbh.foreground(), p, true); when_false(p) = connectivity_number_2d(ima, nbh.background(), p, false); } - debug::println("when true = ", when_true | pw::value(ima)); - debug::println("when false = ", when_false | pw::value(ima)); } } // mln +bool skl_ref_[22][18] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 }, + { 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0 } }; + int main() { using namespace mln; @@ -91,8 +111,9 @@ int main() image2d<bool> pic; io::pbm::load(pic, MLN_IMG_DIR "/tiny.pbm"); - mln_VAR( nbh, - make::dual_neighb(pic, c4(), c8()) ); + typedef neighb<win::multiple_size<2u, window<dpoint<grid::square, short int> >, + pw::value_<image2d<bool> > > > nbh_t; + nbh_t nbh = make::dual_neighb(pic, c4(), c8()); show_connectivity_numbers(pic, nbh); @@ -104,14 +125,11 @@ int main() image2d<int_u8> dmap = transform::distance_geodesic(logical::not_(pic), nbh.foreground(), mln_max(int_u8)); - debug::println("dst =", dmap | pw::value(pic)); dmap = arith::revert(dmap); - mln_VAR( skl, - morpho::skeleton_constrained(pic, - nbh, is_simple_2d_t(), - K, dmap) ); - - debug::println("pic =", pic); - debug::println("skl =", skl); + image2d<bool> skl = morpho::skeleton_constrained(pic, + nbh, is_simple_2d_t(), + K, dmap); + image2d<bool> skl_ref = make::image(skl_ref_); + mln_assertion(skl == skl_ref); } diff --git a/milena/tests/morpho/tree/compute_parent.cc b/milena/tests/morpho/tree/compute_parent.cc index 6b4d34e..5707ed9 100644 --- a/milena/tests/morpho/tree/compute_parent.cc +++ b/milena/tests/morpho/tree/compute_parent.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008, 2009 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 @@ -31,16 +32,51 @@ #include <mln/core/image/image2d.hh> #include <mln/core/alias/neighb2d.hh> -#include <mln/core/var.hh> #include <mln/core/image/image_if.hh> #include <mln/core/site_set/p_array.hh> #include <mln/level/sort_psites.hh> +#include <mln/level/compare.hh> #include <mln/pw/value.hh> #include <mln/debug/println.hh> #include <mln/morpho/tree/compute_parent.hh> +static mln::image2d<mln::point2d> ref1() +{ + using namespace mln; + + image2d<point2d> ref1(make::box2d(3,3)); + + ref1(point2d(0,0)) = point2d(0,0); + ref1(point2d(0,1)) = point2d(0,0); + ref1(point2d(0,2)) = point2d(0,0); + ref1(point2d(1,1)) = point2d(0,0); + ref1(point2d(2,2)) = point2d(2,2); + + return ref1; +} + + +static mln::image2d<mln::point2d> ref2() +{ + using namespace mln; + + image2d<point2d> ref2(make::box2d(3,3)); + + ref2(point2d(0,0)) = point2d(0,1); + ref2(point2d(0,1)) = point2d(0,2); + ref2(point2d(0,2)) = point2d(0,2); + ref2(point2d(1,0)) = point2d(0,0); + ref2(point2d(1,1)) = point2d(0,1); + ref2(point2d(1,2)) = point2d(0,1); + ref2(point2d(2,0)) = point2d(0,0); + ref2(point2d(2,1)) = point2d(0,0); + ref2(point2d(2,2)) = point2d(0,2); + + return ref2; +} + int main() { @@ -51,11 +87,12 @@ int main() 0, 1, 0, 0, 0, 1 }; image2d<bool> ima = make::image2d(vals); - mln_VAR(sub, ima | pw::value(ima)); - debug::println(sub); + typedef image_if<image2d<bool>, pw::value_<image2d<bool> > > sub_t; + sub_t sub = ima | pw::value(ima); - mln_VAR(par, morpho::tree::compute_parent(sub, c4(), sub.domain())); - debug::println("par =", par); + typedef image_if<image2d<point2d>, pw::value_<image2d<bool> > > par_t; + par_t par = morpho::tree::compute_parent(sub, c4(), sub.domain()); + mln_assertion(par == (ref1() | sub.domain())); } { @@ -63,12 +100,11 @@ int main() 3, 2, 3, 3, 4, 1 }; image2d<unsigned char> ima = make::image2d(vals); - debug::println(ima); typedef p_array<point2d> S; S s = level::sort_psites_increasing(ima); - mln_VAR(par, morpho::tree::compute_parent(ima, c4(), s)); - debug::println("par =", par); + image2d<point2d> par = morpho::tree::compute_parent(ima, c4(), s); + mln_assertion(par == ref2()); } } diff --git a/milena/tests/pw/image.cc b/milena/tests/pw/image.cc index a0f2ff9..1be36c1 100644 --- a/milena/tests/pw/image.cc +++ b/milena/tests/pw/image.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory // (LRDE) // // This file is part of the Olena Library. This library is free @@ -42,7 +42,9 @@ int main() { using namespace mln; - mln_VAR(ima, fun::p2b::chess() | make::box2d(8, 8)); + typedef pw::image<fun::p2b::chess, + box<mln::point<grid::square, short int> > > ima_t; + ima_t ima = fun::p2b::chess() | make::box2d(8, 8); // trait::image::print(ima); unsigned i = 0; @@ -61,7 +63,8 @@ int main() { p_array<int> arr; // Sites are ints (why not?) arr.insert(51); // Site 51. - mln_VAR(ima, fun::i2v::array<int>(1) | arr); // An array psite converts to int so that works :-) + typedef pw::image<fun::i2v::array<int>, p_array<int> > ima_t; + ima_t ima = fun::i2v::array<int>(1) | arr; // An array psite converts to int so that works :-) // trait::image::print(ima); p_array<int>::psite p(ima.domain(), 0); // index 0 means the 1st element of arr -- 1.5.6.5