2968: Fix morpho attribute image computation.

https://svn.lrde.epita.fr/svn/oln/trunk/milena Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Fix morpho attribute image computation. * tests/morpho/tree/compute_attribute_image.cc (main): Use relevant input image to test. * mln/math/diff_abs.hh: Upgrade doc style. (diff_abs): Use a test to be more robuste; remind that 1u - 2u is not equal to -1 in C! * mln/morpho/tree/compute_attribute_image.hh: Fix. Non-nodes have to fetch the attribute of their component. mln/math/diff_abs.hh | 10 +++++----- mln/morpho/tree/compute_attribute_image.hh | 3 +++ tests/morpho/tree/compute_attribute_image.cc | 8 ++++---- 3 files changed, 12 insertions(+), 9 deletions(-) Index: tests/morpho/tree/compute_attribute_image.cc --- tests/morpho/tree/compute_attribute_image.cc (revision 2967) +++ tests/morpho/tree/compute_attribute_image.cc (working copy) @@ -49,11 +49,11 @@ using namespace mln; { - unsigned vals[] = { 5, 6, 6, - 8, 9, 9, - 8, 9, 9 }; + unsigned char vals[] = { 3, 2, 1, + 3, 2, 3, + 3, 4, 1 }; - typedef image2d<unsigned> I; + typedef image2d<unsigned char> I; I f = make::image2d(vals); debug::println(f); Index: mln/math/diff_abs.hh --- mln/math/diff_abs.hh (revision 2967) +++ mln/math/diff_abs.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2007, 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,10 +29,9 @@ #ifndef MLN_MATH_DIFF_ABS_HH # define MLN_MATH_DIFF_ABS_HH -/*! \file mln/math/diff_abs.hh - * - * \brief Define diff_abs routine. - */ +/// \file mln/math/diff_abs.hh +/// +/// \brief Define diff_abs routine. namespace mln @@ -50,7 +50,7 @@ inline T diff_abs(const T& v1, const T& v2) { - return abs(v1 - v2); + return v1 > v2 ? v1 - v2 : v2 - v1; } # endif // ! MLN_INCLUDE_ONLY Index: mln/morpho/tree/compute_attribute_image.hh --- mln/morpho/tree/compute_attribute_image.hh (revision 2967) +++ mln/morpho/tree/compute_attribute_image.hh (working copy) @@ -100,6 +100,9 @@ for_all(p) if (! t.is_root(p)) acc(t.parent(p)).take(acc(p)); + for_all(p) + if (! t.is_a_node(p)) + acc(p) = acc(t.parent(p)); } typedef typename T::function I;
participants (1)
-
Thierry Geraud