https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add morphological top hats.
* tests/morpho/elementary/top_hat.cc: New.
* mln/morpho/elementary/top_hat.hh: New.
* mln/morpho/elementary/all.hh: Update.
mln/morpho/elementary/all.hh | 9 ++-
mln/morpho/elementary/top_hat.hh | 89 +++++++++++++++++++++----------------
tests/morpho/elementary/top_hat.cc | 65 +++++++++++++++++++++++++++
3 files changed, 123 insertions(+), 40 deletions(-)
Index: tests/morpho/elementary/top_hat.cc
--- tests/morpho/elementary/top_hat.cc (revision 0)
+++ tests/morpho/elementary/top_hat.cc (revision 0)
@@ -0,0 +1,65 @@
+// 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/top_hat.cc
+ *
+ * \brief Test on mln::morpho::elementary::top_hat's.
+ */
+
+#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/top_hat.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);
+
+ debug::println( morpho::elementary::top_hat_white(ima, c4()) );
+ debug::println( morpho::elementary::top_hat_black(ima, c4()) );
+ debug::println( morpho::elementary::top_hat_self_complementary(ima, c4()) );
+
+ image2d<bool> msk(3, 3, 0);
+ level::fill(msk, pw::value(ima) >= pw::cst(5));
+ debug::println(msk);
+
+ debug::println( morpho::elementary::top_hat_white(msk, c4()) );
+ debug::println( morpho::elementary::top_hat_black(msk, c4()) );
+ debug::println( morpho::elementary::top_hat_self_complementary(msk, c4()) );
+}
Index: mln/morpho/elementary/all.hh
--- mln/morpho/elementary/all.hh (revision 2716)
+++ mln/morpho/elementary/all.hh (working copy)
@@ -46,10 +46,15 @@
}
}
-# include <mln/morpho/elementary/erosion.hh>
+# include <mln/morpho/elementary/closing.hh>
# include <mln/morpho/elementary/dilation.hh>
-# include <mln/morpho/elementary/gradient_internal.hh>
+# include <mln/morpho/elementary/erosion.hh>
+# include <mln/morpho/elementary/gradient.hh>
# include <mln/morpho/elementary/gradient_external.hh>
+# include <mln/morpho/elementary/gradient_internal.hh>
+# include <mln/morpho/elementary/laplacian.hh>
+# include <mln/morpho/elementary/opening.hh>
+# include <mln/morpho/elementary/top_hat.hh>
Index: mln/morpho/elementary/top_hat.hh
--- mln/morpho/elementary/top_hat.hh (revision 2716)
+++ mln/morpho/elementary/top_hat.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
@@ -25,18 +25,19 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_MORPHO_TOP_HAT_HH
-# define MLN_MORPHO_TOP_HAT_HH
+#ifndef MLN_MORPHO_ELEMENTARY_TOP_HAT_HH
+# define MLN_MORPHO_ELEMENTARY_TOP_HAT_HH
-/*! \file mln/morpho/top_hat.hh
+/*! \file mln/morpho/elementary/top_hat.hh
*
- * \brief Morphological top-hats.
+ * \brief Morphological elementary top-hats.
*
* \todo Save memory.
*/
-# include <mln/morpho/opening.hh>
-# include <mln/morpho/closing.hh>
+# include <mln/morpho/elementary/opening.hh>
+# include <mln/morpho/elementary/closing.hh>
+# include <mln/morpho/minus.hh>
namespace mln
@@ -45,88 +46,100 @@
namespace morpho
{
- /*! Morphological white top-hat (for object / light objects).
+ namespace elementary
+ {
+
+ /*! Morphological elementary white top-hat (for object / light objects).
*
- * This operator is Id - ope_B.
+ * This operator is Id - ope.
*/
- template <typename I, typename W>
+ template <typename I, typename N>
mln_concrete(I)
- top_hat_white(const Image<I>& input, const Window<W>& win);
+ top_hat_white(const Image<I>& input, const Neighborhood<N>& nbh);
- /*! Morphological black top-hat (for background / dark objects).
+ /*! Morphological elementary black top-hat (for background / dark objects).
*
- * This operator is clo_B - Id.
+ * This operator is clo - Id.
*/
- template <typename I, typename W>
+ template <typename I, typename N>
mln_concrete(I)
- top_hat_black(const Image<I>& input, const Window<W>& win);
+ top_hat_black(const Image<I>& input, const Neighborhood<N>& nbh);
- /*! Morphological self-complementary top-hat.
+ /*! Morphological elementary self-complementary top-hat.
*
* This operator is \n
* = top_hat_white + top_hat_black \n
- * = (input - opening) + (closing - input) \n
+ * = (Id - opening) + (closing - Id) \n
* = closing - opening. \n
*/
- template <typename I, typename W>
+ template <typename I, typename N>
mln_concrete(I)
- top_hat_self_complementary(const Image<I>& input, const Window<W>& win);
+ top_hat_self_complementary(const Image<I>& input, const Neighborhood<N>& nbh);
# ifndef MLN_INCLUDE_ONLY
- template <typename I, typename W>
+ template <typename I, typename N>
inline
- mln_concrete(I) top_hat_white(const Image<I>& input, const Window<W>& win)
+ mln_concrete(I)
+ top_hat_white(const Image<I>& input,
+ const Neighborhood<N>& nbh)
{
- trace::entering("morpho::top_hat_white");
+ trace::entering("morpho::elementary::top_hat_white");
mln_precondition(exact(input).has_data());
- mln_precondition(! exact(win).is_empty());
+ // mln_precondition(exact(nbh).is_valid());
mln_concrete(I) output = morpho::minus(input,
- opening(input, win));
+ opening(input, nbh));
mln_postcondition(test::positive(output));
- trace::exiting("morpho::top_hat_white");
+ trace::exiting("morpho::elementary::top_hat_white");
return output;
}
- template <typename I, typename W>
+ template <typename I, typename N>
inline
- mln_concrete(I) top_hat_black(const Image<I>& input, const Window<W>& win)
+ mln_concrete(I)
+ top_hat_black(const Image<I>& input,
+ const Neighborhood<N>& nbh)
{
- trace::entering("morpho::top_hat_black");
+ trace::entering("morpho::elementary::top_hat_black");
mln_precondition(exact(input).has_data());
- mln_precondition(! exact(win).is_empty());
+ // mln_precondition(exact(nbh).is_valid());
- mln_concrete(I) output = morpho::minus(closing(input, win),
+ mln_concrete(I) output = morpho::minus(closing(input, nbh),
input);
mln_postcondition(test::positive(output));
- trace::exiting("morpho::top_hat_black");
+ trace::exiting("morpho::elementary::top_hat_black");
return output;
}
- template <typename I, typename W>
+ template <typename I, typename N>
inline
- mln_concrete(I) top_hat_self_complementary(const Image<I>& input, const Window<W>& win)
+ mln_concrete(I)
+ top_hat_self_complementary(const Image<I>& input,
+ const Neighborhood<N>& nbh)
{
- trace::entering("morpho::top_hat_self_complementary");
+ trace::entering("morpho::elementary::top_hat_self_complementary");
mln_precondition(exact(input).has_data());
- mln_precondition(! exact(win).is_empty());
+ // mln_precondition(exact(nbh).is_valid());
- mln_concrete(I) output = morpho::minus(closing(input, win),
- opening(input, win));
+ mln_concrete(I) output = morpho::minus(closing(input, nbh),
+ opening(input, nbh));
mln_postcondition(test::positive(output));
- trace::exiting("morpho::top_hat_self_complementary");
+ // mln_postcondition(output == white + black);
+ trace::exiting("morpho::elementary::top_hat_self_complementary");
return output;
}
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::morpho::elementary
+
} // end of namespace mln::morpho
} // end of namespace mln
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add the morphological elementary laplacian.
* tests/morpho/elementary/laplacian.cc: New.
* doc/tutorial/examples/sub_image.cc: Update.
* mln/morpho/elementary/laplacian.hh: New.
doc/tutorial/examples/sub_image.cc | 4 -
mln/morpho/elementary/laplacian.hh | 87 +++++++++++++++++++++++++++++++++++
tests/morpho/elementary/laplacian.cc | 59 +++++++++++++++++++++++
3 files changed, 148 insertions(+), 2 deletions(-)
Index: tests/morpho/elementary/laplacian.cc
--- tests/morpho/elementary/laplacian.cc (revision 0)
+++ tests/morpho/elementary/laplacian.cc (revision 0)
@@ -0,0 +1,59 @@
+// 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/laplacian.cc
+ *
+ * \brief Test on mln::morpho::elementary::laplacian.
+ */
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/core/var.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+
+#include <mln/morpho/elementary/laplacian.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);
+
+ mln_VAR(lap, morpho::elementary::laplacian(ima, c4()));
+ mln_assertion(lap.border() == 1);
+ debug::println(lap);
+
+}
Index: doc/tutorial/examples/sub_image.cc
--- doc/tutorial/examples/sub_image.cc (revision 2715)
+++ doc/tutorial/examples/sub_image.cc (working copy)
@@ -5,7 +5,7 @@
# include <mln/debug/iota.hh>
# include <mln/debug/println.hh>
-# include <mln/morpho/gradient_elementary.hh>
+# include <mln/morpho/elementary/gradient.hh>
# include <mln/level/fill_with_value.hh>
@@ -20,7 +20,7 @@
sub_image<I, box2d> sub = ima | box2d(2,3);
debug::println(sub);
- debug::println(morpho::gradient_elementary(sub, c4()));
+ debug::println(morpho::elementary::gradient(sub, c4()));
level::fill_with_value((ima | box2d(2,3)).rw(), 0);
debug::println(ima);
Index: mln/morpho/elementary/laplacian.hh
--- mln/morpho/elementary/laplacian.hh (revision 0)
+++ mln/morpho/elementary/laplacian.hh (revision 0)
@@ -0,0 +1,87 @@
+// 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
+// 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_LAPLACIAN_HH
+# define MLN_MORPHO_ELEMENTARY_LAPLACIAN_HH
+
+/*! \file mln/morpho/elementary/laplacian.hh
+ *
+ * \brief Morphological elementary laplacian.
+ *
+ * \todo Handle the set case?
+ */
+
+# include <mln/morpho/elementary/gradient_internal.hh>
+# include <mln/morpho/elementary/gradient_external.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace elementary
+ {
+
+ /// Morphological elementary laplacian.
+ ///
+ /// This operator is (d - id) - (id - e).
+ template <typename I, typename N>
+ mln_trait_op_minus_twice(mln_concrete(I))
+ laplacian(const Image<I>& input, const Neighborhood<N>& nbh);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename N>
+ inline
+ mln_trait_op_minus_twice(mln_concrete(I))
+ laplacian(const Image<I>& input, const Neighborhood<N>& nbh)
+ {
+ trace::entering("morpho::elementary::laplacian");
+
+ mln_precondition(exact(input).has_data());
+ // mln_precondition(exact(nbh).is_valid());
+
+ mln_trait_op_minus_twice(mln_concrete(I)) output;
+ output = gradient_external(input, nbh) - gradient_internal(input, nbh);
+
+ trace::exiting("morpho::elementary::laplacian");
+ 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_LAPLACIAN_HH
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
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
ChangeLog:
2008-10-28 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Add some bench tests on ocr preprocessing.
* garrigues/ocr/Makefile: New, compile an ocr with preprocess
and an other one without.
* garrigues/ocr/check.sh: New, script to bench ocr preprocessing.
* garrigues/ocr/ocr.cc: Rename as...
* garrigues/ocr/ocr_with_preprocess.cc: ...this.
* garrigues/ocr/ocr_without_preprocess.cc: New. version without
preprocess.
---
Makefile | 21 +++++++
check.sh | 29 ++++++++++
ocr_with_preprocess.cc | 130 ++++++++++++++++++++++++++++++++++++++++++++++
ocr_without_preprocess.cc | 98 ++++++++++++++++++++++++++++++++++
4 files changed, 278 insertions(+)
Index: branches/cleanup-2008/milena/sandbox/garrigues/ocr/ocr.cc (deleted)
===================================================================
Index: branches/cleanup-2008/milena/sandbox/garrigues/ocr/ocr_without_preprocess.cc
===================================================================
--- branches/cleanup-2008/milena/sandbox/garrigues/ocr/ocr_without_preprocess.cc (revision 0)
+++ branches/cleanup-2008/milena/sandbox/garrigues/ocr/ocr_without_preprocess.cc (revision 2710)
@@ -0,0 +1,98 @@
+// 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.
+
+#include <iostream>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/window2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+
+#include <mln/core/image/cast_image.hh>
+
+#include <mln/value/int_u8.hh>
+
+#include "resize.hh"
+#include "enlarge.hh"
+//#include "skeleton.hh"
+#include <mln/linear/gaussian.hh>
+
+#include <mln/trace/all.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pbm/save.hh>
+#include <mln/core/alias/w_window2d_float.hh>
+
+#include <mln/debug/println.hh>
+#include <mln/geom/chamfer.hh>
+#include <mln/make/win_chamfer.hh>
+#include <mln/labeling/regional_maxima.hh>
+#include <mln/morpho/dilation.hh>
+
+#include <tesseract/baseapi.h>
+
+// _COMPILATION_
+// g++ -DNDEBUG -O3 -I../../.. ocr.cc -L/usr/lib -ltesseract_full -lpthread
+
+
+// Call tesseract
+// lang: expected language
+template <typename T>
+char* tesseract(const char* lang, const mln::image2d<T>& input)
+{
+ TessBaseAPI::InitWithLanguage(NULL, NULL, lang, NULL, false, 0, NULL);
+ char* s = TessBaseAPI::TesseractRect(
+ (unsigned char*) input.buffer(),
+ sizeof (T),
+ input.ncols() * sizeof (T),
+ 0, 0,
+ input.ncols(),
+ input.nrows());
+ return s;
+}
+
+int main(int argc, char** argv)
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<bool> input;
+
+ if (argc < 2)
+ {
+ std::cerr << "Usage: " << argv[0] << " in.pbm" << std::endl;
+ return 1;
+ }
+
+ mln::border::thickness = 0;
+
+ io::pbm::load(input, argv[1]);
+
+ char* s = tesseract("fra", input);
+ std::cout << s;
+ free(s);
+}
Index: branches/cleanup-2008/milena/sandbox/garrigues/ocr/check.sh
===================================================================
--- branches/cleanup-2008/milena/sandbox/garrigues/ocr/check.sh (revision 0)
+++ branches/cleanup-2008/milena/sandbox/garrigues/ocr/check.sh (revision 2710)
@@ -0,0 +1,29 @@
+for i in input/*.pbm ; do
+ echo "==========================================="
+ echo "--------- $i"
+ echo "==========================================="
+
+ ref="$i.txt"
+ cat $ref
+ sed -e 's/\(.\)/\1\n/g' $ref > tmp/ref
+ total=`cat tmp/ref | wc -l `
+
+ ./ocr_without_preprocess $i tmp/`basename $i` > tmp/without
+ echo "_______________without preprocessing"
+ cat tmp/without
+ cat tmp/without | sed -e 's/\(.\)/\1\n/g' > tmp/without
+
+ ./ocr_with_preprocess $i tmp/`basename $i` > tmp/with
+ echo "_______________with preprocessing"
+ cat tmp/with
+ cat tmp/with | sed -e 's/\(.\)/\1\n/g' > tmp/with
+
+
+ d_without=`diff ./tmp/without tmp/ref | diffstat | grep insert | sed -r 's/.*, ([0-9]+) insertion.*/\1/g'`
+ echo "$(($d_without * 100 / $total))% missmatch without preprocessing"
+
+ ./ocr_with_preprocess $i tmp/`basename $i` | sed -e 's/\(.\)/\1\n/g' > tmp/with
+ d_with=`diff ./tmp/with tmp/ref | diffstat | grep insert | sed -r 's/.*, ([0-9]+) insertion.*/\1/g'`
+ echo "$(($d_with * 100 / $total))% missmatch with preprocessing"
+ echo ""
+done
Property changes on: branches/cleanup-2008/milena/sandbox/garrigues/ocr/check.sh
___________________________________________________________________
Name: svn:executable
+ *
Index: branches/cleanup-2008/milena/sandbox/garrigues/ocr/ocr_with_preprocess.cc
===================================================================
--- branches/cleanup-2008/milena/sandbox/garrigues/ocr/ocr_with_preprocess.cc (revision 0)
+++ branches/cleanup-2008/milena/sandbox/garrigues/ocr/ocr_with_preprocess.cc (revision 2710)
@@ -0,0 +1,130 @@
+// 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.
+
+#include <iostream>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/window2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+
+#include <mln/core/image/cast_image.hh>
+
+#include <mln/value/int_u8.hh>
+
+#include "resize.hh"
+#include "enlarge.hh"
+//#include "skeleton.hh"
+#include <mln/linear/gaussian.hh>
+
+#include <mln/trace/all.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pbm/save.hh>
+#include <mln/core/alias/w_window2d_float.hh>
+
+#include <mln/debug/println.hh>
+#include <mln/geom/chamfer.hh>
+#include <mln/make/win_chamfer.hh>
+#include <mln/labeling/regional_maxima.hh>
+#include <mln/morpho/dilation.hh>
+
+#include <tesseract/baseapi.h>
+
+// _COMPILATION_
+// g++ -DNDEBUG -O3 -I../../.. ocr.cc -L/usr/lib -ltesseract_full -lpthread
+
+
+// Call tesseract
+// lang: expected language
+template <typename T>
+char* tesseract(const char* lang, const mln::image2d<T>& input)
+{
+ TessBaseAPI::InitWithLanguage(NULL, NULL, lang, NULL, false, 0, NULL);
+ char* s = TessBaseAPI::TesseractRect(
+ (unsigned char*) input.buffer(),
+ sizeof (T),
+ input.ncols() * sizeof (T),
+ 0, 0,
+ input.ncols(),
+ input.nrows());
+ return s;
+}
+
+int main(int argc, char** argv)
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<bool> input;
+
+ if (argc < 2)
+ {
+ std::cerr << "Usage: " << argv[0] << " in.pbm out.pbm" << std::endl;
+ return 1;
+ }
+
+ mln::border::thickness = 0;
+
+ io::pbm::load(input, argv[1]);
+
+ // Resize
+ image2d<int_u8> output = enlarge(input, 1);
+
+ // TODO CLEANUP
+#if 0
+ // Blur.
+ output = linear::gaussian(output, 1);
+#endif
+
+#if 0
+ // Threshold
+ mln_piter_(image2d<unsigned>) p(output.domain());
+ for_all(p)
+ {
+ output(p) = output(p) > 127 ? 1 : 0;
+ }
+#endif
+
+#if 0
+ // Compute chamfer distance map.
+ const w_window2d_int& w_win = make::mk_chamfer_3x3_int<8, 0> ();
+ image2d<unsigned> out = geom::chamfer(output, w_win, 255);
+
+ for_all(p)
+ {
+ out(p) = out(p) > 10 ? 255 : 0;
+ }
+#endif
+
+ io::pgm::save(cast_image<int_u8>(output), argv[2]);
+
+ std::cout << "> with preprocessing." << std::endl;
+ char* s = tesseract("fra", output);
+ std::cout << s;
+ free(s);
+}
Index: branches/cleanup-2008/milena/sandbox/garrigues/ocr/Makefile
===================================================================
--- branches/cleanup-2008/milena/sandbox/garrigues/ocr/Makefile (revision 0)
+++ branches/cleanup-2008/milena/sandbox/garrigues/ocr/Makefile (revision 2710)
@@ -0,0 +1,21 @@
+CXXFLAGS=-I../../.. -I${HOME}/local/include
+LFLAGS=-L${HOME}/local/lib -ltesseract_full -lpthread
+
+all: ocr_without_preprocess ocr_with_preprocess
+
+ocr_without_preprocess: ocr_without_preprocess.cc
+ g++ -DNDEBUG -O3 ${CXXFLAGS} $< ${LFLAGS} -o $@
+
+ocr_with_preprocess: ocr_with_preprocess.cc
+ g++ -DNDEBUG -O3 ${CXXFLAGS} $< ${LFLAGS} -o $@
+clean:
+ rm -f *.o ocr_without_preprocess ocr_with_preprocess
+
+logs:
+ mkdir logs
+
+tmp:
+ mkdir tmp
+
+check: logs tmp ocr_without_preprocess ocr_with_preprocess
+ ./check.sh