https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Specialize accu tranform for fastest images.
* mln/accu/snake_2d.hh (todo): New.
* mln/accu/transform.hh (transform_fastest): New.
(transform_dispatch): New overload.
(todo): Remove; obsolete.
* mln/canvas/browsing/snake_generic.hh: Upgrade doc style.
(include): Remove useless 'stack'.
accu/snake_2d.hh | 2 +
accu/transform.hh | 77 ++++++++++++++++++++++++++++++++-------
canvas/browsing/snake_generic.hh | 12 +++---
3 files changed, 72 insertions(+), 19 deletions(-)
Index: mln/accu/snake_2d.hh
--- mln/accu/snake_2d.hh (revision 2861)
+++ mln/accu/snake_2d.hh (working copy)
@@ -31,6 +31,8 @@
/// \file mln/accu/snake_2d.hh
///
/// Run an accumulator in a snake-like browsing.
+///
+/// \todo Make it n-D.
#include <mln/core/concept/image.hh>
#include <mln/core/concept/meta_accumulator.hh>
Index: mln/accu/transform.hh
--- mln/accu/transform.hh (revision 2861)
+++ mln/accu/transform.hh (working copy)
@@ -32,8 +32,6 @@
///
/// Transform an image by applying locally an accumulator on its
/// values.
-///
-/// \todo Specialize for fastest images.
# include <mln/core/concept/meta_accumulator.hh>
# include <mln/core/concept/image.hh>
@@ -67,6 +65,8 @@
namespace impl
{
+ // Generic version.
+
namespace generic
{
@@ -79,8 +79,8 @@
trace::entering("accu::impl::generic::transform");
const I& input = exact(input_);
- A a = exact(a_);
const W& win = exact(win_);
+ A a = exact(a_);
mln_precondition(input.has_data());
// mln_precondition(win.is_valid());
@@ -106,32 +106,85 @@
} // end of namespace mln::accu::impl::generic
+
+ // Fastest version.
+
+ template <typename I, typename A, typename W>
+ mln_ch_value(I, mln_result(A))
+ transform_fastest(const Image<I>& input_, const Accumulator<A>&
a_, const Window<W>& win_)
+ {
+ trace::entering("accu::impl::transform_fastest");
+
+ const I& input = exact(input_);
+ const W& win = exact(win_);
+ A a = exact(a_);
+
+ mln_precondition(input.has_data());
+ // mln_precondition(win.is_valid());
+
+ extension::adjust(input, win);
+
+ typedef mln_ch_value(I, mln_result(A)) O;
+ O output;
+ initialize(output, input);
+ mln_pixter(O) o(output);
+
+ mln_pixter(const I) p(input);
+ mln_qixter(const I, W) q(p, win);
+ for_all_2(p, o)
+ {
+ a.init();
+ for_all(q)
+ a.take(q.val());
+ o.val() = a.to_result();
+ }
+
+ trace::exiting("accu::impl::transform_fastest");
+ return output;
+ }
+
+
} // end of namespace mln::accu::impl
+ // Dispatch.
+
namespace internal
{
template <typename I, typename A, typename W>
- inline
mln_ch_value(I, mln_result(A))
- transform_dispatch(const Image<I>& input,
- const Accumulator<A>& a,
- const Window<W>& win)
+ transform_dispatch(trait::image::speed::any,
+ const Image<I>& input, const Accumulator<A>& a, const
Window<W>& win)
{
return impl::generic::transform(input, a, win);
}
+ template <typename I, typename A, typename W>
+ mln_ch_value(I, mln_result(A))
+ transform_dispatch(trait::image::speed::fastest,
+ const Image<I>& input, const Accumulator<A>& a, const
Window<W>& win)
+ {
+ return impl::transform_fastest(input, a, win);
+ }
+
+ template <typename I, typename A, typename W>
+ mln_ch_value(I, mln_result(A))
+ transform_dispatch(const Image<I>& input, const Accumulator<A>&
a, const Window<W>& win)
+ {
+ return transform_dispatch(mln_trait_image_speed(I)(),
+ input, a, win);
+ }
+
} // end of namespace mln::accu::internal
+ // Facades.
template <typename I, typename A, typename W>
inline
mln_ch_value(I, mln_result(A))
- transform(const Image<I>& input,
- const Accumulator<A>& a,
- const Window<W>& win)
+ transform(const Image<I>& input, const Accumulator<A>& a, const
Window<W>& win)
{
trace::entering("accu::transform");
@@ -147,9 +200,7 @@
template <typename I, typename A, typename W>
mln_ch_value(I, mln_accu_with(A, mln_value(I))::result)
- transform(const Image<I>& input,
- const Meta_Accumulator<A>& a,
- const Window<W>& win)
+ transform(const Image<I>& input, const Meta_Accumulator<A>& a,
const Window<W>& win)
{
trace::entering("accu::transform");
Index: mln/canvas/browsing/snake_generic.hh
--- mln/canvas/browsing/snake_generic.hh (revision 2861)
+++ mln/canvas/browsing/snake_generic.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// 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
@@ -28,14 +29,13 @@
#ifndef MLN_CANVAS_BROWSING_SNAKE_GENERIC_HH
# define MLN_CANVAS_BROWSING_SNAKE_GENERIC_HH
-/*! \file mln/canvas/browsing/snake_generic.hh
- *
- * \brief Browsing in a snake-way, forward.
- */
+/// \file mln/canvas/browsing/snake_generic.hh
+///
+/// Browsing in a snake-way, forward.
-# include <stack>
# include <mln/core/concept/browsing.hh>
+
namespace mln
{