
* tests/geom/rotate.cc: Fix test. * mln/labeling/blobs_and_compute.hh: Add comments. * mln/labeling/flat_zones.hh: Add missing members to functors. * tests/labeling/blobs_and_compute.cc: Fix return type. * tests/labeling/flat_zones.cc, * tests/labeling/foreground.cc: Fix functor template parameters. * tests/labeling/relabel.cc: The number of components is not updated anymore. * tests/labeling/colorize.cc: Fix reference according to last changes in labeling::colorize routine * mln/core/point.hh: Add mln:: namespace prefix. --- milena/ChangeLog | 23 +++++++++++++++++++ milena/mln/core/point.hh | 6 ++-- milena/mln/labeling/blobs_and_compute.hh | 3 ++ milena/mln/labeling/flat_zones.hh | 34 +++++++++++++++++++-------- milena/tests/geom/rotate.cc | 16 +++++++----- milena/tests/labeling/blobs_and_compute.cc | 17 +++++++++----- milena/tests/labeling/colorize.cc | 6 +++- milena/tests/labeling/flat_zones.cc | 4 +- milena/tests/labeling/foreground.cc | 4 +- milena/tests/labeling/relabel.cc | 6 +--- 10 files changed, 83 insertions(+), 36 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 3701f90..bc6cbd1 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,28 @@ 2010-08-10 Guillaume Lazzara <z@lrde.epita.fr> + Fix tests in Milena. + + * tests/geom/rotate.cc: Fix test. + + * mln/labeling/blobs_and_compute.hh: Add comments. + + * mln/labeling/flat_zones.hh: Add missing members to functors. + + * tests/labeling/blobs_and_compute.cc: Fix return type. + + * tests/labeling/flat_zones.cc, + * tests/labeling/foreground.cc: Fix functor template parameters. + + * tests/labeling/relabel.cc: The number of components is not + updated anymore. + + * tests/labeling/colorize.cc: Fix reference according to last + changes in labeling::colorize routine. + + * mln/core/point.hh: Add mln:: namespace prefix. + +2010-08-10 Guillaume Lazzara <z@lrde.epita.fr> + * mln/io/dicom/get_header.hh: Add missing headers. 2010-08-10 Guillaume Lazzara <z@lrde.epita.fr> diff --git a/milena/mln/core/point.hh b/milena/mln/core/point.hh index 1b9efc8..4dc7c5e 100644 --- a/milena/mln/core/point.hh +++ b/milena/mln/core/point.hh @@ -317,7 +317,7 @@ namespace mln enum { dim = G::dim }; for (unsigned i = 0; i < dim; ++i) - to[i] = internal::convert_data<C2>(from[i]); + to[i] = mln::internal::convert_data<C2>(from[i]); } @@ -337,9 +337,9 @@ namespace mln else { for (unsigned i = dim - 2; i < dim; ++i) - to[i] = internal::convert_data<C2>(from[j++]); + to[i] = mln::internal::convert_data<C2>(from[j++]); for (unsigned i = 2; i < dim; ++i, ++j) - to[i-j] = internal::convert_data<C2>(from[j]); + to[i-j] = mln::internal::convert_data<C2>(from[j]); } } diff --git a/milena/mln/labeling/blobs_and_compute.hh b/milena/mln/labeling/blobs_and_compute.hh index dd3eb98..e8f784c 100644 --- a/milena/mln/labeling/blobs_and_compute.hh +++ b/milena/mln/labeling/blobs_and_compute.hh @@ -52,6 +52,9 @@ namespace mln \param[in,out] nlabels The number of labels found. \param[in] accu An accumulator to be computed while labeling. + \return The labeled image, computed attributes for each regions + and an array of the accumulators used to compute the + attributes. */ template <typename I, typename N, typename L, typename A> util::couple<mln_ch_value(I,L), diff --git a/milena/mln/labeling/flat_zones.hh b/milena/mln/labeling/flat_zones.hh index 66bc44d..431bd86 100644 --- a/milena/mln/labeling/flat_zones.hh +++ b/milena/mln/labeling/flat_zones.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2007, 2008, 2009 EPITA Research and Development +// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development // Laboratory (LRDE) // // This file is part of Olena. @@ -51,7 +51,8 @@ namespace mln /// template <typename I, typename N, typename L> mln_ch_value(I, L) - flat_zones(const Image<I>& input, const Neighborhood<N>& nbh, L& nlabels); + flat_zones(const Image<I>& input, const Neighborhood<N>& nbh, + L& nlabels); @@ -62,7 +63,7 @@ namespace mln // Flat zone functor for the labeling canvas. - template <typename I> + template <typename I, typename L> struct flat_zones_functor { const I& input; @@ -72,24 +73,37 @@ namespace mln typedef mln_psite(I) P; void init() {} - bool handles(const P&) const { return true; } - bool equiv(const P& n, const P& p) const { return input(n) == - input(p); } + bool handles(const P&) const { return true; } + + bool equiv(const P& n, const P& p) const + { return input(n) == input(p); } + bool labels(const P&) const { return true; } void do_no_union(const P&, const P&) {} void init_attr(const P&) {} void merge_attr(const P&, const P&) {} + void set_new_label(const P& p, const L& l){} + void set_label(const P& p, const L& l) {} + void finalize() {} + // Fastest implementation. void init_() {} - bool handles_(unsigned) const { return true; } - bool equiv_(unsigned n, unsigned p) const { return input.element(n) == - input.element(p); } + + bool handles_(unsigned) const + { return true; } + + bool equiv_(unsigned n, unsigned p) const + { return input.element(n) == input.element(p); } + bool labels_(unsigned) const { return true; } void do_no_union_(unsigned, unsigned) {} void init_attr_(unsigned) {} void merge_attr_(unsigned, unsigned) {} + void set_new_label_(unsigned, const L&) {} + void set_label_(unsigned, const L&) {} + void finalize_() {} // end of requirements. @@ -117,7 +131,7 @@ namespace mln mln_precondition(input.is_valid()); // Call the labeling canvas. - typedef impl::flat_zones_functor<I> F; + typedef impl::flat_zones_functor<I,L> F; F f(input); mln_ch_value(I, L) output = canvas::labeling::video(input, nbh, nlabels, f); diff --git a/milena/tests/geom/rotate.cc b/milena/tests/geom/rotate.cc index c06aeb2..0b7a842 100644 --- a/milena/tests/geom/rotate.cc +++ b/milena/tests/geom/rotate.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -33,8 +34,12 @@ int main() { using namespace mln; - bool ref_values[][5] = { { 0, 1, 1, 0, 0 }, - { 0, 0, 1, 1, 0 } }; + bool ref_values[][5] = { { 0, 1, 0, 0, 0 }, + { 0, 1, 1, 0, 0 }, + { 0, 0, 1, 1, 0 }, + { 0, 0, 0, 1, 1 }, + { 0, 0, 0, 0, 1 } }; + bool values[][5] = { { 0, 0, 1, 0, 0 }, { 0, 0, 1, 0, 0 }, @@ -45,10 +50,7 @@ int main() image2d<bool> ima = make::image(values); - image2d<bool> ref(make::box2d(1,0, 2,4), 0); - for (unsigned i = 0; i < 2; ++i) - for (unsigned j = 0; j < 5; ++j) - ref(ref.point_at_index(i + j + 4 * i)) = ref_values[i][j]; + image2d<bool> ref = make::image(ref_values); image2d<bool> ima_rot = geom::rotate(ima, 45); diff --git a/milena/tests/labeling/blobs_and_compute.cc b/milena/tests/labeling/blobs_and_compute.cc index 8516bba..8fd5744 100644 --- a/milena/tests/labeling/blobs_and_compute.cc +++ b/milena/tests/labeling/blobs_and_compute.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -45,12 +46,16 @@ int main() typedef image2d<value::label_8> L; typedef util::array<point2d> arr_t; - typedef util::couple<L,arr_t> res_t; + typedef accu::center<point2d,point2d> accu_t; + typedef util::array<accu_t> accu_arr_t; + typedef util::couple<L,util::couple<arr_t, accu_arr_t> > res_t; res_t result = labeling::blobs_and_compute(pic, c4(), n, - accu::center<point2d,point2d>()); + accu_t()); - mln_assertion(result.second().size() == 34); - mln_assertion(result.second()[1] == point2d(10,30)); - mln_assertion(result.second()[33] == point2d(310,66)); + + mln_assertion(result.second().first().size() == 34); + mln_assertion(result.second().second().size() == 34); + mln_assertion(result.second().first()[1] == point2d(10,30)); + mln_assertion(result.second().second()[33] == point2d(310,66)); mln_assertion(n == 33); } diff --git a/milena/tests/labeling/colorize.cc b/milena/tests/labeling/colorize.cc index 9c4d352..3d3a9ea 100644 --- a/milena/tests/labeling/colorize.cc +++ b/milena/tests/labeling/colorize.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of Olena. // @@ -35,6 +36,7 @@ #include <mln/labeling/colorize.hh> #include <mln/data/compare.hh> +#include <mln/debug/println.hh> int main() { @@ -44,7 +46,7 @@ int main() { 0, 0 } }; typedef value::rgb8 rgb_t; - value::rgb8 ref_data[][2] = { { rgb_t(171,46,231), rgb_t(171,46,231) }, + value::rgb8 ref_data[][2] = { { rgb_t(220,80,117), rgb_t(220,80,117) }, { rgb_t(0,0,0), rgb_t(0,0,0) } }; image2d<value::int_u8> ima = make::image(values); diff --git a/milena/tests/labeling/flat_zones.cc b/milena/tests/labeling/flat_zones.cc index 6b4b37e..e1e09d1 100644 --- a/milena/tests/labeling/flat_zones.cc +++ b/milena/tests/labeling/flat_zones.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2007, 2008, 2009 EPITA Research and Development +// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development // Laboratory (LRDE) // // This file is part of Olena. @@ -65,7 +65,7 @@ int main() { typedef image2d<int_u8> I; - labeling::impl::flat_zones_functor<I> f(lena); + labeling::impl::flat_zones_functor<I,unsigned> f(lena); unsigned nlabels_generic, nlabels_fastest; mln_assertion(canvas::labeling::impl::generic::labeling(lena, diff --git a/milena/tests/labeling/foreground.cc b/milena/tests/labeling/foreground.cc index acdecb6..8be0aeb 100644 --- a/milena/tests/labeling/foreground.cc +++ b/milena/tests/labeling/foreground.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2007, 2008, 2009 EPITA Research and Development +// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development // Laboratory (LRDE) // // This file is part of Olena. @@ -54,7 +54,7 @@ int main() // which calls canvas::labeling_video and its generic dispatch // leads to canvas::impl::generic::labeling. - labeling::impl::value_functor<I> f(pic, true); + labeling::impl::value_functor<I,unsigned> f(pic, true); unsigned n_; ref = canvas::labeling::impl::generic::labeling(pic, nbh, n_, diff --git a/milena/tests/labeling/relabel.cc b/milena/tests/labeling/relabel.cc index 79382ba..27ec2df 100644 --- a/milena/tests/labeling/relabel.cc +++ b/milena/tests/labeling/relabel.cc @@ -1,4 +1,5 @@ -// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008, 2009, 2010 EPITA Research and Development +// Laboratory (LRDE) // // This file is part of Olena. // @@ -26,7 +27,6 @@ #include <mln/core/image/image2d.hh> #include <mln/labeling/relabel.hh> #include <mln/value/label_16.hh> -#include <mln/debug/println.hh> struct not_to_remove : public mln::Function_v2b< not_to_remove > @@ -76,11 +76,9 @@ int main() } { - label_16 new_nlabels; labeling::relabel_inplace(lbl, nlabels, not_to_remove()); - mln_assertion(nlabels == 2u); mln_piter_(image2d<label_16>) p(lbl.domain()); for_all(p) mln_assertion(is_valid(lbl(p))); -- 1.5.6.5