cleanup-2008 2898: Prepare to debug morpho skeleton_constrained.

https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Prepare to debug morpho skeleton_constrained. * tests/morpho/skeleton_constrained.cc: Add extra echos. * mln/topo/is_simple_2d.hh: Relax test on domain extension. * mln/morpho/skeleton_constrained.hh: Likewise. Prefer adjust duplicate over adjust fill. mln/morpho/skeleton_constrained.hh | 20 ++++++++++++-------- mln/topo/is_simple_2d.hh | 4 ++-- tests/morpho/skeleton_constrained.cc | 13 +++++++++---- 3 files changed, 23 insertions(+), 14 deletions(-) Index: tests/morpho/skeleton_constrained.cc --- tests/morpho/skeleton_constrained.cc (revision 2897) +++ tests/morpho/skeleton_constrained.cc (working copy) @@ -47,6 +47,7 @@ #include <mln/pw/value.hh> #include <mln/core/image/image_if.hh> +#include <mln/extension/adjust_duplicate.hh> #include <mln/logical/not.hh> #include <mln/arith/revert.hh> @@ -62,7 +63,9 @@ void show_connectivity_numbers(const image2d<bool>& ima, const N& nbh) { - extension::adjust_fill(ima, nbh, false); + 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()); @@ -83,11 +86,13 @@ using namespace mln; using value::int_u8; + border::thickness = 1; + image2d<bool> pic; - io::pbm::load(pic, MLN_IMG_DIR "/tiny.pbm"); + io::pbm::load(pic, MLN_IMG_DIR "/fly.pbm"); mln_VAR( nbh, - make::dual_neighb(pic, c8(), c4()) ); + make::dual_neighb(pic, c4(), c8()) ); show_connectivity_numbers(pic, nbh); @@ -99,7 +104,7 @@ image2d<int_u8> dmap = transform::distance_geodesic(logical::not_(pic), nbh.foreground(), mln_max(int_u8)); - debug::println("dst =", dmap); + debug::println("dst =", dmap | pw::value(pic)); dmap = arith::revert(dmap); mln_VAR( skl, Index: mln/topo/is_simple_2d.hh --- mln/topo/is_simple_2d.hh (revision 2897) +++ mln/topo/is_simple_2d.hh (working copy) @@ -135,11 +135,11 @@ unsigned res = 0; - mln_bkd_niter(neighb2d) n(c8(), p); + mln_fwd_niter(neighb2d) n(c8(), p); for_all(n) { res = (res << 1); - if (ima.domain().has(n) && ima(n) == b) + if (ima.has(n) && ima(n) == b) res = res | 1; } Index: mln/morpho/skeleton_constrained.hh --- mln/morpho/skeleton_constrained.hh (revision 2897) +++ mln/morpho/skeleton_constrained.hh (working copy) @@ -31,12 +31,14 @@ /// \file mln/morpho/skeleton_constrained.hh /// /// Compute a skeleton under constraints. +/// +/// \todo Add an extension handling policy for the user to set it. # include <mln/core/concept/image.hh> # include <mln/core/concept/neighborhood.hh> # include <mln/core/site_set/p_queue_fast.hh> # include <mln/core/site_set/p_priority.hh> -# include <mln/extension/adjust_fill.hh> +# include <mln/extension/adjust_duplicate.hh> # include <mln/level/fill.hh> @@ -72,7 +74,7 @@ const K& constraint = exact(constraint_); const R& priority = exact(priority_); - extension::adjust_fill(input, nbh, false); + extension::adjust_duplicate(input, nbh); // FIXME: Tests! @@ -86,16 +88,17 @@ { initialize(output, input); level::fill(output, input); + extension::adjust_duplicate(output, nbh); mln_piter(I) p(input.domain()); for_all(p) - if ( input(p) == false ) -// if ( input(p) == false && -// is_simple(input, nbh, p) ) // p is a simple point of the background. + if ( input(p) == false && + is_simple(input, nbh, p) ) // p is a simple point of the background. { q.push(priority(p), p); - // std::cout << "push " << p << std::endl; + // std::cout << p << " "; } + std::cout << std::endl; } // std::cout << std::endl << "propagation..." << std::endl; @@ -108,16 +111,17 @@ { p = q.pop_front(); for_all(n) - if ( output.domain().has(n) && + if ( output.has(n) && output(n) == true && constraint(n) == false && is_simple(output, nbh, n) ) { output(n) = false; // Remove n from object. q.push(priority(n), n); - // std::cout << "push " << n << std::endl; + // std::cout << n << " "; } } + std::cout << std::endl; } return output;
participants (1)
-
Thierry Geraud