---
milena/ChangeLog | 5 ++++
milena/mln/topo/skeleton/crest.hh | 48 +++++++++++++++++++++++++-----------
2 files changed, 38 insertions(+), 15 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 21d7ddc..7171949 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,10 @@
2010-02-16 Guillaume Lazzara <z(a)lrde.epita.fr>
+ * mln/topo/skeleton/crest.hh: Fix invalid PSI values for component
+ edge sites.
+
+2010-02-16 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add a routine to read dump files header.
* mln/io/dump/all.hh: Include a new file.
diff --git a/milena/mln/topo/skeleton/crest.hh b/milena/mln/topo/skeleton/crest.hh
index f1501bf..7910a1f 100644
--- a/milena/mln/topo/skeleton/crest.hh
+++ b/milena/mln/topo/skeleton/crest.hh
@@ -34,7 +34,6 @@
# include <mln/core/concept/neighborhood.hh>
# include <mln/data/fill.hh>
-
namespace mln
{
@@ -47,10 +46,13 @@ namespace mln
/// Compute skeletization constraints.
///
- /// \param[in] input_ A binary image.
- /// \param[in] dist_map_ A distance map of \p input. Contains the
- /// inner object distance map.
- /// \param[in] nbh_ A neighborhood.
+ /// \param[in] input A binary image.
+ /// \param[in] dist_map A distance map of \p input. Contains the
+ /// inner object distance map.
+ /// \param[in] nbh A neighborhood.
+ /// \param[in] psi_threshold Keep sites having a Point
+ /// Superiority Index greated or equal
+ /// to \p psi_threshold.
///
/// \result A binary image.
//
@@ -77,7 +79,7 @@ namespace mln
* p.val().
*
* This algorithm keeps sites having their pixel superiority index
- * greater than 5.
+ * greater than \p psi_threshold (6 by default).
*
* For good results with 2D images, we advice you to use c8() as
* neighborhood.
@@ -85,18 +87,24 @@ namespace mln
*/
template <typename I, typename D, typename N>
mln_concrete(I)
- crest(const Image<I>& input_, const Image<D>& dist_map_,
- const Neighborhood<N>& nbh_);
+ crest(const Image<I>& input, const Image<D>& dist_map,
+ const Neighborhood<N>& nbh, unsigned psi_threshold);
+
+ /// \overload
+ /// psi_threshold is set to 6.
+ template <typename I, typename D, typename N>
+ mln_concrete(I)
+ crest(const Image<I>& input, const Image<D>& dist_map,
+ const Neighborhood<N>& nbh);
# ifndef MLN_INCLUDE_ONLY
-
template <typename I, typename D, typename N>
mln_concrete(I)
crest(const Image<I>& input_, const Image<D>& dist_map_,
- const Neighborhood<N>& nbh_)
+ const Neighborhood<N>& nbh_, unsigned psi_threshold)
{
trace::entering("topo::skeleton::crest");
const I& input = exact(input_);
@@ -120,20 +128,22 @@ namespace mln
continue;
unsigned nb_eq = 0;
- unsigned nb_gt = 0;
unsigned nb_lt = 0;
for_all(n)
- if (input.domain().has(n))
+ if (input.domain().has(n)
+ // We want to only consider sites which are part of
+ // the skeleton. If this test is removed, sometimes
+ // edge sites are considered as sites with a high PSI
+ // which is wrong.
+ && dist_map(n) > static_cast<mln_value(D)>(0))
{
if (dist_map(n) == dist_map(p))
++nb_eq;
- else if (dist_map(n) > dist_map(p))
- ++nb_gt;
else
++nb_lt;
}
- if ((nb_lt + nb_eq) > 5) // Pixel Superiority index
+ if ((nb_lt + nb_eq) >= psi_threshold) // Pixel Superiority index
is_crest(p) = true;
}
@@ -142,6 +152,14 @@ namespace mln
}
+ template <typename I, typename D, typename N>
+ mln_concrete(I)
+ crest(const Image<I>& input, const Image<D>& dist_map,
+ const Neighborhood<N>& nbh)
+ {
+ return crest(input, dist_map, nbh, 6);
+ }
+
# endif // ! MLN_INCLUDE_ONLY
--
1.5.6.5
Show replies by date