Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 9625 discussions
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
1
0
28 Oct '08
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
1
0
28 Oct '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add new morphological elementary operators.
* tests/morpho/elementary/gradient.cc: New.
* tests/morpho/elementary/closing.cc: New.
* tests/morpho/elementary/gradient_external.cc: New.
* tests/morpho/elementary/opening.cc: New.
* tests/morpho/gradient_elementary.cc: Remove; obsolete.
* tests/morpho/Makefile.am: Update.
* mln/accu/min_max.hh (meta::min_max): Disambiguate.
* mln/morpho/elementary/like_ero_fun.hh (f_accu): Make it
consistent with others.
* mln/morpho/elementary/dilation.hh (postcondition): New.
* mln/morpho/dilation_elementary.hh: Remove; obsolete.
* mln/morpho/elementary/gradient_internal.hh (val): Fix.
(postcondition): New.
* mln/morpho/elementary/gradient.hh: New.
* mln/morpho/gradient_elementary.hh: Remove; obsolete.
* mln/morpho/elementary/erosion.hh (postcondition): New.
* mln/morpho/elementary/closing.hh: New.
* mln/morpho/elementary/gradient_external.hh: New.
* mln/morpho/elementary/opening.hh: New.
mln/accu/min_max.hh | 2
mln/morpho/elementary/closing.hh | 44 ++++----
mln/morpho/elementary/dilation.hh | 1
mln/morpho/elementary/erosion.hh | 1
mln/morpho/elementary/gradient.hh | 141 ++++++++++++++++++++-------
mln/morpho/elementary/gradient_external.hh | 36 +++---
mln/morpho/elementary/gradient_internal.hh | 3
mln/morpho/elementary/like_ero_fun.hh | 2
mln/morpho/elementary/opening.hh | 46 ++++----
tests/morpho/Makefile.am | 2
tests/morpho/elementary/closing.cc | 18 +--
tests/morpho/elementary/gradient.cc | 10 -
tests/morpho/elementary/gradient_external.cc | 10 -
tests/morpho/elementary/opening.cc | 18 +--
14 files changed, 209 insertions(+), 125 deletions(-)
Index: tests/morpho/elementary/gradient.cc
--- tests/morpho/elementary/gradient.cc (revision 2713)
+++ tests/morpho/elementary/gradient.cc (working copy)
@@ -25,9 +25,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/morpho/elementary/gradient_internal.cc
+/*! \file tests/morpho/elementary/gradient.cc
*
- * \brief Test on mln::morpho::elementary::gradient_internal.
+ * \brief Test on mln::morpho::elementary::gradient.
*/
#include <mln/core/image/image2d.hh>
@@ -39,7 +39,7 @@
#include <mln/debug/iota.hh>
#include <mln/debug/println.hh>
-#include <mln/morpho/elementary/gradient_internal.hh>
+#include <mln/morpho/elementary/gradient.hh>
int main()
@@ -57,7 +57,7 @@
{
mln_VAR(gra,
- morpho::elementary::gradient_internal(ima | b, c4()));
+ morpho::elementary::gradient(ima | b, c4()));
debug::println(gra);
}
@@ -66,7 +66,7 @@
debug::println(msk);
{
mln_VAR(gra,
- morpho::elementary::gradient_internal(msk | b, c4()));
+ morpho::elementary::gradient(msk | b, c4()));
debug::println(gra);
}
Index: tests/morpho/elementary/closing.cc
--- tests/morpho/elementary/closing.cc (revision 2713)
+++ tests/morpho/elementary/closing.cc (working copy)
@@ -25,9 +25,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/morpho/elementary/erosion.cc
+/*! \file tests/morpho/elementary/closing.cc
*
- * \brief Test on mln::morpho::elementary::erosion.
+ * \brief Test on mln::morpho::elementary::closing.
*/
#include <mln/core/image/image2d.hh>
@@ -37,7 +37,7 @@
#include <mln/debug/iota.hh>
#include <mln/debug/println.hh>
-#include <mln/morpho/elementary/erosion.hh>
+#include <mln/morpho/elementary/closing.hh>
int main()
@@ -51,18 +51,18 @@
debug::iota(ima);
debug::println(ima);
{
- image2d<int_u8> ero = morpho::elementary::erosion(ima, c4());
- mln_assertion(ero.border() == 1);
- debug::println(ero);
+ image2d<int_u8> clo = morpho::elementary::closing(ima, c4());
+ mln_assertion(clo.border() == 1);
+ debug::println(clo);
}
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);
+ image2d<bool> clo = morpho::elementary::closing(msk, c4());
+ mln_assertion(clo.border() == 1);
+ debug::println(clo);
}
}
Index: tests/morpho/elementary/gradient_external.cc
--- tests/morpho/elementary/gradient_external.cc (revision 2713)
+++ tests/morpho/elementary/gradient_external.cc (working copy)
@@ -25,9 +25,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/morpho/elementary/gradient_internal.cc
+/*! \file tests/morpho/elementary/gradient_external.cc
*
- * \brief Test on mln::morpho::elementary::gradient_internal.
+ * \brief Test on mln::morpho::elementary::gradient_external.
*/
#include <mln/core/image/image2d.hh>
@@ -39,7 +39,7 @@
#include <mln/debug/iota.hh>
#include <mln/debug/println.hh>
-#include <mln/morpho/elementary/gradient_internal.hh>
+#include <mln/morpho/elementary/gradient_external.hh>
int main()
@@ -57,7 +57,7 @@
{
mln_VAR(gra,
- morpho::elementary::gradient_internal(ima | b, c4()));
+ morpho::elementary::gradient_external(ima | b, c4()));
debug::println(gra);
}
@@ -66,7 +66,7 @@
debug::println(msk);
{
mln_VAR(gra,
- morpho::elementary::gradient_internal(msk | b, c4()));
+ morpho::elementary::gradient_external(msk | b, c4()));
debug::println(gra);
}
Index: tests/morpho/elementary/opening.cc
--- tests/morpho/elementary/opening.cc (revision 2713)
+++ tests/morpho/elementary/opening.cc (working copy)
@@ -25,9 +25,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/morpho/elementary/erosion.cc
+/*! \file tests/morpho/elementary/opening.cc
*
- * \brief Test on mln::morpho::elementary::erosion.
+ * \brief Test on mln::morpho::elementary::opening.
*/
#include <mln/core/image/image2d.hh>
@@ -37,7 +37,7 @@
#include <mln/debug/iota.hh>
#include <mln/debug/println.hh>
-#include <mln/morpho/elementary/erosion.hh>
+#include <mln/morpho/elementary/opening.hh>
int main()
@@ -51,18 +51,18 @@
debug::iota(ima);
debug::println(ima);
{
- image2d<int_u8> ero = morpho::elementary::erosion(ima, c4());
- mln_assertion(ero.border() == 1);
- debug::println(ero);
+ image2d<int_u8> ope = morpho::elementary::opening(ima, c4());
+ mln_assertion(ope.border() == 1);
+ debug::println(ope);
}
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);
+ image2d<bool> ope = morpho::elementary::opening(msk, c4());
+ mln_assertion(ope.border() == 1);
+ debug::println(ope);
}
}
Index: tests/morpho/Makefile.am
--- tests/morpho/Makefile.am (revision 2714)
+++ tests/morpho/Makefile.am (working copy)
@@ -16,7 +16,6 @@
erosion \
erosion_min_h \
gradient \
- gradient_elementary \
graph_image_morpho \
graph_image_wst \
hit_or_miss \
@@ -51,7 +50,6 @@
contrast_SOURCES = contrast.cc
gradient_SOURCES = gradient.cc
-gradient_elementary_SOURCES = gradient_elementary.cc
hit_or_miss_SOURCES = hit_or_miss.cc
laplacian_SOURCES = laplacian.cc
thinning_SOURCES = thinning.cc
Index: mln/accu/min_max.hh
--- mln/accu/min_max.hh (revision 2714)
+++ mln/accu/min_max.hh (working copy)
@@ -67,7 +67,7 @@
{
// FIXME: Doc!
- typedef pair<min,max> min_max;
+ typedef meta::pair<meta::min,meta::max> min_max;
} // end of namespace mln::accu::meta
Index: mln/morpho/elementary/like_ero_fun.hh
--- mln/morpho/elementary/like_ero_fun.hh (revision 2714)
+++ mln/morpho/elementary/like_ero_fun.hh (working copy)
@@ -63,7 +63,7 @@
template <typename V, typename A>
V operator()(const V& input_p, const A& a) const
{
- return a;
+ return a.to_result();
}
};
Index: mln/morpho/elementary/dilation.hh
--- mln/morpho/elementary/dilation.hh (revision 2714)
+++ mln/morpho/elementary/dilation.hh (working copy)
@@ -104,6 +104,7 @@
mln_concrete(I) output = internal::dilation_dispatch(input, nbh);
+ mln_postcondition(output >= input);
trace::exiting("morpho::elementary::dilation");
return output;
}
Index: mln/morpho/elementary/gradient_internal.hh
--- mln/morpho/elementary/gradient_internal.hh (revision 2714)
+++ mln/morpho/elementary/gradient_internal.hh (working copy)
@@ -82,7 +82,7 @@
{
bool val[] =
{
- 0, // ext_value
+ 1, // ext_value
0, // do_clone
1, // on_input_p
0, // on_input_n
@@ -115,6 +115,7 @@
mln_concrete(I) output = internal::gradient_internal_dispatch(input, nbh);
+ mln_postcondition(output <= input);
trace::exiting("morpho::elementary::gradient_internal");
return output;
}
Index: mln/morpho/elementary/gradient.hh
--- mln/morpho/elementary/gradient.hh (revision 2713)
+++ mln/morpho/elementary/gradient.hh (working copy)
@@ -25,15 +25,15 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_MORPHO_ELEMENTARY_GRADIENT_INTERNAL_HH
-# define MLN_MORPHO_ELEMENTARY_GRADIENT_INTERNAL_HH
+#ifndef MLN_MORPHO_ELEMENTARY_GRADIENT_HH
+# define MLN_MORPHO_ELEMENTARY_GRADIENT_HH
-/// \file mln/morpho/elementary/gradient_internal.hh
+/// \file mln/morpho/elementary/gradient.hh
///
-/// \todo Fix the extension issue (see todo in like_ero_fun and _set).
+/// \todo Add fastest versions (be careful about extension values...)
-# include <mln/morpho/elementary/like_ero_fun.hh>
-# include <mln/morpho/elementary/like_ero_set.hh>
+# include <mln/morpho/includes.hh>
+# include <mln/accu/min_max.hh>
namespace mln
@@ -48,7 +48,7 @@
template <typename I, typename N>
mln_concrete(I)
- gradient_internal(const Image<I>& input, const Neighborhood<N>& nbh);
+ gradient(const Image<I>& input, const Neighborhood<N>& nbh);
# ifndef MLN_INCLUDE_ONLY
@@ -56,46 +56,121 @@
namespace internal
{
- struct f_grad_int
+ template <typename I, typename N>
+ void
+ gradient_tests(const Image<I>& input, const Neighborhood<N>& nbh)
+ {
+ mln_precondition(exact(input).has_data());
+ // mln_precondition(exact(nbh).is_valid());
+ }
+
+ } // end of namespace mln::morpho::elementary::tests
+
+
+ namespace impl
+ {
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ gradient_on_function(const Image<I>& input_, const Neighborhood<N>& nbh_)
+ {
+ trace::entering("morpho::elementary::impl::gradient_on_function");
+
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+ internal::gradient_tests(input, nbh);
+
+ accu::min_max<mln_value(I)> a;
+
+ mln_concrete(I) output;
+ initialize(output, input);
+
+ mln_piter(I) p(input.domain());
+ mln_niter(N) n(nbh, p);
+ for_all(p)
+ {
+ a.init();
+ for_all(n) if (input.domain().has(n))
+ a.take(input(n));
+ output(p) = a.second() - a.first();
+ }
+
+ trace::exiting("morpho::elementary::impl::gradient_on_function");
+ return output;
+ }
+
+ template <typename I, typename N>
+ mln_concrete(I)
+ gradient_on_set(const Image<I>& input_, const Neighborhood<N>& nbh_)
+ {
+ trace::entering("morpho::elementary::impl::gradient_on_set");
+
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+ internal::gradient_tests(input, nbh);
+
+ mln_concrete(I) output;
+ initialize(output, input);
+ level::fill(output, false);
+
+ mln_piter(I) p(input.domain());
+ mln_niter(N) n(nbh, p);
+ for_all(p)
+ if (input(p) == true)
{
- template <typename V, typename A>
- V operator()(const V& input_p, const A& a) const
+ for_all(n) if (input.domain().has(n))
+ if (input(n) == false)
{
- return input_p - a.to_result();
+ output(p) = true;
+ break;
+ }
+ }
+ else // input(p) == false
+ {
+ for_all(n) if (input.domain().has(n))
+ if (input(n) == true)
+ {
+ output(p) = true;
+ break;
+ }
}
- };
+
+ trace::exiting("morpho::elementary::impl::gradient_on_set");
+ return output;
+ }
+
+ } // end of namespace mln::morpho::elementary::impl
+
+
+ namespace internal
+ {
// Dispatch.
template <typename I, typename N>
mln_concrete(I)
- gradient_internal_dispatch(trait::image::kind::any,
+ gradient_dispatch(trait::image::kind::any,
+ trait::image::speed::any,
const Image<I>& input, const Neighborhood<N>& nbh)
{
- return like_ero_fun(accu::meta::min(), f_grad_int(), input, nbh);
+ return impl::gradient_on_function(input, nbh);
}
template <typename I, typename N>
mln_concrete(I)
- gradient_internal_dispatch(trait::image::kind::logic,
+ gradient_dispatch(trait::image::kind::logic,
+ trait::image::speed::any,
const Image<I>& input, const Neighborhood<N>& nbh)
{
- bool val[] =
- {
- 0, // ext_value
- 0, // do_clone
- 1, // on_input_p
- 0, // on_input_n
- 1, // output_p
- };
- return like_ero_set(val, input, nbh);
+ return impl::gradient_on_set(input, nbh);
}
template <typename I, typename N>
mln_concrete(I)
- gradient_internal_dispatch(const Image<I>& input, const Neighborhood<N>& nbh)
+ gradient_dispatch(const Image<I>& input, const Neighborhood<N>& nbh)
{
- return gradient_internal_dispatch(mln_trait_image_kind(I)(),
+ return gradient_dispatch(mln_trait_image_kind(I)(),
+ mln_trait_image_speed(I)(),
input, nbh);
}
@@ -106,16 +181,14 @@
template <typename I, typename N>
mln_concrete(I)
- gradient_internal(const Image<I>& input, const Neighborhood<N>& nbh)
+ gradient(const Image<I>& input, const Neighborhood<N>& nbh)
{
- trace::entering("morpho::elementary::gradient_internal");
-
- mln_precondition(exact(input).has_data());
- // mln_precondition(exact(nbh).is_valid());
+ trace::entering("morpho::elementary::gradient");
- mln_concrete(I) output = internal::gradient_internal_dispatch(input, nbh);
+ internal::gradient_tests(input, nbh);
+ mln_concrete(I) output = internal::gradient_dispatch(input, nbh);
- trace::exiting("morpho::elementary::gradient_internal");
+ trace::exiting("morpho::elementary::gradient");
return output;
}
@@ -128,4 +201,4 @@
} // end of namespace mln
-#endif // ! MLN_MORPHO_ELEMENTARY_GRADIENT_INTERNAL_HH
+#endif // ! MLN_MORPHO_ELEMENTARY_GRADIENT_HH
Index: mln/morpho/elementary/erosion.hh
--- mln/morpho/elementary/erosion.hh (revision 2714)
+++ mln/morpho/elementary/erosion.hh (working copy)
@@ -104,6 +104,7 @@
mln_concrete(I) output = internal::erosion_dispatch(input, nbh);
+ mln_postcondition(output <= input);
trace::exiting("morpho::elementary::erosion");
return output;
}
Index: mln/morpho/elementary/closing.hh
--- mln/morpho/elementary/closing.hh (revision 2713)
+++ mln/morpho/elementary/closing.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,15 +25,16 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_MORPHO_CLOSING_HH
-# define MLN_MORPHO_CLOSING_HH
+#ifndef MLN_MORPHO_ELEMENTARY_CLOSING_HH
+# define MLN_MORPHO_ELEMENTARY_CLOSING_HH
-/*! \file mln/morpho/closing.hh
+/*! \file mln/morpho/elementary/closing.hh
*
- * \brief Morphological closing.
+ * \brief Morphological elementary closing.
*/
-# include <mln/morpho/includes.hh>
+# include <mln/morpho/elementary/erosion.hh>
+# include <mln/morpho/elementary/dilation.hh>
namespace mln
@@ -42,36 +43,41 @@
namespace morpho
{
- /*! Morphological closing.
- *
- * This operator is e_{-B} o d_B.
- */
- template <typename I, typename W>
- mln_concrete(I) closing(const Image<I>& input, const Window<W>& win);
+ namespace elementary
+ {
+
+ /// Morphological elementary closing.
+ ///
+ /// This operator is e o d.
+ template <typename I, typename N>
+ mln_concrete(I) closing(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) closing(const Image<I>& input, const Window<W>& win)
+ mln_concrete(I) closing(const Image<I>& input, const Neighborhood<N>& nbh)
{
- trace::entering("morpho::closing");
+ trace::entering("morpho::elementary::closing");
+
mln_precondition(exact(input).has_data());
- mln_precondition(! exact(win).is_empty());
+ // mln_precondition(exact(nbh).is_valid());
- mln_concrete(I) output = erosion(dilation(input, win), win::sym(win));
+ mln_concrete(I) output = erosion(dilation(input, nbh), nbh);
mln_postcondition(output >= input);
- trace::exiting("morpho::closing");
+ trace::exiting("morpho::elementary::closing");
return output;
}
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::morpho::elementary
+
} // end of namespace mln::morpho
} // end of namespace mln
-#endif // ! MLN_MORPHO_CLOSING_HH
+#endif // ! MLN_MORPHO_ELEMENTARY_CLOSING_HH
Index: mln/morpho/elementary/gradient_external.hh
--- mln/morpho/elementary/gradient_external.hh (revision 2713)
+++ mln/morpho/elementary/gradient_external.hh (working copy)
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_MORPHO_ELEMENTARY_GRADIENT_INTERNAL_HH
-# define MLN_MORPHO_ELEMENTARY_GRADIENT_INTERNAL_HH
+#ifndef MLN_MORPHO_ELEMENTARY_GRADIENT_EXTERNAL_HH
+# define MLN_MORPHO_ELEMENTARY_GRADIENT_EXTERNAL_HH
-/// \file mln/morpho/elementary/gradient_internal.hh
+/// \file mln/morpho/elementary/gradient_external.hh
///
/// \todo Fix the extension issue (see todo in like_ero_fun and _set).
@@ -48,7 +48,7 @@
template <typename I, typename N>
mln_concrete(I)
- gradient_internal(const Image<I>& input, const Neighborhood<N>& nbh);
+ gradient_external(const Image<I>& input, const Neighborhood<N>& nbh);
# ifndef MLN_INCLUDE_ONLY
@@ -56,12 +56,12 @@
namespace internal
{
- struct f_grad_int
+ struct f_grad_ext
{
template <typename V, typename A>
V operator()(const V& input_p, const A& a) const
{
- return input_p - a.to_result();
+ return a.to_result() - input_p;
}
};
@@ -69,23 +69,23 @@
template <typename I, typename N>
mln_concrete(I)
- gradient_internal_dispatch(trait::image::kind::any,
+ gradient_external_dispatch(trait::image::kind::any,
const Image<I>& input, const Neighborhood<N>& nbh)
{
- return like_ero_fun(accu::meta::min(), f_grad_int(), input, nbh);
+ return like_ero_fun(accu::meta::max(), f_grad_ext(), input, nbh);
}
template <typename I, typename N>
mln_concrete(I)
- gradient_internal_dispatch(trait::image::kind::logic,
+ gradient_external_dispatch(trait::image::kind::logic,
const Image<I>& input, const Neighborhood<N>& nbh)
{
bool val[] =
{
0, // ext_value
0, // do_clone
- 1, // on_input_p
- 0, // on_input_n
+ 0, // on_input_p
+ 1, // on_input_n
1, // output_p
};
return like_ero_set(val, input, nbh);
@@ -93,9 +93,9 @@
template <typename I, typename N>
mln_concrete(I)
- gradient_internal_dispatch(const Image<I>& input, const Neighborhood<N>& nbh)
+ gradient_external_dispatch(const Image<I>& input, const Neighborhood<N>& nbh)
{
- return gradient_internal_dispatch(mln_trait_image_kind(I)(),
+ return gradient_external_dispatch(mln_trait_image_kind(I)(),
input, nbh);
}
@@ -106,16 +106,16 @@
template <typename I, typename N>
mln_concrete(I)
- gradient_internal(const Image<I>& input, const Neighborhood<N>& nbh)
+ gradient_external(const Image<I>& input, const Neighborhood<N>& nbh)
{
- trace::entering("morpho::elementary::gradient_internal");
+ trace::entering("morpho::elementary::gradient_external");
mln_precondition(exact(input).has_data());
// mln_precondition(exact(nbh).is_valid());
- mln_concrete(I) output = internal::gradient_internal_dispatch(input, nbh);
+ mln_concrete(I) output = internal::gradient_external_dispatch(input, nbh);
- trace::exiting("morpho::elementary::gradient_internal");
+ trace::exiting("morpho::elementary::gradient_external");
return output;
}
@@ -128,4 +128,4 @@
} // end of namespace mln
-#endif // ! MLN_MORPHO_ELEMENTARY_GRADIENT_INTERNAL_HH
+#endif // ! MLN_MORPHO_ELEMENTARY_GRADIENT_EXTERNAL_HH
Index: mln/morpho/elementary/opening.hh
--- mln/morpho/elementary/opening.hh (revision 2713)
+++ mln/morpho/elementary/opening.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,15 +25,16 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_MORPHO_OPENING_HH
-# define MLN_MORPHO_OPENING_HH
+#ifndef MLN_MORPHO_ELEMENTARY_OPENING_HH
+# define MLN_MORPHO_ELEMENTARY_OPENING_HH
-/*! \file mln/morpho/opening.hh
+/*! \file mln/morpho/elementary/opening.hh
*
- * \brief Morphological opening.
+ * \brief Morphological elementary opening.
*/
-# include <mln/morpho/includes.hh>
+# include <mln/morpho/elementary/erosion.hh>
+# include <mln/morpho/elementary/dilation.hh>
namespace mln
@@ -42,38 +43,41 @@
namespace morpho
{
- /*! Morphological opening.
- *
- * This operator is d_{-B} o e_B.
- */
- template <typename I, typename W>
- mln_concrete(I) opening(const Image<I>& input, const Window<W>& win);
+ namespace elementary
+ {
+
+ /// Morphological elementary opening.
+ ///
+ /// This operator is d o e.
+ template <typename I, typename N>
+ mln_concrete(I) opening(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) opening(const Image<I>& input, const Window<W>& win)
+ mln_concrete(I) opening(const Image<I>& input, const Neighborhood<N>& nbh)
{
- trace::entering("morpho::opening");
+ trace::entering("morpho::elementary::opening");
+
mln_precondition(exact(input).has_data());
- mln_precondition(! exact(win).is_empty());
+ // mln_precondition(exact(nbh).is_valid());
- mln_concrete(I) output = dilation(erosion(input, win), win::sym(win));
+ mln_concrete(I) output = dilation(erosion(input, nbh), nbh);
- // FIXME: Is this postcondition always true, even if the
- // structuring element is not centered?
mln_postcondition(output <= input);
- trace::exiting("morpho::opening");
+ trace::exiting("morpho::elementary::opening");
return output;
}
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::morpho::elementary
+
} // end of namespace mln::morpho
} // end of namespace mln
-#endif // ! MLN_MORPHO_OPENING_HH
+#endif // ! MLN_MORPHO_ELEMENTARY_OPENING_HH
1
0
From: Maxime van Noppen <yabo(a)lrde.epita.fr>
To: olena-patches(a)lrde.epita.fr
Subject: r2714: Compute volume of max tree nodes
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
ChangeLog:
2008-10-28 Maxime van Noppen <yabo(a)lrde.epita.fr>
Compute volume of max tree nodes.
* Makefile: Little fix.
* max_tree.hh: Compute the volume.
* v2.cc: Call the volume routine.
---
Makefile | 3 ++-
max_tree.hh | 45 +++++++++++++++++++++++++++++++++++++++++++--
v2.cc | 2 ++
3 files changed, 47 insertions(+), 3 deletions(-)
Index: branches/cleanup-2008/milena/sandbox/classif/max_tree.hh
===================================================================
--- branches/cleanup-2008/milena/sandbox/classif/max_tree.hh (revision 2713)
+++ branches/cleanup-2008/milena/sandbox/classif/max_tree.hh (revision 2714)
@@ -9,6 +9,7 @@
# include <mln/level/sort_psites.hh>
# include <mln/core/image/image2d.hh>
+# include <mln/core/image/image3d.hh>
# include <mln/core/alias/neighb2d.hh>
# include <mln/value/int_u8.hh>
# include <mln/io/pgm/load.hh>
@@ -33,9 +34,13 @@
mln_ch_value(I, point) parent;
mln_ch_value(I, point) zpar;
+ // image of volumes
+ image3d<unsigned> vol;
+ image3d<unsigned> nb_represent;
+ image3d<double> density;
+
max_tree_(const I& f, const N& nbh)
- : f(f),
- nbh(nbh)
+ : f(f), nbh(nbh), vol(f.domain()), nb_represent(f.domain()), density(f.domain())
{
run();
}
@@ -98,6 +103,42 @@
debug::println(area);
}
+ void volume()
+ {
+ level::fill(vol, 0);
+ level::fill(nb_represent, 0);
+
+ {
+ mln_fwd_piter(S) p(s);
+
+ for_all(p)
+ {
+ vol(p) += 1;
+ nb_represent(p) += f(p);
+
+ if (parent(p) != p)
+ {
+ nb_represent(parent(p)) += nb_represent(p);
+ vol(parent(p)) += vol(p);
+ }
+
+ density(p) = nb_represent(p) / (double) vol(p);
+ }
+ }
+
+ {
+ mln_fwd_piter(S) p(s);
+ for_all(p)
+ {
+ std::cerr << " Color " << p << std::endl
+ << " vol = " << vol(p) << " vertices" << std::endl
+ << " nb_represent = " << nb_represent(p) << std::endl
+ << " f = " << f(p) << std::endl
+ << " density = " << density(p) << " representant / vertices " << std::endl << std::endl;
+ }
+ }
+ }
+
bool is_root(const point& p) const
{
return parent(p) == p;
Index: branches/cleanup-2008/milena/sandbox/classif/v2.cc
===================================================================
--- branches/cleanup-2008/milena/sandbox/classif/v2.cc (revision 2713)
+++ branches/cleanup-2008/milena/sandbox/classif/v2.cc (revision 2714)
@@ -55,6 +55,8 @@
out(p) = value::rgb8(pn[0] * f, pn[1] * f, pn[2] * f);
}
io::ppm::save(out, "tmp.ppm");
+
+ run.volume();
}
bool usage(int argc, char ** argv)
Index: branches/cleanup-2008/milena/sandbox/classif/Makefile
===================================================================
--- branches/cleanup-2008/milena/sandbox/classif/Makefile (revision 2713)
+++ branches/cleanup-2008/milena/sandbox/classif/Makefile (revision 2714)
@@ -13,7 +13,7 @@
# V2
V2_INCLUDES=-I../.. -I../garrigues/fllt
-V2_SRC=v2.cc
+V2_SRC=v2.cc max_tree.hh
V2=v2
V2_DBG=v2_dbg
@@ -43,6 +43,7 @@
rm -f $(ICCVG_DBG)
rm -f $(V2)
rm -f $(V2_DBG)
+ rm -f *.log
check-debug: $(ICCVG_DBG)
./iccvg_dbg $(IMG) $(DIV) $(LAMBDA) $(LOG)
1
0
cleanup-2008 2713: Add morpho elementary dilation and internal gradient.
by Thierry Geraud 28 Oct '08
by Thierry Geraud 28 Oct '08
28 Oct '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add morpho elementary dilation and internal gradient.
* mln/border/resize.hh: Remove precondition.
This test cannot be verified since this operation may be
a no-op (for images without borders).
* mln/border/adjust.hh: Likewise.
* mln/morpho/elementary/like_ero_set.hh: Fix missing
initialization.
* mln/morpho/elementary/like_ero_fun.hh: Likewise.
(f_accu): Move into the internal namespace.
* mln/morpho/elementary/dilation.hh: New.
* mln/morpho/elementary/gradient_internal.hh: New.
* mln/morpho/elementary/all.hh: Update.
* tests/morpho/elementary/dilation.cc: New.
* tests/morpho/elementary/gradient_internal.cc: New.
mln/border/adjust.hh | 2 -
mln/border/resize.hh | 2 -
mln/morpho/elementary/all.hh | 3 +
mln/morpho/elementary/dilation.hh | 36 ++++++++++-----------
mln/morpho/elementary/gradient_internal.hh | 45 ++++++++++++++++-----------
mln/morpho/elementary/like_ero_fun.hh | 11 ++++++
mln/morpho/elementary/like_ero_set.hh | 8 ++++
tests/morpho/elementary/dilation.cc | 18 +++++-----
tests/morpho/elementary/gradient_internal.cc | 23 ++++++++-----
9 files changed, 90 insertions(+), 58 deletions(-)
Index: tests/morpho/elementary/dilation.cc
--- tests/morpho/elementary/dilation.cc (revision 2712)
+++ tests/morpho/elementary/dilation.cc (working copy)
@@ -25,9 +25,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/morpho/elementary/erosion.cc
+/*! \file tests/morpho/elementary/dilation.cc
*
- * \brief Test on mln::morpho::elementary::erosion.
+ * \brief Test on mln::morpho::elementary::dilation.
*/
#include <mln/core/image/image2d.hh>
@@ -37,7 +37,7 @@
#include <mln/debug/iota.hh>
#include <mln/debug/println.hh>
-#include <mln/morpho/elementary/erosion.hh>
+#include <mln/morpho/elementary/dilation.hh>
int main()
@@ -51,18 +51,18 @@
debug::iota(ima);
debug::println(ima);
{
- image2d<int_u8> ero = morpho::elementary::erosion(ima, c4());
- mln_assertion(ero.border() == 1);
- debug::println(ero);
+ image2d<int_u8> dil = morpho::elementary::dilation(ima, c4());
+ mln_assertion(dil.border() == 1);
+ debug::println(dil);
}
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);
+ image2d<bool> dil = morpho::elementary::dilation(msk, c4());
+ mln_assertion(dil.border() == 1);
+ debug::println(dil);
}
}
Index: tests/morpho/elementary/gradient_internal.cc
--- tests/morpho/elementary/gradient_internal.cc (revision 2712)
+++ tests/morpho/elementary/gradient_internal.cc (working copy)
@@ -25,19 +25,21 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/morpho/elementary/erosion.cc
+/*! \file tests/morpho/elementary/gradient_internal.cc
*
- * \brief Test on mln::morpho::elementary::erosion.
+ * \brief Test on mln::morpho::elementary::gradient_internal.
*/
#include <mln/core/image/image2d.hh>
+#include <mln/core/image/sub_image.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/erosion.hh>
+#include <mln/morpho/elementary/gradient_internal.hh>
int main()
@@ -50,19 +52,22 @@
image2d<int_u8> ima(3, 3, 0);
debug::iota(ima);
debug::println(ima);
+
+ mln_VAR(b, ima.domain());
+
{
- image2d<int_u8> ero = morpho::elementary::erosion(ima, c4());
- mln_assertion(ero.border() == 1);
- debug::println(ero);
+ mln_VAR(gra,
+ morpho::elementary::gradient_internal(ima | b, c4()));
+ debug::println(gra);
}
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);
+ mln_VAR(gra,
+ morpho::elementary::gradient_internal(msk | b, c4()));
+ debug::println(gra);
}
}
Index: mln/border/resize.hh
--- mln/border/resize.hh (revision 2712)
+++ mln/border/resize.hh (working copy)
@@ -176,8 +176,6 @@
impl::resize_(ima, thickness);
- mln_postcondition(border::get(ima) == thickness);
-
trace::exiting("border::resize");
}
Index: mln/border/adjust.hh
--- mln/border/adjust.hh (revision 2712)
+++ mln/border/adjust.hh (working copy)
@@ -73,8 +73,6 @@
if (border::get(ima) < min_thickness)
border::resize(ima, min_thickness);
-
- mln_postcondition(border::get(ima) >= min_thickness);
}
trace::exiting("border::adjust");
Index: mln/morpho/elementary/like_ero_fun.hh
--- mln/morpho/elementary/like_ero_fun.hh (revision 2712)
+++ mln/morpho/elementary/like_ero_fun.hh (working copy)
@@ -29,6 +29,9 @@
# define MLN_MORPHO_ELEMENTARY_LIKE_ERO_FUN_HH
/// \file mln/morpho/elementary/like_ero_fun.hh
+///
+/// \todo Add a choice between adjust_fill and adjust_duplicate.
+
# include <mln/morpho/includes.hh>
@@ -49,6 +52,12 @@
const Image<I>& input, const Neighborhood<N>& nbh);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace internal
+ {
+
struct f_accu
{
template <typename V, typename A>
@@ -58,8 +67,8 @@
}
};
+ } // end of namespace mln::morpho::elementary::internal
-# ifndef MLN_INCLUDE_ONLY
namespace impl
{
Index: mln/morpho/elementary/dilation.hh
--- mln/morpho/elementary/dilation.hh (revision 2712)
+++ mln/morpho/elementary/dilation.hh (working copy)
@@ -25,10 +25,10 @@
// 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
+#ifndef MLN_MORPHO_ELEMENTARY_DILATION_HH
+# define MLN_MORPHO_ELEMENTARY_DILATION_HH
-/// \file mln/morpho/elementary/erosion.hh
+/// \file mln/morpho/elementary/dilation.hh
# include <mln/morpho/elementary/like_ero_fun.hh>
# include <mln/morpho/elementary/like_ero_set.hh>
@@ -46,7 +46,7 @@
template <typename I, typename N>
mln_concrete(I)
- erosion(const Image<I>& input, const Neighborhood<N>& nbh);
+ dilation(const Image<I>& input, const Neighborhood<N>& nbh);
# ifndef MLN_INCLUDE_ONLY
@@ -58,33 +58,33 @@
template <typename I, typename N>
mln_concrete(I)
- erosion_dispatch(trait::image::kind::any,
+ dilation_dispatch(trait::image::kind::any,
const Image<I>& input, const Neighborhood<N>& nbh)
{
- return like_ero_fun(accu::meta::min(), f_accu(), input, nbh);
+ return like_ero_fun(accu::meta::max(), f_accu(), input, nbh);
}
template <typename I, typename N>
mln_concrete(I)
- erosion_dispatch(trait::image::kind::logic,
+ dilation_dispatch(trait::image::kind::logic,
const Image<I>& input, const Neighborhood<N>& nbh)
{
bool val[] =
{
- 1, // ext_value
+ 0, // ext_value
1, // do_clone
- 1, // on_input_p
- 0, // on_input_n
- 0, // output_p
+ 0, // on_input_p
+ 1, // on_input_n
+ 1, // 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)
+ dilation_dispatch(const Image<I>& input, const Neighborhood<N>& nbh)
{
- return erosion_dispatch(mln_trait_image_kind(I)(),
+ return dilation_dispatch(mln_trait_image_kind(I)(),
input, nbh);
}
@@ -95,16 +95,16 @@
template <typename I, typename N>
mln_concrete(I)
- erosion(const Image<I>& input, const Neighborhood<N>& nbh)
+ dilation(const Image<I>& input, const Neighborhood<N>& nbh)
{
- trace::entering("morpho::elementary::erosion");
+ trace::entering("morpho::elementary::dilation");
mln_precondition(exact(input).has_data());
// mln_precondition(exact(nbh).is_valid());
- mln_concrete(I) output = internal::erosion_dispatch(input, nbh);
+ mln_concrete(I) output = internal::dilation_dispatch(input, nbh);
- trace::exiting("morpho::elementary::erosion");
+ trace::exiting("morpho::elementary::dilation");
return output;
}
@@ -117,4 +117,4 @@
} // end of namespace mln
-#endif // ! MLN_MORPHO_ELEMENTARY_EROSION_HH
+#endif // ! MLN_MORPHO_ELEMENTARY_DILATION_HH
Index: mln/morpho/elementary/like_ero_set.hh
--- mln/morpho/elementary/like_ero_set.hh (revision 2712)
+++ mln/morpho/elementary/like_ero_set.hh (working copy)
@@ -29,6 +29,8 @@
# define MLN_MORPHO_ELEMENTARY_LIKE_ERO_SET_HH
/// \file mln/morpho/elementary/like_ero_set.hh
+///
+/// \todo Add a choice between adjust_fill and adjust_duplicate.
# include <mln/morpho/includes.hh>
@@ -79,7 +81,10 @@
if (do_clone)
output = clone(input);
else
+ {
+ initialize(output, input);
level::fill(output, false);
+ }
mln_piter(I) p(input.domain());
mln_niter(N) n(nbh, p);
@@ -119,7 +124,10 @@
if (do_clone)
output = clone(input);
else
+ {
+ initialize(output, input);
level::fill(output, false);
+ }
mln_pixter(const I) p_in(input);
mln_pixter(I) p_out(output);
Index: mln/morpho/elementary/all.hh
--- mln/morpho/elementary/all.hh (revision 2712)
+++ mln/morpho/elementary/all.hh (working copy)
@@ -47,6 +47,9 @@
}
# include <mln/morpho/elementary/erosion.hh>
+# include <mln/morpho/elementary/dilation.hh>
+# include <mln/morpho/elementary/gradient_internal.hh>
+# include <mln/morpho/elementary/gradient_external.hh>
Index: mln/morpho/elementary/gradient_internal.hh
--- mln/morpho/elementary/gradient_internal.hh (revision 2712)
+++ mln/morpho/elementary/gradient_internal.hh (working copy)
@@ -25,10 +25,12 @@
// 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
+#ifndef MLN_MORPHO_ELEMENTARY_GRADIENT_INTERNAL_HH
+# define MLN_MORPHO_ELEMENTARY_GRADIENT_INTERNAL_HH
-/// \file mln/morpho/elementary/erosion.hh
+/// \file mln/morpho/elementary/gradient_internal.hh
+///
+/// \todo Fix the extension issue (see todo in like_ero_fun and _set).
# include <mln/morpho/elementary/like_ero_fun.hh>
# include <mln/morpho/elementary/like_ero_set.hh>
@@ -46,7 +48,7 @@
template <typename I, typename N>
mln_concrete(I)
- erosion(const Image<I>& input, const Neighborhood<N>& nbh);
+ gradient_internal(const Image<I>& input, const Neighborhood<N>& nbh);
# ifndef MLN_INCLUDE_ONLY
@@ -54,37 +56,46 @@
namespace internal
{
+ struct f_grad_int
+ {
+ template <typename V, typename A>
+ V operator()(const V& input_p, const A& a) const
+ {
+ return input_p - a.to_result();
+ }
+ };
+
// Dispatch.
template <typename I, typename N>
mln_concrete(I)
- erosion_dispatch(trait::image::kind::any,
+ gradient_internal_dispatch(trait::image::kind::any,
const Image<I>& input, const Neighborhood<N>& nbh)
{
- return like_ero_fun(accu::meta::min(), f_accu(), input, nbh);
+ return like_ero_fun(accu::meta::min(), f_grad_int(), input, nbh);
}
template <typename I, typename N>
mln_concrete(I)
- erosion_dispatch(trait::image::kind::logic,
+ gradient_internal_dispatch(trait::image::kind::logic,
const Image<I>& input, const Neighborhood<N>& nbh)
{
bool val[] =
{
- 1, // ext_value
- 1, // do_clone
+ 0, // ext_value
+ 0, // do_clone
1, // on_input_p
0, // on_input_n
- 0, // output_p
+ 1, // 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)
+ gradient_internal_dispatch(const Image<I>& input, const Neighborhood<N>& nbh)
{
- return erosion_dispatch(mln_trait_image_kind(I)(),
+ return gradient_internal_dispatch(mln_trait_image_kind(I)(),
input, nbh);
}
@@ -95,16 +106,16 @@
template <typename I, typename N>
mln_concrete(I)
- erosion(const Image<I>& input, const Neighborhood<N>& nbh)
+ gradient_internal(const Image<I>& input, const Neighborhood<N>& nbh)
{
- trace::entering("morpho::elementary::erosion");
+ trace::entering("morpho::elementary::gradient_internal");
mln_precondition(exact(input).has_data());
// mln_precondition(exact(nbh).is_valid());
- mln_concrete(I) output = internal::erosion_dispatch(input, nbh);
+ mln_concrete(I) output = internal::gradient_internal_dispatch(input, nbh);
- trace::exiting("morpho::elementary::erosion");
+ trace::exiting("morpho::elementary::gradient_internal");
return output;
}
@@ -117,4 +128,4 @@
} // end of namespace mln
-#endif // ! MLN_MORPHO_ELEMENTARY_EROSION_HH
+#endif // ! MLN_MORPHO_ELEMENTARY_GRADIENT_INTERNAL_HH
1
0
From: Vivien Delmon <vivien.delmon(a)lrde.epita.fr>
To: olena-patches(a)lrde.epita.fr
Subject: milena r2711: Add missing return
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
ChangeLog:
2008-10-28 Vivien Delmon <vivien.delmon(a)lrde.epita.fr>
Add missing return.
* mln/morpho/erosion.spe.hh: done.
---
erosion.spe.hh | 1 +
1 file changed, 1 insertion(+)
Index: branches/cleanup-2008/milena/mln/morpho/erosion.spe.hh
===================================================================
--- branches/cleanup-2008/milena/mln/morpho/erosion.spe.hh (revision 2710)
+++ branches/cleanup-2008/milena/mln/morpho/erosion.spe.hh (revision 2711)
@@ -1255,6 +1255,7 @@
erosion_dispatch_for_arbitrary(mln_trait_image_speed(I)(),
input, win);
trace::exiting("morpho::erosion_dispatch_for_arbitrary");
+ return ima;
}
1
0
28 Oct '08
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
1
0
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
1
0
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
ChangeLog:
2008-10-28 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
* garrigues/ocr/ocr.cc: Updates dues to gaussian's facade changes.
---
ocr.cc | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
Index: branches/cleanup-2008/milena/sandbox/garrigues/ocr/ocr.cc
===================================================================
--- branches/cleanup-2008/milena/sandbox/garrigues/ocr/ocr.cc (revision 2708)
+++ branches/cleanup-2008/milena/sandbox/garrigues/ocr/ocr.cc (revision 2709)
@@ -83,7 +83,10 @@
image2d<bool> input;
if (argc < 2)
+ {
+ std::cerr << "Usage: " << argv[0] << " in.pbm out.pbm" << std::endl;
return 1;
+ }
mln::border::thickness = 0;
@@ -102,11 +105,9 @@
image2d<int_u8> output = enlarge(input, 1);
// TODO CLEANUP
-#if 0
+#if 1
// Blur.
- image2d<int_u8> output;
- initialize(output, output2);
- linear::gaussian(output2, 1, output);
+ output = linear::gaussian(output, 1);
#endif
#if 0
1
0
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
ChangeLog:
2008-10-28 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Update gaussian facade.
* mln/linear/gaussian.hh: Return the output image.
* tests/linear/gaussian.cc: Update.
---
mln/linear/gaussian.hh | 20 +++++++++++---------
tests/linear/gaussian.cc | 5 +----
2 files changed, 12 insertions(+), 13 deletions(-)
Index: branches/cleanup-2008/milena/tests/linear/gaussian.cc
===================================================================
--- branches/cleanup-2008/milena/tests/linear/gaussian.cc (revision 2707)
+++ branches/cleanup-2008/milena/tests/linear/gaussian.cc (revision 2708)
@@ -53,10 +53,7 @@
image2d< value::int_u8 > lena;
io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
- image2d<float> tmp(lena.domain());
- linear::gaussian(lena, 5.1f, tmp);
+ image2d< value::int_u8 > out = linear::gaussian(lena, 5.1f);
- image2d< value::int_u_sat<8> > out(lena.domain());
- level::transform(tmp, math::round<int>(), out);
io::pgm::save(out, "out.pgm");
}
Index: branches/cleanup-2008/milena/mln/linear/gaussian.hh
===================================================================
--- branches/cleanup-2008/milena/mln/linear/gaussian.hh (revision 2707)
+++ branches/cleanup-2008/milena/mln/linear/gaussian.hh (revision 2708)
@@ -55,10 +55,9 @@
*
* \pre output.domain = input.domain
*/
- template <class I, class O>
- void
- gaussian(const Image<I>& input, float sigma,
- Image<O>& output);
+ template <class I>
+ mln_concrete(I)
+ gaussian(const Image<I>& input, float sigma);
# ifndef MLN_INCLUDE_ONLY
@@ -323,14 +322,15 @@
// Facade.
- template <class I, class O>
+ template <class I>
inline
- void
- gaussian(const Image<I>& input, float sigma,
- Image<O>& output)
+ mln_concrete(I)
+ gaussian(const Image<I>& input, float sigma)
{
mln_precondition(exact(input).has_data());
- mln_precondition(exact(output).has_data());
+
+ mln_concrete(I) output;
+ initialize(output, input);
impl::recursivefilter_coef_
coef(1.68f, 3.735f,
@@ -340,6 +340,8 @@
sigma);
impl::gaussian_common_(mln_trait_value_nature(mln_value(I))(),
input, coef, sigma, output);
+
+ return output;
}
# endif // ! MLN_INCLUDE_ONLY
1
0