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