https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Make morpho erosion generic impl rely on accu transform.
* mln/set/compute.hh (todo): New.
* mln/morpho/erosion.hh
(erosion_on_function): Rely on accu transform.
* mln/morpho/erosion.spe.hh
(erosion_on_function_fastest) Remove; useless since
accu::transform is specialized for fastest input.
(dispatch for the generic version): Remove; useless.
morpho/erosion.hh | 21 +++---------------
morpho/erosion.spe.hh | 58 --------------------------------------------------
set/compute.hh | 5 +++-
3 files changed, 8 insertions(+), 76 deletions(-)
Index: mln/set/compute.hh
--- mln/set/compute.hh (revision 2871)
+++ mln/set/compute.hh (working copy)
@@ -30,9 +30,12 @@
/// \file mln/set/compute.hh
///
-/// Compute an accumulator on a site set.
+/// Compute an accumulator on a site set or a binary image.
+///
+/// \todo Add a version with a binary image as input.
# include <mln/core/concept/meta_accumulator.hh>
+# include <mln/core/concept/image.hh>
# include <mln/core/concept/site_set.hh>
Index: mln/morpho/erosion.spe.hh
--- mln/morpho/erosion.spe.hh (revision 2871)
+++ mln/morpho/erosion.spe.hh (working copy)
@@ -97,38 +97,6 @@
template <typename I, typename W>
mln_concrete(I)
- erosion_on_function_fastest(const Image<I>& input_, const
Window<W>& win_)
- {
- trace::entering("morpho::impl::erosion_on_function_fastest");
-
- typedef mln_concrete(I) O;
- const I& input = exact(input_);
- const W& win = exact(win_);
-
- extension::adjust_fill(input, win, mln_max(mln_value(I)));
-
- O output;
- initialize(output, input);
-
- mln_pixter(const I) p(input);
- mln_pixter(O) o(output);
- mln_qixter(const I, W) q(p, win);
- accu::min<mln_value(I)> min;
- for_all_2(p, o)
- {
- min.init();
- for_all(q)
- min.take(q.val());
- o.val() = min.to_result();
- }
-
- trace::exiting("morpho::impl::erosion_on_function_fastest");
-
- return output;
- }
-
- template <typename I, typename W>
- mln_concrete(I)
erosion_on_set_fastest(const Image<I>& input_, const Window<W>&
win_)
{
trace::entering("morpho::impl::erosion_on_set_fastest");
@@ -1169,32 +1137,6 @@
namespace internal
{
- // dispatch for the generic version
-
- // FIXME: De-activate because when the window is multiple, the access
- // win.dp(i), used in dpoints_pixter, is impossible.
-
- // template <typename I, typename W>
- // mln_concrete(I)
- // erosion_dispatch_for_generic(trait::image::kind::logic, // On sets.
- // trait::image::speed::fastest,
- // const I& input, const W& win)
- // {
- // if (win.is_centered())
- // return impl::erosion_on_set_centered_fastest(input, win);
- // else
- // return impl::erosion_on_set_fastest(input, win);
- // }
-
- // template <typename I, typename W>
- // mln_concrete(I)
- // erosion_dispatch_for_generic(trait::image::kind::any, // On functions.
- // trait::image::speed::fastest,
- // const I& input, const W& win)
- // {
- // return impl::erosion_on_function_fastest(input, win);
- // }
-
template <typename I, typename W>
mln_concrete(I)
erosion_dispatch_for_generic(trait::image::kind::logic, // On sets.
Index: mln/morpho/erosion.hh
--- mln/morpho/erosion.hh (revision 2871)
+++ mln/morpho/erosion.hh (working copy)
@@ -34,6 +34,7 @@
/// \brief Morphological erosion.
# include <mln/morpho/includes.hh>
+# include <mln/accu/transform.hh>
// Specializations are in:
# include <mln/morpho/erosion.spe.hh>
@@ -83,35 +84,21 @@
namespace generic
{
+
// On function.
template <typename I, typename W>
inline
mln_concrete(I)
- erosion_on_function(const Image<I>& input_, const Window<W>& win_)
+ erosion_on_function(const Image<I>& input, const Window<W>& win)
{
trace::entering("morpho::impl::generic::erosion_on_function");
- const I& input = exact(input_);
- const W& win = exact(win_);
internal::erosion_tests(input, win);
extension::adjust_fill(input, win, mln_max(mln_value(I)));
-
mln_concrete(I) output;
- initialize(output, input);
-
- accu::min<mln_value(I)> min;
-
- mln_piter(I) p(input.domain());
- mln_qiter(W) q(win, p);
- for_all(p)
- {
- min.init();
- for_all(q) if (input.has(q))
- min.take(input(q));
- output(p) = min;
- }
+ output = accu::transform(input, accu::meta::min(), win);
trace::exiting("morpho::impl::generic::erosion_on_function");
return output;