URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-02-06 Fabien Freling <freling(a)lrde.epita.fr>
Implement fastest regional_minima.
* fabien/level.hh: New file to implement fastest level.
* fabien/regional_maxima.hh: Fix.
* fabien/regional_minima.cc: New file to test regional_minima.
* fabien/regional_minima.hh: Fastest implementation.
---
level.hh | 188 +++++++++++++++++++++++++++++++++++++++++++++++++++++
regional_minima.cc | 57 ++++++++++++++++
regional_minima.hh | 172 ++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 417 insertions(+)
Index: trunk/milena/sandbox/fabien/level.hh
===================================================================
--- trunk/milena/sandbox/fabien/level.hh (revision 0)
+++ trunk/milena/sandbox/fabien/level.hh (revision 3309)
@@ -0,0 +1,188 @@
+// 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_LABELING_LEVEL_HH
+# define MLN_LABELING_LEVEL_HH
+
+/// \file mln/labeling/level.hh
+///
+/// Connected component labeling of the image objects at a given
+/// level.
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/canvas/labeling.hh>
+# include <mln/data/fill.hh>
+
+
+
+namespace mln
+{
+
+ namespace labeling
+ {
+
+ /*! Connected component labeling of the image objects at a given
+ * level.
+ *
+ * \param[in] input The input image.
+ * \param[in] val The level to consider for the labeling.
+ * \param[in] nbh The connexity of the level components.
+ * \param[out] nlabels The number of labels.
+ * \return The label image.
+ */
+ template <typename I, typename N, typename L>
+ mln_ch_value(I, L)
+ level(const Image<I>& input, const mln_value(I)& val,
+ const Neighborhood<N>& nbh, L& nlabels);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Tests.
+
+ namespace internal
+ {
+
+ template <typename I, typename N, typename L>
+ void
+ level_tests(const Image<I>& input, const mln_value(I)& val, const Neighborhood<N>& nbh,
+ L& nlabels)
+ {
+ mln_precondition(exact(input).is_valid());
+ // mln_precondition(exact(nbh).is_valid());
+
+ (void) input;
+ (void) val;
+ (void) nbh;
+ (void) nlabels;
+ }
+
+ } // end of namespace mln::labeling::internal
+
+
+
+ // Generic implementation.
+
+ namespace impl
+ {
+
+
+ struct labeling_functor_base
+ {
+ void init() {}
+
+ template <typename P>
+ bool handles(const P&) const { return true; }
+
+ template <typename L, typename R>
+ bool equiv(const L&, const R&) const { return false; }
+
+ template <typename P>
+ bool labels(const P&) const { return true; }
+
+ template <typename L, typename R>
+ void do_no_union(const L&, const R&) {}
+
+ template <typename P>
+ void init_attr(const P&) {}
+
+ template <typename L, typename R>
+ void merge_attr(const L&, const R&) {}
+ };
+
+
+ // Generic functor.
+
+ template <typename I>
+ struct level_functor : labeling_functor_base
+ {
+ typedef mln_psite(I) P;
+
+ const I& input;
+ const mln_value(I)& val;
+
+ // Requirements from mln::canvas::labeling.
+
+ typedef mln_pset(I) S;
+
+ // Generic implementation
+
+ void init() {}
+ bool handles(const P& p) const { return input(p) == val; }
+ bool equiv(const P& n, const P&) const { return input(n) == val; }
+ bool labels(const P&) const { return true; }
+
+ // Fastest implementation
+
+ void init_() {}
+ bool handles_(const P& p) const { return input.element(p) == val; }
+ bool equiv_(const P& n, const P&) const { return input.element(n) == val; }
+ bool labels_(const P&) const { return true; }
+
+
+ // end of Requirements.
+
+ level_functor(const Image<I>& input_, const mln_value(I)& val)
+ : input(exact(input_)),
+ val(val)
+ {
+ }
+ };
+
+
+
+
+ // Facade.
+
+ template <typename I, typename N, typename L>
+ mln_ch_value(I, L)
+ level(const Image<I>& input, const mln_value(I)& val, const Neighborhood<N>& nbh,
+ L& nlabels)
+ {
+ trace::entering("labeling::level");
+
+ internal::level_tests(input, val, nbh, nlabels);
+
+ mln_ch_value(I, L) output;
+ level_functor<I> f(input, val);
+ output = canvas::labeling_video(input, nbh, nlabels, f);
+
+ trace::exiting("labeling::level");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::labeling
+
+} // end of namespace mln
+
+
+#endif // ! MLN_LABELING_LEVEL_HH
Index: trunk/milena/sandbox/fabien/regional_minima.hh
===================================================================
--- trunk/milena/sandbox/fabien/regional_minima.hh (revision 0)
+++ trunk/milena/sandbox/fabien/regional_minima.hh (revision 3309)
@@ -0,0 +1,172 @@
+// 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_LABELING_REGIONAL_MINIMA_HH
+# define MLN_LABELING_REGIONAL_MINIMA_HH
+
+/// \file mln/labeling/regional_minima.hh
+///
+/// Connected component labeling of the regional minima of an image.
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/neighborhood.hh>
+
+# include "labeling.hh"
+
+# include <mln/data/fill.hh>
+# include <mln/level/sort_psites.hh>
+
+
+namespace mln
+{
+
+ namespace labeling
+ {
+
+ /*! Connected component labeling of the regional minima of an
+ * image.
+ *
+ * \param[in] input The input image.
+ * \param[in] nbh The connexity of the regional minima.
+ * \param[out] nlabels The number of labeled regions.
+ * \return The label image.
+ *
+ */
+ template <typename I, typename N, typename L>
+ mln_ch_value(I, L)
+ regional_minima(const Image<I>& input, const Neighborhood<N>& nbh,
+ L& nlabels);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ // Generic functor.
+
+ template <typename I>
+ struct regional_minima_functor
+ {
+ typedef mln_psite(I) P;
+
+ // requirements from mln::canvas::labeling:
+
+ const I& input;
+
+ // Generic implementation
+
+ void init() { data::fill(attr, true); }
+ bool handles(const P&) const { return true; }
+ bool labels(const P& p) const { return attr(p); }
+ bool equiv(const P& n, const P& p) const { return input(n) ==
+ input(p); }
+ void do_no_union(const P& n, const P& p)
+ {
+ // Avoid a warning about an undefined variable when NDEBUG
+ // is not defined.
+ (void)n;
+
+ mln_invariant(input(n) < input(p));
+ attr(p) = false;
+ }
+
+ void init_attr(const P&) {}
+ void merge_attr(const P& r, const P& p) { attr(p) = attr(p) &&
+ attr(r); }
+
+ // Fastest implementation
+
+ void init_() { data::fill(attr, true); }
+ bool handles_(unsigned p) const { return true; }
+ bool labels_(unsigned p) const { return attr.element(p); }
+ bool equiv_(unsigned n, unsigned p) const { return input.element(n) ==
+ input.element(p); }
+ void do_no_union_(unsigned n, unsigned p)
+ {
+ // Avoid a warning about an undefined variable when NDEBUG
+ // is not defined.
+ (void)n;
+
+ mln_invariant(input.element(n) < input.element(p));
+ attr.element(p) = false;
+ }
+
+ void init_attr_(unsigned) {}
+ void merge_attr_(unsigned r, unsigned p) { attr.element(p) = attr.element(p) &&
+ attr.element(r); }
+
+ // end of requirements
+
+ mln_ch_value(I, bool) attr;
+
+ regional_minima_functor(const I& input)
+ : input(input)
+ {
+ initialize(attr, input);
+ }
+ };
+
+
+ } // end of namespace mln::labeling::impl
+
+
+
+ // Facade.
+
+ template <typename I, typename N, typename L>
+ mln_ch_value(I, L)
+ regional_minima(const Image<I>& input_, const Neighborhood<N>& nbh_,
+ L& nlabels)
+ {
+ trace::entering("labeling::regional_minima");
+
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+ mln_precondition(input.is_valid());
+
+ // FIXME: abort if L is not wide enough to encode the set of
+ // minima.
+
+ typedef impl::regional_minima_functor<I> F;
+ F f(exact(input));
+ mln_ch_value(I, L) output = canvas::labeling_sorted(input, nbh, nlabels,
+ f, true);
+
+ trace::exiting("labeling::regional_minima");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::labeling
+
+} // end of namespace mln
+
+
+#endif // ! MLN_LABELING_REGIONAL_MINIMA_HH
Index: trunk/milena/sandbox/fabien/regional_maxima.hh
===================================================================
Index: trunk/milena/sandbox/fabien/regional_minima.cc
===================================================================
--- trunk/milena/sandbox/fabien/regional_minima.cc (revision 0)
+++ trunk/milena/sandbox/fabien/regional_minima.cc (revision 3309)
@@ -0,0 +1,57 @@
+// 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/labeling/regional_minima.cc
+ *
+ * \brief Test on mln::labeling::regional_minima.
+ */
+
+#include <mln/core/image/image2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/pw/all.hh>
+
+#include "regional_minima.hh"
+
+#include <tests/data.hh>
+#include <mln/debug/println.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ trace::quiet = false;
+
+ image2d<int_u8> lena = io::pgm::load<int_u8>(MLN_IMG_DIR "/tiny.pgm");
+
+ unsigned n;
+ labeling::regional_minima((pw::cst(255) - pw::value(lena)) | lena.domain(),
+ c4(), n);
+}
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Prepare to fast the morpho wst by flooding.
* mln/morpho/watershed: New directory.
* mln/morpho/meyer_wst.hh: Copy to...
* mln/morpho/watershed/flooding.hh: ...this new file.
(watershed): New namespace.
(nbasins): Rename as...
(n_basins): ...this.
(meyer_wst): Remove overload without n_basins.
(meyer_wst): Rename this only remaining routine as...
(flooding): ...this.
(flooding_dispatch): New.
* mln/morpho/watershed/all.hh: New.
* mln/morpho/all.hh: Update.
* tests/morpho/watershed: New directory.
* tests/morpho/watershed/flooding.cc: New.
* tests/morpho/watershed/Makefile.am: New.
* tests/morpho/Makefile.am: Update.
mln/morpho/all.hh | 1
mln/morpho/watershed/all.hh | 65 +++++++++
mln/morpho/watershed/flooding.hh | 266 +++++++++++++++++++++++++++++--------
tests/morpho/Makefile.am | 3
tests/morpho/watershed/Makefile.am | 10 +
tests/morpho/watershed/flooding.cc | 61 ++++++++
6 files changed, 351 insertions(+), 55 deletions(-)
Index: mln/morpho/watershed/flooding.hh
--- mln/morpho/watershed/flooding.hh (revision 0)
+++ mln/morpho/watershed/flooding.hh (working copy)
@@ -25,19 +25,20 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_MORPHO_MEYER_WST_HH
-# define MLN_MORPHO_MEYER_WST_HH
+#ifndef MLN_MORPHO_WATERSHED_FLOODING_HH
+# define MLN_MORPHO_WATERSHED_FLOODING_HH
-/** \file mln/morpho/meyer_wst.hh
- \brief Meyer's Watershed Transform (WST) algorithm.
-
- The Watershed Transform algorithm from Meyer using a hierarchical
- queue.
-
- Reference:
- Fernand Meyer. Un algorithme optimal de ligne de partage des
- eaux. In: Actes du 8�me Congr�s AFCET, Lyon-Villeurbanne, France
- (1991), pages 847--859. */
+/// \file mln/morpho/watershed/flooding.hh
+///
+/// Meyer's Watershed Transform (WST) algorithm.
+///
+/// The Watershed Transform algorithm from Meyer using a hierarchical
+/// queue.
+///
+/// Reference:
+/// Fernand Meyer. Un algorithme optimal de ligne de partage des
+/// eaux. In: Actes du 8�me Congr�s AFCET, Lyon-Villeurbanne, France
+/// (1991), pages 847--859.
# include <mln/trait/ch_value.hh>
@@ -56,59 +57,155 @@
namespace morpho
{
- /* FIXME: Provide also a version of the algorithm taking an image
- of minima as input. */
- /* FIXME: See also the interface of the Shortest-Path Watershed
+ namespace watershed
+ {
+
+ /*
+ FIXME:
+ Provide also a version of the algorithm taking an image
+ of minima as input.
+
+ FIXME:
+ See also the interface of the Shortest-Path Watershed
Transform, which proposes to lower-complete the image before
processing it. Then, add a reference to
- mln/morpho/lower_completion.hh. */
+ mln/morpho/lower_completion.hh.
+ */
- /** \brief Meyer's Watershed Transform (WST) algorithm.
+ /// Meyer's Watershed Transform (WST) algorithm.
+ ///
+ /// \param[in] input The input image.
+ /// \param[in] nbh The connexity of markers.
+ /// \param[out] n_basins The number of basins.
+ ///
+ /// \li \p L is the type of labels, used to number the watershed
+ /// itself (with the minimal value), and the basins.
+ /// \li \p I is the exact type of the input image.
+ /// \li \p N is the exact type of the neighborhood used to express
+ /// \a input's connexity.
- \param[in] input The input image.
- \param[in] nbh The connexity of markers.
- \param[out] nbasins The number of basins.
-
- \li \p L is the type of labels, used to number the watershed
- itself (with the minimal value), and the basins.
- \li \p I is the exact type of the input image.
- \li \p N is the exact type of the neighborhood used to express
- \a input's connexity. */
template <typename I, typename N, typename L>
mln_ch_value(I, L)
- meyer_wst(const Image<I>& input, const Neighborhood<N>& nbh,
- L& nbasins);
+ flooding(const Image<I>& input, const Neighborhood<N>& nbh,
+ L& n_basins);
+
- /** \brief Meyer's Watershed Transform (WST) algorithm, with no
- count of basins.
- \param[in] input The input image.
- \param[in] nbh The connexity of markers.
+# ifndef MLN_INCLUDE_ONLY
+
- \li \p L is the type of labels, used to number the watershed
- itself (with the minimal value), and the basins.
- \li \p I is the exact type of the input image.
- \li \p N is the exact type of the neighborhood used to express
- \a input's connexity.
+ // Implementations.
- Note that the first parameter, \p L, is not automatically
- valued from the type of the actual argument during implicit
- instantiation: you have to explicitly pass this parameter at
- call sites. */
- template <typename L, typename I, typename N>
+ namespace impl
+ {
+
+ namespace generic
+ {
+
+ template <typename I, typename N, typename L>
mln_ch_value(I, L)
- meyer_wst(const Image<I>& input, const Neighborhood<N>& nbh);
+ flooding(const Image<I>& input_, const Neighborhood<N>& nbh_,
+ L& n_basins)
+ {
+ trace::entering("morpho::watershed::impl::generic::flooding");
+ /* FIXME: Ensure the input image has scalar values. */
+
+ const I input = exact(input_);
+ const N nbh = exact(nbh_);
+ typedef L marker;
+ const marker unmarked = literal::zero;
-# ifndef MLN_INCLUDE_ONLY
+ typedef mln_value(I) V;
+ const V max = mln_max(V);
+
+ // Initialize the output with the markers (minima components).
+ mln_ch_value(I, marker) output =
+ labeling::regional_minima (input, nbh, n_basins);
+
+ typedef mln_psite(I) psite;
+
+ // Ordered queue.
+ typedef p_queue_fast<psite> Q;
+ p_priority<V, Q> queue;
+
+ // In_queue structure to avoid processing sites several times.
+ mln_ch_value(I, bool) in_queue;
+ initialize(in_queue, input);
+ data::fill(in_queue, false);
+
+ // Insert every neighbor P of every marked area in a
+ // hierarchical queue, with a priority level corresponding to
+ // the grey level input(P).
+ mln_piter(I) p(output.domain());
+ mln_niter(N) n(nbh, p);
+ for_all (p)
+ if (output(p) == unmarked)
+ for_all(n)
+ if (output.domain().has(n) && output(n) != unmarked)
+ {
+ queue.push(max - input(p), p);
+ in_queue(p) = true;
+ break;
+ }
+
+ /* Until the queue is empty, extract a psite P from the
+ hierarchical queue, at the highest priority level, that is,
+ the lowest level. */
+ while (! queue.is_empty())
+ {
+ psite p = queue.front();
+ queue.pop();
+ // Last seen marker adjacent to P.
+ marker adjacent_marker = unmarked;
+ // Has P a single adjacent marker?
+ bool single_adjacent_marker_p = true;
+ mln_niter(N) n(nbh, p);
+ for_all(n)
+ if (output.domain().has(n) && output(n) != unmarked)
+ {
+ if (adjacent_marker == unmarked)
+ {
+ adjacent_marker = output(n);
+ single_adjacent_marker_p = true;
+ }
+ else
+ if (adjacent_marker != output(n))
+ {
+ single_adjacent_marker_p = false;
+ break;
+ }
+ }
+ /* If the neighborhood of P contains only psites with the
+ same label, then P is marked with this label, and its
+ neighbors that are not yet marked are put into the
+ hierarchical queue. */
+ if (single_adjacent_marker_p)
+ {
+ output(p) = adjacent_marker;
+ for_all(n)
+ if (output.domain().has(n) && output(n) == unmarked
+ && ! in_queue(n))
+ {
+ queue.push(max - input(n), n);
+ in_queue(n) = true;
+ }
+ }
+ }
+ trace::exiting("morpho::watershed::impl::generic::flooding");
+ return output;
+ }
+
+
+ // Fastest version.
template <typename I, typename N, typename L>
mln_ch_value(I, L)
- meyer_wst(const Image<I>& input_, const Neighborhood<N>& nbh_,
- L& nbasins)
+ flooding_fastest(const Image<I>& input_, const Neighborhood<N>& nbh_,
+ L& n_basins)
{
- trace::entering("morpho::meyer_wst");
+ trace::entering("morpho::watershed::impl::flooding_fastest");
/* FIXME: Ensure the input image has scalar values. */
const I input = exact(input_);
@@ -122,7 +219,7 @@
// Initialize the output with the markers (minima components).
mln_ch_value(I, marker) output =
- labeling::regional_minima (input, nbh, nbasins);
+ labeling::regional_minima (input, nbh, n_basins);
typedef mln_psite(I) psite;
@@ -193,23 +290,84 @@
}
}
}
- trace::exiting("morpho::meyer_wst");
+ trace::exiting("morpho::watershed::impl::flooding_fastest");
return output;
}
- template <typename L, typename I, typename N>
+
+ } // end of namespace mln::morpho::watershed::impl::generic
+
+ } // end of namespace mln::morpho::watershed::impl
+
+
+
+ // Dispatch.
+
+ namespace internal
+ {
+
+ template <typename I, typename N, typename L>
+ inline
mln_ch_value(I, L)
- meyer_wst(const Image<I>& input, const Neighborhood<N>& nbh)
+ flooding_dispatch(metal::false_,
+ const Image<I>& input, const Neighborhood<N>& nbh, L& n_basins)
{
- L nbasins;
- return meyer_wst<L>(input, nbh, nbasins);
+ return impl::generic::flooding(input, nbh, n_basins);
+ }
+
+
+ template <typename I, typename N, typename L>
+ inline
+ mln_ch_value(I, L)
+ flooding_dispatch(metal::true_,
+ const Image<I>& input, const Neighborhood<N>& nbh, L& n_basins)
+ {
+ return impl::generic::flooding(input, nbh, n_basins);
+// return impl::generic::flooding_fastest(input, nbh, n_basins);
+ }
+
+ template <typename I, typename N, typename L>
+ inline
+ mln_ch_value(I, L)
+ flooding_dispatch(const Image<I>& input, const Neighborhood<N>& nbh, L& n_basins)
+ {
+ enum {
+ test = mlc_equal(mln_trait_image_speed(I),
+ trait::image::speed::fastest)::value
+ &&
+ mln_is_simple_neighborhood(N)::value
+ };
+ return flooding_dispatch(metal::bool_<test>(),
+ input, nbh, n_basins);
+ }
+
+ } // end of namespace mln::morpho::watershed::impl
+
+
+ // Facade.
+
+ template <typename I, typename N, typename L>
+ inline
+ mln_ch_value(I, L)
+ flooding(const Image<I>& input, const Neighborhood<N>& nbh, L& n_basins)
+ {
+ trace::entering("morpho::watershed::flooding");
+
+ // FIXME: internal::flooding_tests(input, nbh, n_basins);
+
+ mln_ch_value(I, L) output = internal::flooding_dispatch(input, nbh, n_basins);
+
+ trace::exiting("morpho::watershed::flooding");
+ return output;
}
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::morpho::watershed
+
} // end of namespace mln::morpho
} // end of namespace mln
-#endif // ! MLN_MORPHO_MEYER_WST_HH
+#endif // ! MLN_MORPHO_WATERSHED_FLOODING_HH
Property changes on: mln/morpho/watershed/flooding.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/morpho/watershed/all.hh
--- mln/morpho/watershed/all.hh (revision 0)
+++ mln/morpho/watershed/all.hh (revision 0)
@@ -0,0 +1,65 @@
+// Copyright (C) 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_MORPHO_WATERSHED_ALL_HH
+# define MLN_MORPHO_WATERSHED_ALL_HH
+
+/// \file mln/morpho/watershed/all.hh
+///
+/// File that includes all morphological watershed routines.
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ /// Namespace of morphological watershed routines.
+ namespace watershed
+ {
+
+ /// Namespace of morphological watershed routines
+ /// implementations.
+ namespace watershed
+ {
+
+ /// Namespace of morphological watershed routines generic
+ /// implementations.
+ namespace generic
+ {}
+
+ }
+ }
+ }
+}
+
+
+# include <mln/morpho/watershed/flooding.hh>
+
+
+#endif // ! MLN_MORPHO_WATERSHED_ALL_HH
Index: mln/morpho/all.hh
--- mln/morpho/all.hh (revision 3307)
+++ mln/morpho/all.hh (working copy)
@@ -86,6 +86,7 @@
# include <mln/morpho/elementary/all.hh>
# include <mln/morpho/tree/all.hh>
+# include <mln/morpho/watershed/all.hh>
Index: tests/morpho/watershed/flooding.cc
--- tests/morpho/watershed/flooding.cc (revision 0)
+++ tests/morpho/watershed/flooding.cc (revision 0)
@@ -0,0 +1,61 @@
+// Copyright (C) 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// \file tests/morpho/watershed/flooding.cc
+///
+/// Test on mln::morpho::watershed::flooding.
+
+#include <iostream>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/window2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+
+#include <mln/value/int_u8.hh>
+
+#include <mln/morpho/watershed/flooding.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include "tests/data.hh"
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<int_u8> input;
+ io::pgm::load(input, MLN_IMG_DIR "/squares.pgm");
+
+ typedef int_u8 L;
+ L nbasins;
+ image2d<L> output = morpho::watershed::flooding(input, c4(), nbasins);
+
+ io::pgm::save(output, "out.pgm");
+}
Index: tests/morpho/watershed/Makefile.am
--- tests/morpho/watershed/Makefile.am (revision 0)
+++ tests/morpho/watershed/Makefile.am (revision 0)
@@ -0,0 +1,10 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ flooding
+
+flooding_SOURCES = flooding.cc
+
+TESTS = $(check_PROGRAMS)
Index: tests/morpho/Makefile.am
--- tests/morpho/Makefile.am (revision 3307)
+++ tests/morpho/Makefile.am (working copy)
@@ -4,7 +4,8 @@
SUBDIRS = \
elementary \
- tree
+ tree \
+ watershed
check_PROGRAMS = \
artificial_line_graph_image_wst \
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Make distance-geodesic-based routines have fastest versions.
* mln/canvas/distance_geodesic.hh
(distance_geodesic_tests, distance_geodesic_dispatch): New.
(distance_geodesic_fastest): New.
(distance_geodesic): Call dispatch.
* mln/transform/internal/influence_zone_functor.hh
(init_p): New; fix missing.
* mln/transform/internal/influence_zone_functor.hh,
* mln/transform/internal/closest_point_functor.hh,
* mln/transform/internal/distance_functor.hh,
(P): Fix.
(init_, init_p_, process_): New.
(inqueue_p_wrt_input_p_, inqueue_p_wrt_input_n_): New.
* mln/transform/closest_point_geodesic.hh: New.
* mln/transform/all.hh: Update.
* tests/transform/bench_closest_point_geodesic.cc: New.
* tests/transform/closest_point_geodesic.cc: New.
* tests/transform/Makefile.am: Update.
mln/canvas/distance_geodesic.hh | 228 ++++++++++++++++++++++-
mln/transform/all.hh | 1
mln/transform/closest_point_geodesic.hh | 81 ++++++++
mln/transform/internal/closest_point_functor.hh | 10 -
mln/transform/internal/distance_functor.hh | 9
mln/transform/internal/influence_zone_functor.hh | 9
tests/transform/Makefile.am | 4
tests/transform/bench_closest_point_geodesic.cc | 63 ++++++
tests/transform/closest_point_geodesic.cc | 54 +++++
9 files changed, 448 insertions(+), 11 deletions(-)
Index: mln/transform/closest_point_geodesic.hh
--- mln/transform/closest_point_geodesic.hh (revision 0)
+++ mln/transform/closest_point_geodesic.hh (revision 0)
@@ -0,0 +1,81 @@
+// Copyright (C) 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_TRANSFORM_CLOSEST_POINT_GEODESIC_HH
+# define MLN_TRANSFORM_CLOSEST_POINT_GEODESIC_HH
+
+/// \file mln/transform/closest_point_geodesic.hh
+///
+/// Geodesic closest point transform.
+///
+/// \todo Add a version to retrieve both distance and closest point
+/// maps.
+
+# include <mln/canvas/distance_geodesic.hh>
+# include <mln/transform/internal/closest_point_functor.hh>
+
+
+
+namespace mln
+{
+
+ namespace transform
+ {
+
+ /// Discrete geodesic distance transform.
+ template <typename I, typename N, typename D>
+ mln_ch_value(I, mln_psite(I))
+ closest_point_geodesic(const Image<I>& input, const Neighborhood<N>& nbh, D max);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename N, typename D>
+ inline
+ mln_ch_value(I, mln_psite(I))
+ closest_point_geodesic(const Image<I>& input, const Neighborhood<N>& nbh, D max)
+ {
+ trace::entering("transform::closest_point_geodesic");
+
+ mln_precondition(exact(input).is_valid());
+ mln_precondition(exact(nbh).is_valid());
+
+ internal::closest_point_functor<I> f;
+ (void) mln::canvas::distance_geodesic(input, nbh, max, f);
+
+ trace::exiting("transform::closest_point_geodesic");
+ return f.cp_ima;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::transform
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TRANSFORM_CLOSEST_POINT_GEODESIC_HH
Index: mln/transform/all.hh
--- mln/transform/all.hh (revision 3304)
+++ mln/transform/all.hh (working copy)
@@ -42,6 +42,7 @@
} // end of namespace mln
+# include <mln/transform/closest_point_geodesic.hh>
# include <mln/transform/distance_front.hh>
# include <mln/transform/distance_geodesic.hh>
# include <mln/transform/influence_zone_front.hh>
Index: mln/transform/internal/influence_zone_functor.hh
--- mln/transform/internal/influence_zone_functor.hh (revision 3304)
+++ mln/transform/internal/influence_zone_functor.hh (working copy)
@@ -49,14 +49,21 @@
struct influence_zone_functor
{
typedef mln_value(I) V;
- typedef mln_site(I) P;
+ typedef mln_psite(I) P;
mln_concrete(I) output;
void init(const I& input);
bool inqueue_p_wrt_input_p(const V& input_p);
bool inqueue_p_wrt_input_n(const V& input_n);
+ void init_p(const P&) {} // FIXME: move def below.
void process(const P& p, const P& n);
+
+ void init_(const I& input) { output = duplicate(input); }
+ bool inqueue_p_wrt_input_p_(const V& input_p) { return input_p != 0u; }
+ bool inqueue_p_wrt_input_n_(const V& input_n) { return input_n == 0u; }
+ void init_p_(unsigned) {}
+ void process_(unsigned p, unsigned n) { output.element(n) = output.element(p); }
};
Index: mln/transform/internal/closest_point_functor.hh
--- mln/transform/internal/closest_point_functor.hh (revision 3304)
+++ mln/transform/internal/closest_point_functor.hh (working copy)
@@ -48,7 +48,9 @@
struct closest_point_functor
{
typedef mln_value(I) V;
- typedef mln_site(I) P;
+ typedef mln_psite(I) P;
+
+ mln_ch_value(I,P) cp_ima;
void init(const I&);
bool inqueue_p_wrt_input_p(const V& input_p);
@@ -56,7 +58,11 @@
bool inqueue_p_wrt_input_n(const V& input_n);
void process(const P&, const P&);
- mln_ch_value(I,P) cp_ima;
+ void init_(const I& input) { initialize(cp_ima, input); }
+ bool inqueue_p_wrt_input_p_(const V& input_p) { return input_p == true; }
+ void init_p_(unsigned p) { cp_ima.element(p) = cp_ima.point_at_index(p); }
+ bool inqueue_p_wrt_input_n_(const V& input_n) { return input_n == false; }
+ void process_(unsigned p, unsigned n) { cp_ima.element(n) = cp_ima.element(p); }
};
Index: mln/transform/internal/distance_functor.hh
--- mln/transform/internal/distance_functor.hh (revision 3304)
+++ mln/transform/internal/distance_functor.hh (working copy)
@@ -31,6 +31,8 @@
/// \file mln/transform/internal/distance_functor.hh
///
/// Distance functor.
+///
+/// \todo Move all functors into their corresponding file.
# include <mln/core/macros.hh>
@@ -56,6 +58,13 @@
void init_p(const P&);
bool inqueue_p_wrt_input_n(const V& input_n);
void process(const P&, const P&);
+
+
+ void init_(const I&) {}
+ bool inqueue_p_wrt_input_p_(const V& input_p) { return input_p == true; }
+ void init_p_(unsigned) {}
+ bool inqueue_p_wrt_input_n_(const V& input_n) { return input_n == false; }
+ void process_(unsigned, unsigned) {}
};
Index: mln/canvas/distance_geodesic.hh
--- mln/canvas/distance_geodesic.hh (revision 3304)
+++ mln/canvas/distance_geodesic.hh (working copy)
@@ -1,5 +1,4 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 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
@@ -32,14 +31,16 @@
/// \file mln/canvas/distance_geodesic.hh
///
/// Discrete geodesic distance canvas.
-///
-/// \todo add fast version. Use extension(input) = true and extension(map) = 0.
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
-# include <mln/core/site_set/p_queue_fast.hh>
# include <mln/core/routine/duplicate.hh>
+
+# include <mln/core/site_set/p_queue_fast.hh>
+# include <queue>
+
# include <mln/data/fill.hh>
+# include <mln/extension/adjust_fill.hh>
namespace mln
@@ -56,20 +57,59 @@
F& functor);
+
# ifndef MLN_INCLUDE_ONLY
+ // Tests.
+
+ namespace internal
+ {
+
+ template <typename I, typename N, typename D,
+ typename F>
+ void
+ distance_geodesic_tests(const Image<I>& input_, const Neighborhood<N>& nbh_, D max,
+ F& functor)
+ {
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+
+ mln_precondition(input.is_valid());
+ mln_precondition(nbh.is_valid());
+
+ (void) input;
+ (void) nbh;
+ (void) max;
+ (void) functor;
+ }
+
+
+ } // of namespace mln::canvas::internal
+
+
+
+ // Implementations.
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+
template <typename I, typename N, typename D,
typename F>
mln_ch_value(I, D)
distance_geodesic(const Image<I>& input_, const Neighborhood<N>& nbh_, D max,
F& functor)
{
- trace::entering("canvas::distance_geodesic");
+ trace::entering("canvas::impl::generic::distance_geodesic");
const I& input = exact(input_);
const N& nbh = exact(nbh_);
+ internal::distance_geodesic_tests(input, nbh, max, functor);
+
mln_precondition(input.is_valid());
mln_precondition(nbh.is_valid());
@@ -81,14 +121,17 @@
// Initialization.
{
+ trace::entering("initialization");
+
functor.init(input); // <-- init
data::fill(dmap, max);
+
mln_piter(I) p(input.domain());
mln_niter(N) n(nbh, p);
for_all(p)
if (functor.inqueue_p_wrt_input_p(input(p))) // <-- inqueue_p_wrt_input_p
{
- functor.init_p(p);
+ functor.init_p(p); // <-- init_p
dmap(p) = 0;
for_all(n)
if (input.domain().has(n) &&
@@ -98,10 +141,12 @@
break;
}
}
+ trace::exiting("initialization");
}
// Propagation.
{
+ trace::entering("propagation");
P p;
mln_niter(N) n(nbh, p);
while (! q.is_empty())
@@ -121,12 +166,179 @@
q.push(n);
}
}
+ trace::exiting("propagation");
}
- trace::exiting("canvas::distance_geodesic");
+ trace::exiting("canvas::impl::generic::distance_geodesic");
+ return dmap;
+ }
+
+ } // of namespace mln::canvas::impl::generic
+
+
+
+ // Fastest version.
+
+ template <typename I, typename N, typename D,
+ typename F>
+ mln_ch_value(I, D)
+ distance_geodesic_fastest(const Image<I>& input_, const Neighborhood<N>& nbh_, D max,
+ F& functor)
+ {
+ trace::entering("canvas::impl::distance_geodesic_fastest");
+
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+
+ internal::distance_geodesic_tests(input, nbh, max, functor);
+
+ extension::adjust(input, nbh);
+
+ mln_ch_value(I, D) dmap; // Distance map is aux data.
+ initialize(dmap, input);
+
+ std::queue<unsigned> q;
+
+ // Initialization.
+ {
+ trace::entering("initialization");
+
+ functor.init_(input); // <-- init
+ data::fill(dmap, max);
+ // For the extension to be ignored:
+ extension::fill(input, true);
+ extension::fill(dmap, D(0));
+
+ mln_pixter(const I) p(input);
+ mln_nixter(const I, N) n(p, nbh);
+ for_all(p)
+ if (functor.inqueue_p_wrt_input_p_(p.val())) // <-- inqueue_p_wrt_input_p
+ {
+ functor.init_p_(p); // <-- init_p
+ dmap.element(p.offset()) = 0;
+ for_all(n)
+ if (functor.inqueue_p_wrt_input_n_(n.val())) // <-- inqueue_p_wrt_input_n
+ {
+ q.push(p.offset());
+ break;
+ }
+ }
+
+ trace::exiting("initialization");
+ }
+
+ // Propagation.
+ {
+ trace::entering("propagation");
+ unsigned p;
+
+ util::array<int> dp = offsets_wrt(input, nbh);
+ const unsigned n_nbhs = dp.nelements();
+
+ while (! q.empty())
+ {
+ p = q.front();
+ q.pop();
+ if (dmap.element(p) == max)
+ // Saturation so stop.
+ break;
+ for (unsigned i = 0; i < n_nbhs; ++i)
+ {
+ unsigned n = p + dp[i];
+ if (dmap.element(n) == max)
+ {
+ dmap.element(n) = dmap.element(p) + 1;
+ functor.process_(p, n); // <- process
+ q.push(n);
+ }
+ }
+ }
+ trace::exiting("propagation");
+ }
+
+ trace::exiting("canvas::impl::distance_geodesic_fastest");
return dmap;
}
+
+ } // of namespace mln::canvas::impl
+
+
+
+ // Dispatch.
+
+ namespace internal
+ {
+
+ template <typename I, typename N, typename D,
+ typename F>
+ inline
+ mln_ch_value(I, D)
+ distance_geodesic_dispatch(metal::false_,
+ const Image<I>& input, const Neighborhood<N>& nbh, D max,
+ F& functor)
+ {
+ return impl::generic::distance_geodesic(input, nbh, max,
+ functor);
+ }
+
+ template <typename I, typename N, typename D,
+ typename F>
+ inline
+ mln_ch_value(I, D)
+ distance_geodesic_dispatch(metal::true_,
+ const Image<I>& input, const Neighborhood<N>& nbh, D max,
+ F& functor)
+ {
+ return impl::distance_geodesic_fastest(input, nbh, max, functor);
+// return impl::generic::distance_geodesic(input, nbh, max,
+// functor);
+ }
+
+ template <typename I, typename N, typename D,
+ typename F>
+ inline
+ mln_ch_value(I, D)
+ distance_geodesic_dispatch(const Image<I>& input, const Neighborhood<N>& nbh, D max,
+ F& functor)
+ {
+ enum {
+ test = mlc_equal(mln_trait_image_speed(I),
+ trait::image::speed::fastest)::value
+ &&
+ mln_is_simple_neighborhood(N)::value
+ };
+ return distance_geodesic_dispatch(metal::bool_<test>(),
+ input, nbh, max,
+ functor);
+ }
+
+
+ } // of namespace mln::canvas::internal
+
+
+
+ // Facade.
+
+ template <typename I, typename N, typename D,
+ typename F>
+ inline
+ mln_ch_value(I, D)
+ distance_geodesic(const Image<I>& input, const Neighborhood<N>& nbh, D max,
+ F& functor)
+ {
+ trace::entering("canvas::distance_geodesic");
+
+ internal::distance_geodesic_tests(input, nbh, max, functor);
+
+ mln_ch_value(I,D) output;
+ output = internal::distance_geodesic_dispatch(input, nbh, max, functor);
+
+ trace::exiting("canvas::distance_geodesic");
+ return output;
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::canvas
Index: tests/transform/Makefile.am
--- tests/transform/Makefile.am (revision 3304)
+++ tests/transform/Makefile.am (working copy)
@@ -3,11 +3,15 @@
include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
+ bench_closest_point_geodesic \
+ closest_point_geodesic \
distance_front \
distance_geodesic \
influence_zone_front \
influence_zone_geodesic
+bench_closest_point_geodesic_SOURCES = bench_closest_point_geodesic.cc
+closest_point_geodesic_SOURCES = closest_point_geodesic.cc
distance_front_SOURCES = distance_front.cc
distance_geodesic_SOURCES = distance_geodesic.cc
influence_zone_front_SOURCES = influence_zone_front.cc
Index: tests/transform/bench_closest_point_geodesic.cc
--- tests/transform/bench_closest_point_geodesic.cc (revision 0)
+++ tests/transform/bench_closest_point_geodesic.cc (revision 0)
@@ -0,0 +1,63 @@
+// Copyright (C) 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// \file tests/transform/bench_closest_point_geodesic.cc
+///
+/// Test on mln::transform::closest_point_geodesic.
+
+#include <cstdlib>
+
+#include <mln/core/image/image3d.hh>
+#include <mln/core/alias/neighb3d.hh>
+#include <mln/data/fill.hh>
+#include <mln/opt/at.hh>
+#include <mln/transform/closest_point_geodesic.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ const unsigned
+ nslis = 100,
+ nrows = 250,
+ ncols = 250;
+ image3d<bool> input(nslis, nrows, ncols);
+ data::fill(input, false);
+ for (unsigned i = 0; i < 100; ++i)
+ opt::at(input,
+ std::rand() % nslis,
+ std::rand() % nrows,
+ std::rand() % ncols) = true;
+
+ trace::quiet = false;
+
+ image3d<point3d> output = transform::closest_point_geodesic(input,
+ c6(),
+ mln_max(unsigned));
+}
Index: tests/transform/closest_point_geodesic.cc
--- tests/transform/closest_point_geodesic.cc (revision 0)
+++ tests/transform/closest_point_geodesic.cc (revision 0)
@@ -0,0 +1,54 @@
+// Copyright (C) 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// \file tests/transform/closest_point_geodesic.cc
+///
+/// Test on mln::transform::closest_point_geodesic.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/data/fill.hh>
+#include <mln/debug/println.hh>
+#include <mln/opt/at.hh>
+
+#include <mln/transform/closest_point_geodesic.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<bool> input(9, 9);
+ data::fill(input, false);
+ opt::at(input, 2, 4) = true;
+ opt::at(input, 4, 2) = true;
+
+ image2d<point2d> output = transform::closest_point_geodesic(input, c4(), int_u8(4));
+ debug::println(output);
+}