https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add extension::adjust_fill and elementary erosion.
* mln/debug/println.hh: Add trace.
* mln/border/resize.hh: Re-activate fast code.
* mln/border/adjust.hh: Handle the 0 case.
* mln/geom/delta.hh: New.
* mln/extension/adjust_fill.hh: New.
* mln/extension/all.hh: Update.
* mln/morpho/erosion.hh (todo): Remove; see below.
Use adjust_fill.
* mln/morpho/erosion.spe.hh: Likewise.
* mln/morpho/elementary: New directory.
* mln/morpho/elementary/like_ero_fun.hh: New.
* mln/morpho/elementary/like_ero_set.hh: New.
* mln/morpho/elementary/all.hh: New.
* mln/morpho/elementary/erosion.hh: New.
* tests/morpho/elementary: New directory.
* tests/morpho/elementary/erosion.cc: New.
mln/border/adjust.hh | 8 -
mln/border/resize.hh | 8 -
mln/debug/println.hh | 2
mln/extension/adjust_fill.hh | 134 ++++++++++++++++++++++
mln/extension/all.hh | 1
mln/extension/fill.hh | 1
mln/geom/delta.hh | 125 +++++++++++++++++++++
mln/morpho/elementary/all.hh | 53 ++++++++
mln/morpho/elementary/erosion.hh | 120 ++++++++++++++++++++
mln/morpho/elementary/like_ero_fun.hh | 201 ++++++++++++++++++++++++++++++++++
mln/morpho/elementary/like_ero_set.hh | 197 +++++++++++++++++++++++++++++++++
mln/morpho/erosion.hh | 8 -
mln/morpho/erosion.spe.hh | 38 ++----
tests/morpho/elementary/erosion.cc | 68 +++++++++++
14 files changed, 923 insertions(+), 41 deletions(-)
Index: tests/morpho/elementary/erosion.cc
--- tests/morpho/elementary/erosion.cc (revision 0)
+++ tests/morpho/elementary/erosion.cc (revision 0)
@@ -0,0 +1,68 @@
+// 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/elementary/erosion.cc
+ *
+ * \brief Test on mln::morpho::elementary::erosion.
+ */
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+
+#include <mln/morpho/elementary/erosion.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+// trace::quiet = false;
+
+ image2d<int_u8> ima(3, 3, 0);
+ debug::iota(ima);
+ debug::println(ima);
+ {
+ image2d<int_u8> ero = morpho::elementary::erosion(ima, c4());
+ mln_assertion(ero.border() == 1);
+ debug::println(ero);
+ }
+
+ image2d<bool> msk(3, 3, 0);
+ level::fill(msk, pw::value(ima) >= pw::cst(5));
+ debug::println(msk);
+ {
+ image2d<bool> ero = morpho::elementary::erosion(msk, c4());
+ mln_assertion(ero.border() == 1);
+ debug::println(ero);
+ }
+
+}
Index: mln/debug/println.hh
--- mln/debug/println.hh (revision 2711)
+++ mln/debug/println.hh (working copy)
@@ -81,8 +81,10 @@
void
println(const Image<I>& input)
{
+ trace::entering("debug::println");
impl::println(geom::bbox(exact(input).domain()),
exact(input));
+ trace::exiting("debug::println");
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/border/resize.hh
--- mln/border/resize.hh (revision 2711)
+++ mln/border/resize.hh (working copy)
@@ -92,11 +92,11 @@
mln_concrete(I) memo = clone(ima);
ima.resize_(thickness);
- // level::fill(ima, memo);
+ level::fill(ima, memo);
// level::paste(memo, ima);
- mln_piter(I) p(ima.domain());
- for_all(p)
- ima(p) = memo(p);
+// mln_piter(I) p(ima.domain());
+// for_all(p)
+// ima(p) = memo(p);
}
// ext_domain: /any/
Index: mln/border/adjust.hh
--- mln/border/adjust.hh (revision 2711)
+++ mln/border/adjust.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -66,9 +66,8 @@
{
trace::entering("border::adjust");
- //FIXME: fix this check
- //mlc_is(mln_trait_image_border(I),
- // trait::image::border::some)::check();
+ if (min_thickness != 0)
+ {
const I& ima = exact(ima_);
mln_precondition(ima.has_data());
@@ -76,6 +75,7 @@
border::resize(ima, min_thickness);
mln_postcondition(border::get(ima) >= min_thickness);
+ }
trace::exiting("border::adjust");
}
Index: mln/geom/delta.hh
--- mln/geom/delta.hh (revision 0)
+++ mln/geom/delta.hh (revision 0)
@@ -0,0 +1,125 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// 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_GEOM_DELTA_HH
+# define MLN_GEOM_DELTA_HH
+
+/*! \file mln/geom/delta.hh
+ *
+ * \todo Add doc.
+ */
+
+# include <mln/core/concept/window.hh>
+# include <mln/core/concept/weighted_window.hh>
+# include <mln/core/concept/neighborhood.hh>
+
+
+namespace mln
+{
+
+ namespace geom
+ {
+
+ /// Compute the delta of a window \p win.
+ template <typename W>
+ unsigned delta(const Window<W>& win);
+
+ /// Compute the delta of a weighted window \p wwin.
+ template <typename W>
+ unsigned delta(const Weighted_Window<W>& wwin);
+
+ /// Compute the delta of a neighborhood \p nbh.
+ template <typename N>
+ unsigned delta(const Neighborhood<N>& nbh);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace internal
+ {
+
+ template <typename W>
+ unsigned delta_dispatch(trait::window::support::any,
+ trait::window::definition::any,
+ const W& win)
+ {
+ return 0;
+ }
+
+ template <typename W>
+ unsigned delta_dispatch(trait::window::support::regular,
+ trait::window::definition::varying,
+ const W&)
+ {
+ return 0;
+ }
+
+ template <typename W>
+ unsigned delta_dispatch(trait::window::support::regular,
+ trait::window::definition::any, // So not varying.
+ const W& win)
+ {
+ return win.delta();
+ }
+
+ } // end of namespace mln::geom::internal
+
+
+ // Facades.
+
+ template <typename W>
+ unsigned delta(const Window<W>& win)
+ {
+ // mln_precondition(exact(win).is_valid());
+ return internal::delta_dispatch(mln_trait_window_support(W)(),
+ mln_trait_window_definition(W)(),
+ exact(win));
+ }
+
+ template <typename W>
+ unsigned delta(const Weighted_Window<W>& wwin)
+ {
+ // mln_precondition(exact(wwin).is_valid());
+ return delta(exact(wwin).win());
+ }
+
+ template <typename N>
+ unsigned delta(const Neighborhood<N>& nbh)
+ {
+ // mln_precondition(exact(nbh).is_valid());
+ return delta(exact(nbh).win());
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_DELTA_HH
Index: mln/morpho/erosion.spe.hh
--- mln/morpho/erosion.spe.hh (revision 2711)
+++ mln/morpho/erosion.spe.hh (working copy)
@@ -57,8 +57,6 @@
*
* \todo Warning: we should also have the "arbitrary" versions working
* on sets (not only on functions!)
- *
- * \todo Activate the FIXMEs (border::adjust).
*/
# ifndef MLN_INCLUDE_ONLY
@@ -104,8 +102,7 @@
const I& input = exact(input_);
const W& win = exact(win_);
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, mln_max(mln_value(I)));
O output;
initialize(output, input);
@@ -137,8 +134,7 @@
const I& input = exact(input_);
const W& win = exact(win_);
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, true);
+ extension::adjust_fill(input, win, true);
O output;
initialize(output, input);
@@ -170,8 +166,7 @@
const I& input = exact(input_);
const W& win = exact(win_);
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, true);
+ extension::adjust_fill(input, win, true);
O output;
output = clone(input);
@@ -201,8 +196,7 @@
const I& input = exact(input_);
const W& win = exact(win_);
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, true);
+ extension::adjust_fill(input, win, true);
O output;
output = clone(input);
@@ -404,8 +398,7 @@
void init()
{
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, mln_max(mln_value(I)));
initialize(output, input);
min.init();
p = input.domain().pmin() - dps[0];
@@ -562,8 +555,7 @@
void init()
{
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, mln_max(mln_value(I)));
initialize(output, input);
min.init();
p = input.domain().pmin() - dps[0];
@@ -674,8 +666,7 @@
void init()
{
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, accu);
+ extension::adjust_fill(input, win, accu);
initialize(output, input);
}
@@ -758,8 +749,7 @@
void init()
{
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, accu);
+ extension::adjust_fill(input, win, accu);
initialize(output, input);
}
@@ -845,8 +835,7 @@
void init()
{
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, mln_max(mln_value(I)));
initialize(output, input);
}
@@ -928,8 +917,7 @@
void init()
{
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, mln_max(mln_value(I)));
initialize(output, input);
}
@@ -1011,8 +999,7 @@
void init()
{
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, mln_max(mln_value(I)));
initialize(output, input);
}
@@ -1094,8 +1081,7 @@
void init()
{
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, mln_max(mln_value(I)));
initialize(output, input);
}
Index: mln/morpho/elementary/like_ero_fun.hh
--- mln/morpho/elementary/like_ero_fun.hh (revision 0)
+++ mln/morpho/elementary/like_ero_fun.hh (revision 0)
@@ -0,0 +1,201 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// 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_ELEMENTARY_LIKE_ERO_FUN_HH
+# define MLN_MORPHO_ELEMENTARY_LIKE_ERO_FUN_HH
+
+/// \file mln/morpho/elementary/like_ero_fun.hh
+
+# include <mln/morpho/includes.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace elementary
+ {
+
+ template <typename A, typename F,
+ typename I, typename N>
+ mln_concrete(I)
+ like_ero_fun(const Meta_Accumulator<A>&, const F& f,
+ const Image<I>& input, const Neighborhood<N>& nbh);
+
+
+ struct f_accu
+ {
+ template <typename V, typename A>
+ V operator()(const V& input_p, const A& a) const
+ {
+ return a;
+ }
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+
+ template <typename A, typename F,
+ typename I, typename N>
+ mln_concrete(I)
+ like_ero_fun(const Meta_Accumulator<A>&, const F& f,
+ const Image<I>& input_, const Neighborhood<N>& nbh_)
+ {
+ trace::entering("morpho::elementary::impl::generic::like_ero_fun");
+
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+
+ mln_accu_with(A, mln_value(I)) a;
+ extension::adjust_fill(input, nbh, a);
+
+ mln_concrete(I) output;
+ initialize(output, input);
+
+ mln_piter(I) p(input.domain());
+ mln_niter(N) n(nbh, p);
+ for_all(p)
+ {
+ a.take_as_init(input(p));
+ for_all(n) if (input.has(n))
+ a.take(input(n));
+ output(p) = f(input(p), a);
+ }
+
+ trace::exiting("morpho::elementary::impl::generic::like_ero_fun");
+ return output;
+ }
+
+ } // end of namespace mln::morpho::elementary::impl::generic
+
+
+ template <typename A, typename F,
+ typename I, typename N>
+ mln_concrete(I)
+ like_ero_fun_fastest(const Meta_Accumulator<A>&, const F& f,
+ const Image<I>& input_, const Neighborhood<N>& nbh_)
+ {
+ trace::entering("morpho::elementary::impl::like_ero_fun_fastest");
+
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+
+ mln_accu_with(A, mln_value(I)) a;
+ extension::adjust_fill(input, nbh, a);
+
+ mln_concrete(I) output;
+ initialize(output, input);
+
+ mln_pixter(const I) p_in(input);
+ mln_pixter(I) p_out(output);
+ mln_nixter(const I, N) n(p_in, nbh);
+ for_all_2(p_in, p_out)
+ {
+ a.take_as_init(p_in.val());
+ for_all(n)
+ a.take(n.val());
+ p_out.val() = f(p_in.val(), a);
+ }
+
+ trace::exiting("morpho::elementary::impl::like_ero_fun_fastest");
+ return output;
+ }
+
+ } // end of namespace mln::morpho::elementary::impl
+
+
+ namespace internal
+ {
+
+ template <typename A, typename F,
+ typename I, typename N>
+ mln_concrete(I)
+ like_ero_fun_dispatch(metal::false_,
+ const A& a, const F& f,
+ const I& input, const N& nbh)
+ {
+ return impl::generic::like_ero_fun(a, f, input, nbh);
+ }
+
+ template <typename A, typename F,
+ typename I, typename N>
+ mln_concrete(I)
+ like_ero_fun_dispatch(metal::true_,
+ const A& a, const F& f,
+ const I& input, const N& nbh)
+ {
+ return impl::like_ero_fun_fastest(a, f, input, nbh);
+ }
+
+ template <typename A, typename F,
+ typename I, typename N>
+ mln_concrete(I)
+ like_ero_fun_dispatch(const A& a, const F& f,
+ const I& input, const N& nbh)
+ {
+ typedef mlc_equal(mln_trait_image_speed(I),
+ trait::image::speed::fastest) I_fastest;
+ typedef mln_window(N) W;
+ typedef mln_is_simple_window(W) N_simple;
+
+ return like_ero_fun_dispatch(mlc_and(I_fastest, N_simple)(),
+ a, f, input, nbh);
+ }
+
+ } // end of namespace mln::morpho::elementary::internal
+
+
+ // Facade.
+
+ template <typename A, typename F,
+ typename I, typename N>
+ mln_concrete(I)
+ like_ero_fun(const Meta_Accumulator<A>& a, const F& f,
+ const Image<I>& input, const Neighborhood<N>& nbh)
+ {
+ return internal::like_ero_fun_dispatch(a, f,
+ exact(input), exact(nbh));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho::elementary
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_ELEMENTARY_LIKE_ERO_FUN_HH
Index: mln/morpho/elementary/like_ero_set.hh
--- mln/morpho/elementary/like_ero_set.hh (revision 0)
+++ mln/morpho/elementary/like_ero_set.hh (revision 0)
@@ -0,0 +1,197 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// 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_ELEMENTARY_LIKE_ERO_SET_HH
+# define MLN_MORPHO_ELEMENTARY_LIKE_ERO_SET_HH
+
+/// \file mln/morpho/elementary/like_ero_set.hh
+
+# include <mln/morpho/includes.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace elementary
+ {
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ like_ero_set(bool val[5],
+ const Image<I>& input, const Neighborhood<N>& nbh);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ like_ero_set(bool val[5],
+ const Image<I>& input_, const Neighborhood<N>& nbh_)
+ {
+ trace::entering("morpho::elementary::impl::generic::like_ero_set");
+
+ bool
+ ext_value = val[0],
+ do_clone = val[1],
+ on_input_p = val[2],
+ on_input_n = val[3],
+ output_p = val[4];
+
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+
+ extension::adjust_fill(input, nbh, ext_value);
+
+ mln_concrete(I) output;
+ if (do_clone)
+ output = clone(input);
+ else
+ level::fill(output, false);
+
+ mln_piter(I) p(input.domain());
+ mln_niter(N) n(nbh, p);
+ for_all(p)
+ if (input(p) == on_input_p)
+ for_all(n)
+ if (input.has(n) && input(n) == on_input_n)
+ output(p) = output_p;
+
+ trace::exiting("morpho::elementary::impl::generic::like_ero_set");
+ return output;
+ }
+
+ } // end of namespace mln::morpho::elementary::impl::generic
+
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ like_ero_set_fastest(bool val[5],
+ const Image<I>& input_, const Neighborhood<N>& nbh_)
+ {
+ trace::entering("morpho::elementary::impl::like_ero_set_fastest");
+
+ bool
+ ext_value = val[0],
+ do_clone = val[1],
+ on_input_p = val[2],
+ on_input_n = val[3],
+ output_p = val[4];
+
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+
+ extension::adjust_fill(input, nbh, ext_value);
+
+ mln_concrete(I) output;
+ if (do_clone)
+ output = clone(input);
+ else
+ level::fill(output, false);
+
+ mln_pixter(const I) p_in(input);
+ mln_pixter(I) p_out(output);
+ mln_nixter(const I, N) n(p_in, nbh);
+ for_all_2(p_in, p_out)
+ if (p_in.val() == on_input_p)
+ for_all(n)
+ if (n.val() == on_input_n)
+ p_out.val() = output_p;
+
+ trace::exiting("morpho::elementary::impl::like_ero_set_fastest");
+ return output;
+ }
+
+ } // end of namespace mln::morpho::elementary::impl
+
+
+ namespace internal
+ {
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ like_ero_set_dispatch(metal::false_,
+ bool val[5],
+ const I& input, const N& nbh)
+ {
+ return impl::generic::like_ero_set(val, input, nbh);
+ }
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ like_ero_set_dispatch(metal::true_,
+ bool val[5],
+ const I& input, const N& nbh)
+ {
+ return impl::like_ero_set_fastest(val, input, nbh);
+ }
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ like_ero_set_dispatch(bool val[5],
+ const I& input, const N& nbh)
+ {
+ typedef mlc_equal(mln_trait_image_speed(I),
+ trait::image::speed::fastest) I_fastest;
+ typedef mln_window(N) W;
+ typedef mln_is_simple_window(W) N_simple;
+
+ return like_ero_set_dispatch(mlc_and(I_fastest, N_simple)(),
+ val, input, nbh);
+ }
+
+ } // end of namespace mln::morpho::elementary::internal
+
+
+ // Facade.
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ like_ero_set(bool val[5],
+ const Image<I>& input, const Neighborhood<N>& nbh)
+ {
+ return internal::like_ero_set_dispatch(val, exact(input), exact(nbh));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho::elementary
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_ELEMENTARY_LIKE_ERO_SET_HH
Index: mln/morpho/elementary/all.hh
--- mln/morpho/elementary/all.hh (revision 0)
+++ mln/morpho/elementary/all.hh (revision 0)
@@ -0,0 +1,53 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// 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_ELEMENTARY_ALL_HH
+# define MLN_MORPHO_ELEMENTARY_ALL_HH
+
+/// \file mln/morpho/elementary/all.hh
+///
+/// File that includes all elementary mathematical morphology
+/// routines.
+
+
+namespace mln
+{
+ namespace morpho
+ {
+
+ /// Namespace of image processing routines of elementary
+ /// mathematical morphology.
+ namespace elementary {}
+
+ }
+}
+
+# include <mln/morpho/elementary/erosion.hh>
+
+
+
+#endif // ! MLN_MORPHO_ELEMENTARY_ALL_HH
Index: mln/morpho/elementary/erosion.hh
--- mln/morpho/elementary/erosion.hh (revision 0)
+++ mln/morpho/elementary/erosion.hh (revision 0)
@@ -0,0 +1,120 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// 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_ELEMENTARY_EROSION_HH
+# define MLN_MORPHO_ELEMENTARY_EROSION_HH
+
+/// \file mln/morpho/elementary/erosion.hh
+
+# include <mln/morpho/elementary/like_ero_fun.hh>
+# include <mln/morpho/elementary/like_ero_set.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace elementary
+ {
+
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ erosion(const Image<I>& input, const Neighborhood<N>& nbh);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace internal
+ {
+
+ // Dispatch.
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ erosion_dispatch(trait::image::kind::any,
+ const Image<I>& input, const Neighborhood<N>& nbh)
+ {
+ return like_ero_fun(accu::meta::min(), f_accu(), input, nbh);
+ }
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ erosion_dispatch(trait::image::kind::logic,
+ const Image<I>& input, const Neighborhood<N>& nbh)
+ {
+ bool val[] =
+ {
+ 1, // ext_value
+ 1, // do_clone
+ 1, // on_input_p
+ 0, // on_input_n
+ 0, // output_p
+ };
+ return like_ero_set(val, input, nbh);
+ }
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ erosion_dispatch(const Image<I>& input, const Neighborhood<N>& nbh)
+ {
+ return erosion_dispatch(mln_trait_image_kind(I)(),
+ input, nbh);
+ }
+
+ } // end of namespace mln::morpho::elementary::internal
+
+
+ // Facade.
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ erosion(const Image<I>& input, const Neighborhood<N>& nbh)
+ {
+ trace::entering("morpho::elementary::erosion");
+
+ mln_precondition(exact(input).has_data());
+ // mln_precondition(exact(nbh).is_valid());
+
+ mln_concrete(I) output = internal::erosion_dispatch(input, nbh);
+
+ trace::exiting("morpho::elementary::erosion");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho::elementary
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_ELEMENTARY_EROSION_HH
Index: mln/morpho/erosion.hh
--- mln/morpho/erosion.hh (revision 2711)
+++ mln/morpho/erosion.hh (working copy)
@@ -30,8 +30,6 @@
/// \file mln/morpho/erosion.hh
/// \brief Morphological erosion.
-///
-/// \todo Activate the FIXMEs (border::adjust).
# include <mln/morpho/includes.hh>
@@ -72,8 +70,7 @@
const I& input = exact(input_);
const W& win = exact(win_);
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, mln_max(mln_value(I)));
+ extension::adjust_fill(input, win, mln_max(mln_value(I)));
mln_concrete(I) output;
initialize(output, input);
@@ -106,8 +103,7 @@
const I& input = exact(input_);
const W& win = exact(win_);
- // FIXME: border::adjust(input, win.delta());
- extension::fill(input, true);
+ extension::adjust_fill(input, win, true);
mln_concrete(I) output;
initialize(output, input);
Index: mln/extension/fill.hh
--- mln/extension/fill.hh (revision 2711)
+++ mln/extension/fill.hh (working copy)
@@ -63,7 +63,6 @@
void fill(const Image<I>& ima, const mln_value(I)& val);
-
# ifndef MLN_INCLUDE_ONLY
Index: mln/extension/all.hh
--- mln/extension/all.hh (revision 2711)
+++ mln/extension/all.hh (working copy)
@@ -46,6 +46,7 @@
# include <mln/extension/fill.hh>
+# include <mln/extension/adjust_fill.hh>
#endif // ! MLN_EXTENSION_ALL_HH
Index: mln/extension/adjust_fill.hh
--- mln/extension/adjust_fill.hh (revision 0)
+++ mln/extension/adjust_fill.hh (revision 0)
@@ -0,0 +1,134 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// 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_CORE_EXTENSION_ADJUST_FILL_HH
+# define MLN_CORE_EXTENSION_ADJUST_FILL_HH
+
+/*! \file mln/extension/adjust_fill.hh
+ *
+ * \brief Adjust then fill the domain extension.
+ *
+ * \todo Fix doc.
+ */
+
+# include <mln/border/adjust.hh>
+# include <mln/extension/fill.hh>
+# include <mln/geom/delta.hh>
+
+
+namespace mln
+{
+
+ namespace extension
+ {
+
+ /*! Fill the domain extension of image \p ima with the
+ * single value \p v.
+ *
+ * \param[in,out] ima The image whose domain extension is to be filled.
+ * \param[in] val The value to assign.
+ *
+ * \pre \p ima has to be initialized.
+ *
+ * \todo Optimize with memset if possible.
+ */
+ template <typename I, typename W>
+ void adjust_fill(const Image<I>& ima,
+ const Window<W>& win,
+ const mln_value(I)& val);
+
+ template <typename I, typename W>
+ void adjust_fill(const Image<I>& ima,
+ const Weighted_Window<W>& wwin,
+ const mln_value(I)& val);
+
+ template <typename I, typename N>
+ void adjust_fill(const Image<I>& ima,
+ const Neighborhood<N>& nbh,
+ const mln_value(I)& val);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ template <typename I, typename W, typename V>
+ void do_adjust_fill(const I& ima,
+ const W& win_like,
+ const V& val)
+ {
+ mln_precondition(exact(ima).has_data());
+ // mln_precondition(exact(win_like).is_valid());
+
+ border::adjust(ima, geom::delta(win_like));
+ extension::fill(ima, val);
+ }
+
+ } // end of namespace mln::extension::impl
+
+
+ // Facades.
+
+ template <typename I, typename W>
+ void adjust_fill(const Image<I>& ima,
+ const Window<W>& win,
+ const mln_value(I)& val)
+ {
+ trace::entering("extension::adjust_fill");
+ impl::do_adjust_fill(ima, win, val);
+ trace::exiting("extension::adjust_fill");
+ }
+
+ template <typename I, typename W>
+ void adjust_fill(const Image<I>& ima,
+ const Weighted_Window<W>& wwin,
+ const mln_value(I)& val)
+ {
+ trace::entering("extension::adjust_fill");
+ impl::do_adjust_fill(ima, wwin, val);
+ trace::exiting("extension::adjust_fill");
+ }
+
+ template <typename I, typename N>
+ void adjust_fill(const Image<I>& ima,
+ const Neighborhood<N>& nbh,
+ const mln_value(I)& val)
+ {
+ trace::entering("extension::adjust_fill");
+ impl::do_adjust_fill(ima, nbh, val);
+ trace::exiting("extension::adjust_fill");
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::extension
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_EXTENSION_FILL_HH