
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Move diagonal-related code out of erosion, then factor. * mln/accu/transform_diagonal.hh: New file. * mln/morpho/erosion.spe.hh (erosion_diagonal2d_functor), (erosion_diagonal2d_fastest_functor), (erosion_backdiagonal2d_functor), (erosion_backdiagonal2d_fastest_functor): Move and rename as... * mln/accu/transform_diagonal.hh (diagonal_functor, diagonal_fastest_functor), (backdiagonal_functor, backdiagonal_fastest_functor): ...these. * mln/morpho/erosion.spe.hh (erosion_diagonal2d): Rename as... (erosion_diagonal_2d): ...this; it is the only impl routine. (erosion_backdiagonal2d), (erosion_diagonal2d_fastest), (erosion_backdiagonal2d_fastest): Remove these impl routines. Thanks to factorization in accu::transform_diagonal, those are now useless. (erosion_dispatch_for_diagonal2d), (erosion_dispatch_for_backdiagonal2d): Factor into... (erosion_dispatch_diagonal): ...this new dispatch routine. Now both diagonals are handled by the same code. * mln/morpho/includes.hh: Update. * mln/accu/transform_directional.hh (diff): Remove useless include. * mln/win/line.hh: Upgrade doc style. (dir): New constant. accu/transform_diagonal.hh | 481 ++++++++++++++++++++++++++++++++++++++++++ accu/transform_directional.hh | 1 morpho/erosion.spe.hh | 468 +++------------------------------------- morpho/includes.hh | 1 win/line.hh | 17 - 5 files changed, 526 insertions(+), 442 deletions(-) Index: mln/accu/transform_directional.hh --- mln/accu/transform_directional.hh (revision 2881) +++ mln/accu/transform_directional.hh (working copy) @@ -40,7 +40,6 @@ #include <mln/core/concept/image.hh> #include <mln/core/concept/meta_accumulator.hh> #include <mln/core/alias/window2d.hh> -#include <mln/win/diff.hh> #include <mln/win/shift.hh> #include <mln/geom/delta.hh> #include <mln/literal/zero.hh> Index: mln/accu/transform_diagonal.hh --- mln/accu/transform_diagonal.hh (revision 0) +++ mln/accu/transform_diagonal.hh (revision 0) @@ -0,0 +1,481 @@ +// 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_ACCU_TRANSFORM_DIAGONAL_HH +# define MLN_ACCU_TRANSFORM_DIAGONAL_HH + +/// \file mln/accu/transform_diagonal.hh +/// +/// Run an accumulator over a diagonal. +/// +/// \todo Split dispatch and impl. +/// +/// \todo Pass the accumulator to the function-object. + + +#include <mln/core/concept/image.hh> +#include <mln/core/concept/meta_accumulator.hh> +#include <mln/core/alias/window2d.hh> +#include <mln/win/shift.hh> +#include <mln/geom/delta.hh> +#include <mln/extension/adjust.hh> + +#include <mln/win/diag2d.hh> +#include <mln/canvas/browsing/diagonal2d.hh> + +#include <mln/win/backdiag2d.hh> +#include <mln/canvas/browsing/backdiagonal2d.hh> + + + +namespace mln +{ + + namespace accu + { + + + template <typename A, typename I, typename W> + mln_ch_value(I, mln_result(A)) + transform_diagonal(const Accumulator<A>&, + const Image<I>& input, const Window<W>& win, + unsigned dir); + + + template <typename A, typename I, typename W> + mln_ch_value(I, mln_accu_with(A, mln_value(I))::result) + transform_diagonal(const Meta_Accumulator<A>&, + const Image<I>& input, const Window<W>& win, + unsigned dir); + + + +# ifndef MLN_INCLUDE_ONLY + + namespace internal + { + + + // Tests. + + + template <typename I, typename W> + void transform_diagonal_tests(const Image<I>& input_, const Window<W>& win_) + { + const I& input = exact(input_); + const W& win = exact(win_); + + mln_precondition(input.has_data()); + mln_precondition(! win.is_empty()); + // mln_precondition(! win.is_valid()); + + (void) input; + (void) win; + } + + + + // Functors. + + + template <typename I_, typename W, typename A> + struct diagonal_functor + { + typedef I_ I; + typedef mln_deduce(I, psite, delta) dpsite; + + const I& input; + const W& win; + mln_concrete(I) output; + A accu; + + mln_psite(I) p; + enum { dim = I::site::dim }; + unsigned dir; + + window2d win_left, win_right; + + mln_qiter(window2d) q_l, q_r; + + diagonal_functor(const I& input, const W& win) + : input(input), + win(win), + accu(), + dir(dir), + win_left(win::shift(win, dpsite(1, -1)) - win), + win_right(win - win::shift(win, dpsite(1, -1))), + q_l(win_left, p), + q_r(win_right, p) + { + } + + void init() + { + initialize(output, input); + } + + void next() + { + for_all(q_l) + accu.untake(input(q_l)); + for_all(q_r) + accu.take(input(q_r)); + output(p) = accu; + } + + + void init_diag() + { + accu.init(); + p = p - dpsite(-1, 1); + mln_qiter(W) q(win, p); + for_all(q) + accu.take(input(q)); + p = p + dpsite(-1, 1); + } + + void final() + { + } + + }; + + + + template <typename I_, typename W, typename A> + struct backdiagonal_functor + { + typedef I_ I; + typedef mln_deduce(I, psite, delta) dpsite; + + const I& input; + const W& win; + mln_concrete(I) output; + A accu; + + mln_psite(I) p; + enum { dim = I::site::dim }; + unsigned dir; + + window2d win_left, win_right; + + mln_qiter(window2d) q_l, q_r; + + backdiagonal_functor(const I& input, const W& win) + : input(input), + win(win), + accu(), + dir(dir), + win_left(win::shift(win, dpsite(-1, -1)) - win), + win_right(win - win::shift(win, dpsite(-1, -1))), + q_l(win_left, p), + q_r(win_right, p) + { + } + + void init() + { + initialize(output, input); + } + + void next() + { + for_all(q_l) + accu.untake(input(q_l)); + for_all(q_r) + accu.take(input(q_r)); + output(p) = accu; + } + + + void init_diag() + { + accu.init(); + p = p - dpsite(1, 1); + mln_qiter(W) q(win, p); + for_all(q) + accu.take(input(q)); + p = p + dpsite(1, 1); + } + + void final() + { + } + + }; + + + + // Functors (fastest versions). + + + template <typename I_, typename W, typename A> + struct diagonal_fastest_functor + { + typedef I_ I; + typedef mln_deduce(I, psite, delta) dpsite; + + const I& input; + const W& win; + mln_concrete(I) output; + A accu; + + mln_psite(I) p; + enum { dim = I::site::dim }; + unsigned dir; + + window2d win_left, win_right; + + mln_qixter(const I, window2d) q_l, q_r; + + diagonal_fastest_functor(const I& input, const W& win) + : input(input), + win(win), + accu(), + dir(dir), + win_left(win::shift(win, dpsite(1, -1)) - win), + win_right(win - win::shift(win, dpsite(1, -1))), + q_l(input, win_left, p), + q_r(input, win_right, p) + { + } + + void init() + { + initialize(output, input); + } + + void next() + { + for_all(q_l) + accu.untake(q_l.val()); + for_all(q_r) + accu.take(q_r.val()); + output(p) = accu; + } + + + void init_diag() + { + accu.init(); + p = p - dpsite(-1, 1); + mln_qixter(const I, W) q(input, win, p); + for_all(q) + accu.take(q.val()); + p = p + dpsite(-1, 1); + } + + void final() + { + } + + }; + + + template <typename I_, typename W, typename A> + struct backdiagonal_fastest_functor + { + typedef I_ I; + typedef mln_deduce(I, psite, delta) dpsite; + + const I& input; + const W& win; + mln_concrete(I) output; + A accu; + + mln_psite(I) p; + enum { dim = I::site::dim }; + unsigned dir; + + window2d win_left, win_right; + + mln_qixter(const I, window2d) q_l, q_r; + + backdiagonal_fastest_functor(const I& input, const W& win) + : input(input), + win(win), + accu(), + dir(dir), + win_left(win::shift(win, dpsite(-1, -1)) - win), + win_right(win - win::shift(win, dpsite(-1, -1))), + q_l(input, win_left, p), + q_r(input, win_right, p) + { + } + + void init() + { + initialize(output, input); + } + + void next() + { + for_all(q_l) + accu.untake(q_l.val()); + for_all(q_r) + accu.take(q_r.val()); + output(p) = accu; + } + + + void init_diag() + { + accu.init(); + p = p - dpsite(1, 1); + mln_qixter(const I, W) q(input, win, p); + for_all(q) + accu.take(q.val()); + p = p + dpsite(1, 1); + } + + void final() + { + } + + }; + + + + + // Both dispatch and implementation (hum...) + + template <typename A, typename I> + inline + mln_ch_value(I, mln_result(A)) + transform_diagonal_dispatch(trait::image::speed::any, + const Accumulator<A>& /* FIXME a */, + const Image<I>& input, const win::diag2d& win) + { + typedef diagonal_functor<I, win::diag2d, A> F; + F f(exact(input), win); // FIXME: Pass a to f. + canvas::browsing::diagonal2d(f); + return f.output; + } + + template <typename A, typename I> + inline + mln_ch_value(I, mln_result(A)) + transform_diagonal_dispatch(trait::image::speed::any, + const Accumulator<A>& /* FIXME a */, + const Image<I>& input, const win::backdiag2d& win) + { + typedef backdiagonal_functor<I, win::backdiag2d, A> F; + F f(exact(input), win); // FIXME: Pass a to f. + canvas::browsing::backdiagonal2d(f); + return f.output; + } + + template <typename A, typename I> + inline + mln_ch_value(I, mln_result(A)) + transform_diagonal_dispatch(trait::image::speed::fastest, + const Accumulator<A>& /* FIXME a*/, + const Image<I>& input, const win::diag2d& win) + { + typedef diagonal_fastest_functor<I, win::diag2d, A> F; + F f(exact(input), win); // FIXME: Pass a to f. + canvas::browsing::diagonal2d(f); + return f.output; + } + + template <typename A, typename I> + inline + mln_ch_value(I, mln_result(A)) + transform_diagonal_dispatch(trait::image::speed::fastest, + const Accumulator<A>& /* FIXME a*/, + const Image<I>& input, const win::backdiag2d& win) + { + typedef backdiagonal_fastest_functor<I, win::backdiag2d, A> F; + F f(exact(input), win); // FIXME: Pass a to f. + canvas::browsing::backdiagonal2d(f); + return f.output; + } + + template <typename A, typename I, typename W> + inline + mln_ch_value(I, mln_result(A)) + transform_diagonal_dispatch(const Accumulator<A>& a, + const Image<I>& input, const Window<W>& win) + { + return transform_diagonal_dispatch(mln_trait_image_speed(I)(), + a, input, exact(win)); + } + + } // end of namespace mln::accu::internal + + + + + template <typename A, typename I, typename W> + inline + mln_ch_value(I, mln_result(A)) + transform_diagonal(const Accumulator<A>& a, + const Image<I>& input, const Window<W>& win) + { + trace::entering("accu::transform_diagonal"); + + internal::transform_diagonal_tests(input, win); + + extension::adjust(input, geom::delta(win) + 1); + mln_ch_value(I, mln_result(A)) output; + output = internal::transform_diagonal_dispatch(a, input, win); + + trace::exiting("accu::transform_diagonal"); + return output; + } + + + template <typename A, typename I, typename W> + inline + mln_ch_value(I, mln_accu_with(A, mln_value(I))::result) + transform_diagonal(const Meta_Accumulator<A>& a, + const Image<I>& input, const Window<W>& win) + { + trace::entering("accu::transform_diagonal"); + + internal::transform_diagonal_tests(input, win); + + typedef mln_accu_with(A, mln_value(I)) A_; + A_ a_ = accu::unmeta(exact(a), mln_value(I)()); + + extension::adjust(input, geom::delta(win) + 1); + mln_ch_value(I, mln_result(A_)) output; + output = internal::transform_diagonal_dispatch(a_, input, win); + + trace::exiting("accu::transform_diagonal"); + return output; + } + + +# endif // ! MLN_INCLUDE_ONLY + + } // end of namespace mln::accu + +} // end of namespace mln + + +#endif // ! MLN_ACCU_TRANSFORM_DIAGONAL_HH Index: mln/win/line.hh --- mln/win/line.hh (revision 2881) +++ mln/win/line.hh (working copy) @@ -73,12 +73,12 @@ template <typename M, unsigned i, typename C> struct line : public internal::classical_window_base< dpoint<M, C>, line<M,i,C> > { - /*! \brief Constructor. - * - * \param[in] length Length of the line. - * - * \pre \p length is odd. - */ + /// Direction. + enum { dir = i }; + + /// Constructor. + /// \param[in] length Length of the line. + /// \pre \p length is odd. line(unsigned length); /// Give the line length. @@ -87,9 +87,8 @@ /// Give the line size, that is, its length. unsigned size() const; - /*! \brief Give the maximum coordinate gap between the window - * center and a window point. - */ + /// Give the maximum coordinate gap between the window + /// center and a window point. unsigned delta_() const; void print_(std::ostream& ostr) const; Index: mln/morpho/erosion.spe.hh --- mln/morpho/erosion.spe.hh (revision 2881) +++ mln/morpho/erosion.spe.hh (working copy) @@ -161,6 +161,9 @@ + // Line case. + + template <typename I, typename G, unsigned Dir, typename C> inline mln_concrete(I) @@ -210,6 +213,10 @@ } + + // Particular windows. + + template <typename I> inline mln_concrete(I) @@ -250,7 +257,6 @@ } - template <typename I, typename W> inline mln_concrete(I) @@ -270,7 +276,6 @@ } - template <typename I, typename W> inline mln_concrete(I) @@ -290,350 +295,32 @@ } - - // Diagonal2d non fastest. - template <typename I_, typename W, typename A> - struct erosion_diagonal2d_functor - { - typedef I_ I; - typedef mln_deduce(I, psite, delta) dpsite; - - const I& input; - const W& win; - mln_concrete(I) output; - A accu; - - mln_psite(I) p; - enum { dim = I::site::dim }; - unsigned dir; - - window2d win_left, win_right; - - mln_qiter(window2d) q_l, q_r; - - erosion_diagonal2d_functor(const I& input, const W& win) - : input(input), - win(win), - accu(), - dir(dir), - win_left(win::shift(win, dpsite(1, -1)) - win), - win_right(win - win::shift(win, dpsite(1, -1))), - q_l(win_left, p), - q_r(win_right, p) - { - } - - void init() - { - extension::adjust_fill(input, win, accu); - initialize(output, input); - } - - void next() - { - for_all(q_l) - accu.untake(input(q_l)); - for_all(q_r) - accu.take(input(q_r)); - output(p) = accu; - } - - - void init_diag() - { - accu.init(); - p = p - dpsite(-1, 1); - mln_qiter(W) q(win, p); - for_all(q) - accu.take(input(q)); - p = p + dpsite(-1, 1); - } - - void final() - { - } - - }; - - // Backdiagonal2d non fastest. - template <typename I, typename W> - inline - mln_concrete(I) - erosion_diagonal2d(const Image<I>& input, const Window<W>& win) - { - trace::entering("morpho::impl:erosion_diagonal2d"); - - typedef mlc_is(mln_trait_image_kind(I), - trait::image::kind::binary) is_binary; - typedef mlc_if(is_binary, accu::land, accu::min_h<mln_value(I)>) A; - - typedef erosion_diagonal2d_functor<I, W, A> F; - F f(exact(input), exact(win)); - canvas::browsing::diagonal2d(f); - - trace::exiting("morpho::impl:erosion_diagonal2d"); - - return f.output; - } - - - - template <typename I_, typename W, typename A> - struct erosion_backdiagonal2d_functor - { - typedef I_ I; - typedef mln_deduce(I, psite, delta) dpsite; - - const I& input; - const W& win; - mln_concrete(I) output; - A accu; - - mln_psite(I) p; - enum { dim = I::site::dim }; - unsigned dir; - - window2d win_left, win_right; - - mln_qiter(window2d) q_l, q_r; - - erosion_backdiagonal2d_functor(const I& input, const W& win) - : input(input), - win(win), - accu(), - dir(dir), - win_left(win::shift(win, dpsite(-1, -1)) - win), - win_right(win - win::shift(win, dpsite(-1, -1))), - q_l(win_left, p), - q_r(win_right, p) - { - } - - void init() - { - extension::adjust_fill(input, win, accu); - initialize(output, input); - } - - void next() - { - for_all(q_l) - accu.untake(input(q_l)); - for_all(q_r) - accu.take(input(q_r)); - output(p) = accu; - } - - - void init_diag() - { - accu.init(); - p = p - dpsite(1, 1); - mln_qiter(W) q(win, p); - for_all(q) - accu.take(input(q)); - p = p + dpsite(1, 1); - } - - void final() - { - } - - }; - template <typename I, typename W> inline mln_concrete(I) - erosion_backdiagonal2d(const Image<I>& input, const Window<W>& win) - { - trace::entering("morpho::impl:erosion_backdiagonal2d"); - - typedef mlc_is(mln_trait_image_kind(I), - trait::image::kind::binary) is_binary; - typedef mlc_if(is_binary, accu::land, accu::min_h<mln_value(I)>) A; - - typedef erosion_backdiagonal2d_functor<I, W, A> F; - F f(exact(input), exact(win)); - canvas::browsing::backdiagonal2d(f); - - trace::exiting("morpho::impl:erosion_backdiagonal2d"); - - return f.output; - } - - - - // Diagonal2d fastest. - template <typename I_, typename W, typename A> - struct erosion_diagonal2d_fastest_functor + erosion_diagonal_2d(const Image<I>& input, const Window<W>& win) { - typedef I_ I; - typedef mln_deduce(I, psite, delta) dpsite; - - const I& input; - const W& win; - mln_concrete(I) output; - A accu; - - mln_psite(I) p; - enum { dim = I::site::dim }; - unsigned dir; - - window2d win_left, win_right; - - mln_qixter(const I, window2d) q_l, q_r; - - erosion_diagonal2d_fastest_functor(const I& input, const W& win) - : input(input), - win(win), - accu(), - dir(dir), - win_left(win::shift(win, dpsite(1, -1)) - win), - win_right(win - win::shift(win, dpsite(1, -1))), - q_l(input, win_left, p), - q_r(input, win_right, p) - { - } + trace::entering("morpho::impl:erosion_diagonal_2d"); - void init() - { - extension::adjust_fill(input, win, accu); - initialize(output, input); - } - - void next() - { - for_all(q_l) - accu.untake(q_l.val()); - for_all(q_r) - accu.take(q_r.val()); - output(p) = accu; - } - - - void init_diag() - { - accu.init(); - p = p - dpsite(-1, 1); - mln_qixter(const I, W) q(input, win, p); - for_all(q) - accu.take(q.val()); - p = p + dpsite(-1, 1); - } - - void final() - { - } - - }; - - template <typename I, typename W> - inline - mln_concrete(I) - erosion_diagonal2d_fastest(const Image<I>& input, const Window<W>& win) - { - trace::entering("morpho::impl:erosion_diagonal2d_fastest"); - - typedef mlc_is(mln_trait_image_kind(I), - trait::image::kind::binary) is_binary; + typedef mlc_is(mln_trait_image_kind(I), trait::image::kind::binary) is_binary; typedef mlc_if(is_binary, accu::land, accu::min_h<mln_value(I)>) A; + A a; - typedef erosion_diagonal2d_fastest_functor<I, W, A> F; - F f(exact(input), exact(win)); - canvas::browsing::diagonal2d(f); - - trace::exiting("morpho::impl:erosion_diagonal2d_fastest"); - - return f.output; - } - - - - // Backdiagonal2d fastest. - template <typename I_, typename W, typename A> - struct erosion_backdiagonal2d_fastest_functor - { - typedef I_ I; - typedef mln_deduce(I, psite, delta) dpsite; - - const I& input; - const W& win; - mln_concrete(I) output; - A accu; - - mln_psite(I) p; - enum { dim = I::site::dim }; - unsigned dir; - - window2d win_left, win_right; - - mln_qixter(const I, window2d) q_l, q_r; - - erosion_backdiagonal2d_fastest_functor(const I& input, const W& win) - : input(input), - win(win), - accu(), - dir(dir), - win_left(win::shift(win, dpsite(-1, -1)) - win), - win_right(win - win::shift(win, dpsite(-1, -1))), - q_l(input, win_left, p), - q_r(input, win_right, p) - { - } - - void init() - { - extension::adjust_fill(input, win, accu); - initialize(output, input); - } - - void next() - { - for_all(q_l) - accu.untake(q_l.val()); - for_all(q_r) - accu.take(q_r.val()); - output(p) = accu; - } - + extension::adjust_fill(input, geom::delta(win) + 1, a); + mln_concrete(I) output = accu::transform_diagonal(a, input, win); - void init_diag() - { - accu.init(); - p = p - dpsite(1, 1); - mln_qixter(const I, W) q(input, win, p); - for_all(q) - accu.take(q.val()); - p = p + dpsite(1, 1); + trace::exiting("morpho::impl:erosion_diagonal_2d"); + return output; } - void final() - { - } - }; - template <typename I, typename W> - inline - mln_concrete(I) - erosion_backdiagonal2d_fastest(const Image<I>& input, const Window<W>& win) - { - trace::entering("morpho::impl:erosion_backdiagonal2d_fastest"); - - typedef mlc_is(mln_trait_image_kind(I), - trait::image::kind::binary) is_binary; - typedef mlc_if(is_binary, accu::land, accu::min_h<mln_value(I)>) A; + } // end of namespace mln::morpho::impl - typedef erosion_backdiagonal2d_fastest_functor<I, W, A> F; - F f(exact(input), exact(win)); - canvas::browsing::backdiagonal2d(f); - trace::exiting("morpho::impl:erosion_backdiagonal2d_fastest"); - return f.output; - } - } // end of namespace mln::morpho::impl + // Dispatch. namespace internal @@ -675,67 +362,6 @@ - // dispatch for diagonal2d w.r.t. speed - - template <typename I, typename W> - mln_concrete(I) - erosion_dispatch_for_diagonal2d(trait::image::speed::fastest, - const I& input, const W& win) - { - return impl::erosion_diagonal2d_fastest(input, win); - } - - template <typename I, typename W> - mln_concrete(I) - erosion_dispatch_for_diagonal2d(trait::image::speed::any, - const I& input, const W& win) - { - return impl::erosion_diagonal2d(input, win); - } - - template <typename I, typename W> - mln_concrete(I) - erosion_dispatch_for_diagonal2d(const I& input, const W& win) - { - trace::entering("morpho::erosion_dispatch_for_diagonal2d"); - mln_concrete(I) ima = - erosion_dispatch_for_diagonal2d(mln_trait_image_speed(I)(), - input, win); - trace::exiting("morpho::erosion_dispatch_for_diagonal2d"); - return ima; - } - - - // dispatch for backdiagonal2d w.r.t. speed - - template <typename I, typename W> - mln_concrete(I) - erosion_dispatch_for_backdiagonal2d(trait::image::speed::fastest, - const I& input, const W& win) - { - return impl::erosion_backdiagonal2d_fastest(input, win); - } - - template <typename I, typename W> - mln_concrete(I) - erosion_dispatch_for_backdiagonal2d(trait::image::speed::any, - const I& input, const W& win) - { - return impl::erosion_backdiagonal2d(input, win); - } - - template <typename I, typename W> - mln_concrete(I) - erosion_dispatch_for_backdiagonal2d(const I& input, const W& win) - { - trace::entering("morpho::erosion_dispatch_for_backdiagonal2d"); - mln_concrete(I) ima = - erosion_dispatch_for_backdiagonal2d(mln_trait_image_speed(I)(), - input, win); - trace::exiting("morpho::erosion_dispatch_for_backdiagonal2d"); - return ima; - } - // dispatch w.r.t. win @@ -776,6 +402,8 @@ input, win); } + + template <typename I> mln_concrete(I) erosion_dispatch_wrt_win(const I& input, const win::rectangle2d& win) @@ -786,6 +414,7 @@ return impl::erosion_rectangle2d(input, win); } + template <typename I> mln_concrete(I) erosion_dispatch_wrt_win(const I& input, const win::octagon2d& win) @@ -877,28 +506,30 @@ /// \} - /// Handling win::diag2d. + + + /// Handling diagonals. /// \{ - template <typename I> + template <typename I, typename W> mln_concrete(I) - erosion_dispatch_wrt_win(metal::true_, - const I& input, const win::diag2d& win) + erosion_dispatch_diagonal(metal::true_, + const I& input, const W& win) { - return erosion_dispatch_for_diagonal2d(input, win); + return impl::erosion_diagonal_2d(input, win); } - template <typename I> + template <typename I, typename W> mln_concrete(I) - erosion_dispatch_wrt_win(metal::false_, - const I& input, const win::diag2d& win) + erosion_dispatch_diagonal(metal::false_, + const I& input, const W& win) { return erosion_dispatch_for_generic(input, win); } - template <typename I> + template <typename I, typename W> mln_concrete(I) - erosion_dispatch_wrt_win(const I& input, const win::diag2d& win) + erosion_dispatch_diagonal(const I& input, const W& win) { if (win.size() == 1) return clone(input); @@ -911,51 +542,24 @@ && mlc_is_a(mln_pset(I), Box)::value && mlc_equal(mln_trait_image_quant(I), mln::trait::image::quant::low)::value }; - return erosion_dispatch_wrt_win(metal::bool_<test>(), + return erosion_dispatch_diagonal(metal::bool_<test>(), input, win); } } - /// \} - - - /// Handling win::backdiag2d. - /// \{ template <typename I> mln_concrete(I) - erosion_dispatch_wrt_win(metal::true_, - const I& input, const win::backdiag2d& win) - { - return erosion_dispatch_for_backdiagonal2d(input, win); - } - - template <typename I> - mln_concrete(I) - erosion_dispatch_wrt_win(metal::false_, - const I& input, const win::backdiag2d& win) + erosion_dispatch_wrt_win(const I& input, const win::diag2d& win) { - return erosion_dispatch_for_generic(input, win); + return erosion_dispatch_diagonal(input, win); } template <typename I> mln_concrete(I) erosion_dispatch_wrt_win(const I& input, const win::backdiag2d& win) { - if (win.size() == 1) - return clone(input); - else if (win.size() == 3) - return erosion_dispatch_for_generic(input, win); - else - { - enum { test = mlc_is_not(mln_trait_image_kind(I), - mln::trait::image::kind::logic)::value - && mlc_is_a(mln_pset(I), Box)::value - && mlc_equal(mln_trait_image_quant(I), - mln::trait::image::quant::low)::value }; - return erosion_dispatch_wrt_win(metal::bool_<test>(), - input, win); - } + return erosion_dispatch_diagonal(input, win); } /// \} Index: mln/morpho/includes.hh --- mln/morpho/includes.hh (revision 2881) +++ mln/morpho/includes.hh (working copy) @@ -55,6 +55,7 @@ # include <mln/accu/transform.hh> # include <mln/accu/transform_stop.hh> # include <mln/accu/transform_directional.hh> +# include <mln/accu/transform_diagonal.hh> # include <mln/fun/v2v/saturate.hh>