
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena Index: ChangeLog from Thierry Geraud <thierry.geraud@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