[PATCH 19/31] Have uniform signatures for watershed transforms.

* mln/morpho/meyer_wst.hh (meyer_wst<I, N, L>(const Image<I>&, const Neighborhood<N>&, L&)) Reorder the template parameters... (meyer_wst<L, I, N>(const Image<I>&, const Neighborhood<N>&, L&)): ...so that the type of labels (L) comes first. * mln/morpho/watershed/flooding.hh: Remove useless #include. (watershed::flooding(const Image<I>&, const Neighborhood<N>&, L&)): Likewise. (watershed::flooding(const Image<I>&, const Neighborhood<N>&)): New facade. --- milena/ChangeLog | 16 ++++++ milena/mln/morpho/meyer_wst.hh | 24 +++++---- milena/mln/morpho/watershed/flooding.hh | 88 +++++++++++++++++++------------ 3 files changed, 83 insertions(+), 45 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index d5f79b1..8a351bd 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,19 @@ +2009-05-14 Roland Levillain <roland@lrde.epita.fr> + + Have uniform signatures for watershed transforms. + + * mln/morpho/meyer_wst.hh + (meyer_wst<I, N, L>(const Image<I>&, const Neighborhood<N>&, L&)) + Reorder the template parameters... + (meyer_wst<L, I, N>(const Image<I>&, const Neighborhood<N>&, L&)): + ...so that the type of labels (L) comes first. + * mln/morpho/watershed/flooding.hh: + Remove useless #include. + (watershed::flooding(const Image<I>&, const Neighborhood<N>&, L&)): + Likewise. + (watershed::flooding(const Image<I>&, const Neighborhood<N>&)): + New facade. + 2009-05-11 Roland Levillain <roland@lrde.epita.fr> Clean up Milena's top-level Makefile.am. diff --git a/milena/mln/morpho/meyer_wst.hh b/milena/mln/morpho/meyer_wst.hh index 091db34..90114e0 100644 --- a/milena/mln/morpho/meyer_wst.hh +++ b/milena/mln/morpho/meyer_wst.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008, 2009 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 @@ -39,6 +39,15 @@ eaux. In: Actes du 8ème Congrès AFCET, Lyon-Villeurbanne, France (1991), pages 847--859. */ + +/* FIXME: This file is outdated. Compare this file with + mln/morpho/watershed/flooding.hh, and remove the former when + + 1. it is entirely covered by the latter; + 2. clients (including tests and Milena) are updated to use + mln::morpho::watershed::flooding. */ + + # include <mln/trait/ch_value.hh> // FIXME: See below. @@ -56,14 +65,6 @@ namespace mln 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 - Transform, which proposes to lower-complete the image before - processing it. Then, add a reference to - mln/morpho/lower_completion.hh. */ - /** \brief Meyer's Watershed Transform (WST) algorithm. \param[in] input The input image. @@ -75,7 +76,7 @@ namespace mln \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> + template <typename L, typename I, typename N> mln_ch_value(I, L) meyer_wst(const Image<I>& input, const Neighborhood<N>& nbh, L& nbasins); @@ -101,9 +102,10 @@ namespace mln meyer_wst(const Image<I>& input, const Neighborhood<N>& nbh); + # ifndef MLN_INCLUDE_ONLY - template <typename I, typename N, typename L> + template <typename L, typename I, typename N> mln_ch_value(I, L) meyer_wst(const Image<I>& input_, const Neighborhood<N>& nbh_, L& nbasins) diff --git a/milena/mln/morpho/watershed/flooding.hh b/milena/mln/morpho/watershed/flooding.hh index 837b018..f07f250 100644 --- a/milena/mln/morpho/watershed/flooding.hh +++ b/milena/mln/morpho/watershed/flooding.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008, 2009 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 @@ -42,8 +42,6 @@ # include <mln/trait/ch_value.hh> -// FIXME: See below. -# include <mln/util/greater_psite.hh> # include <mln/morpho/includes.hh> # include <mln/literal/zero.hh> # include <mln/labeling/regional_minima.hh> @@ -63,18 +61,6 @@ namespace mln 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. - */ - /// Meyer's Watershed Transform (WST) algorithm. /// /// \param[in] input The input image. @@ -87,10 +73,30 @@ namespace mln /// \li \p N is the exact type of the neighborhood used to express /// \a input's connexity. - template <typename I, typename N, typename L> + template <typename L, typename I, typename N> mln_ch_value(I, L) - flooding(const Image<I>& input, const Neighborhood<N>& nbh, - L& n_basins); + 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. + /// + /// \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. + /// + /// 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> + mln_ch_value(I, L) + flooding(const Image<I>& input, const Neighborhood<N>& nbh); @@ -105,10 +111,10 @@ namespace mln namespace generic { - template <typename I, typename N, typename L> + template <typename L, typename I, typename N> mln_ch_value(I, L) - flooding(const Image<I>& input_, const Neighborhood<N>& nbh_, - L& n_basins) + 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. */ @@ -209,8 +215,8 @@ namespace mln template <typename I, typename N, typename L> mln_ch_value(I, L) - flooding_fastest(const Image<I>& input_, const Neighborhood<N>& nbh_, - L& n_basins) + flooding_fastest(const Image<I>& input_, const Neighborhood<N>& nbh_, + L& n_basins) { trace::entering("morpho::watershed::impl::flooding_fastest"); /* FIXME: Ensure the input image has scalar values. */ @@ -278,7 +284,8 @@ namespace mln for (unsigned i = 0; i < n_nbhs; ++i) { unsigned n = p + dp[i]; - if (output.element(n) != unmarked) // In the border, output is unmarked so n is ignored. + // In the border, output is unmarked so N is ignored. + if (output.element(n) != unmarked) { if (adjacent_marker == unmarked) { @@ -304,7 +311,8 @@ namespace mln { unsigned n = p + dp[i]; if (output.element(n) == unmarked - && ! in_queue.element(n)) // In the border, in_queue is true so n is ignored. + // In the border, in_queue is true so N is ignored. + && ! in_queue.element(n)) { queue.push(max - input.element(n), n); in_queue.element(n) = true; @@ -330,8 +338,9 @@ namespace mln template <typename I, typename N, typename L> inline mln_ch_value(I, L) - flooding_dispatch(metal::false_, - const Image<I>& input, const Neighborhood<N>& nbh, L& n_basins) + flooding_dispatch(metal::false_, + const Image<I>& input, const Neighborhood<N>& nbh, + L& n_basins) { return impl::generic::flooding(input, nbh, n_basins); } @@ -340,8 +349,9 @@ namespace mln 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) + flooding_dispatch(metal::true_, + const Image<I>& input, const Neighborhood<N>& nbh, + L& n_basins) { return impl::flooding_fastest(input, nbh, n_basins); } @@ -349,7 +359,8 @@ namespace mln 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) + flooding_dispatch(const Image<I>& input, const Neighborhood<N>& nbh, + L& n_basins) { enum { test = mlc_equal(mln_trait_image_speed(I), @@ -364,23 +375,32 @@ namespace mln } // end of namespace mln::morpho::watershed::internal - // Facade. + // Facades. - template <typename I, typename N, typename L> + template <typename L, typename I, typename N> inline mln_ch_value(I, L) - flooding(const Image<I>& input, const Neighborhood<N>& nbh, L& n_basins) + 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); + mln_ch_value(I, L) output = + internal::flooding_dispatch(input, nbh, n_basins); trace::exiting("morpho::watershed::flooding"); return output; } + template <typename L, typename I, typename N> + mln_ch_value(I, L) + flooding(const Image<I>& input, const Neighborhood<N>& nbh) + { + L nbasins; + return flooding<L>(input, nbh, nbasins); + } + # endif // ! MLN_INCLUDE_ONLY } // end of namespace mln::morpho::watershed -- 1.6.1.2
participants (1)
-
Roland Levillain