* mln/topo/skeleton/breadth_first_thinning.hh
(mln::topo::skeleton::breadth_first_thinning):
Fix a bias in the algorithm due to a buggy predicate.
Introduce a temporary psite to help the compiler.
Fix the type of `output'.
---
milena/ChangeLog | 10 ++++++++++
milena/mln/topo/skeleton/breadth_first_thinning.hh | 20 ++++++++++++++------
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 214b7e6..f1c1386 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,13 @@
+2010-05-04 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Improve topo::skeleton::breadth_first_thinning.
+
+ * mln/topo/skeleton/breadth_first_thinning.hh
+ (mln::topo::skeleton::breadth_first_thinning):
+ Fix a bias in the algorithm due to a buggy predicate.
+ Introduce a temporary psite to help the compiler.
+ Fix the type of `output'.
+
2010-04-26 Roland Levillain <roland(a)lrde.epita.fr>
Clean Milena's tests' outputs during `make mostlyclean'.
diff --git a/milena/mln/topo/skeleton/breadth_first_thinning.hh
b/milena/mln/topo/skeleton/breadth_first_thinning.hh
index 42e1bef..8039ffb 100644
--- a/milena/mln/topo/skeleton/breadth_first_thinning.hh
+++ b/milena/mln/topo/skeleton/breadth_first_thinning.hh
@@ -1,4 +1,4 @@
-// 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.
//
@@ -90,7 +90,7 @@ namespace mln
F& is_simple = exact(is_simple_);
const H& constraint = exact(constraint_);
- I output = duplicate(input);
+ mln_concrete(I) output = duplicate(input);
// Attach the work image to IS_SIMPLE.
is_simple.set_image(output);
@@ -133,15 +133,23 @@ namespace mln
/* FIXME: We compute the cell and attachment of P twice:
during the call to is_simple() and within detach().
How could we reuse this elegantly, without breaking
- the genericity of the skeleton algorithm? */
+ the genericity of the skeleton algorithm?
+ Also, keep in mind that functors can maintain an
+ internal state and make side effects, meaning that
+ e.g. constraint(p) might not be constant for a
+ given p during the thinning. */
if (constraint(p) && is_simple(p))
{
detach(p, output);
- mln_niter(N) n(nbh, p);
- for_all(n)
+ mln_niter(N) n_(nbh, p);
+ for_all(n_)
+ {
+ // Same remark as above regarding P and P_.
+ psite n = n_;
if (output.domain().has(n)
- && output(n) && constraint(p) && is_simple(n))
+ && output(n) && constraint(n) && is_simple(n))
next_set.insert(n);
+ }
}
}
set.clear();
--
1.5.6.5
Show replies by date