milena r3442: Typos corrections in morpho, tests added and corrected

URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena ChangeLog: 2009-02-28 Frederic Bour <bour@lrde.epita.fr> Typos corrections in morpho, tests added and corrected. * mln/morpho/attribute/height.hh, * mln/morpho/closing/algebraic.hh, * mln/morpho/closing/area.hh, * mln/morpho/closing/height.hh, * mln/morpho/closing/volume.hh, * mln/morpho/opening/algebraic.hh, * mln/morpho/opening/area.hh, * mln/morpho/opening/height.hh, * mln/morpho/opening/leveling.hh, * mln/morpho/opening/volume.hh: Correct typos errors, adjust names. * tests/morpho/closing/Makefile.am: Add sum test. * tests/morpho/closing/sum.cc: New. * tests/morpho/closing/volume.cc: Correct error in function usage. * tests/morpho/opening/Makefile.am: Add sum test. * tests/morpho/opening/sum.cc: New. --- mln/morpho/attribute/height.hh | 12 ++++--- mln/morpho/closing/algebraic.hh | 2 - mln/morpho/closing/area.hh | 2 - mln/morpho/closing/height.hh | 4 +- mln/morpho/closing/volume.hh | 4 +- mln/morpho/opening/algebraic.hh | 4 +- mln/morpho/opening/area.hh | 2 - mln/morpho/opening/height.hh | 4 +- mln/morpho/opening/leveling.hh | 4 +- mln/morpho/opening/volume.hh | 2 - tests/morpho/closing/Makefile.am | 4 +- tests/morpho/closing/sum.cc | 59 +++++++++++++++++++++++++++++++++++++++ tests/morpho/closing/volume.cc | 2 - tests/morpho/opening/Makefile.am | 4 +- tests/morpho/opening/sum.cc | 58 ++++++++++++++++++++++++++++++++++++++ 15 files changed, 143 insertions(+), 24 deletions(-) Index: trunk/milena/tests/morpho/closing/sum.cc =================================================================== --- trunk/milena/tests/morpho/closing/sum.cc (revision 0) +++ trunk/milena/tests/morpho/closing/sum.cc (revision 3442) @@ -0,0 +1,59 @@ +// Copyright (C) 2007, 2008, 2009 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/closing/sum.cc +/// +/// Test on mln::morpho::closing::sum. + +#include <mln/core/image/image2d.hh> +#include <mln/value/int_u8.hh> +#include <mln/core/alias/neighb2d.hh> + +#include <mln/io/pgm/load.hh> +#include <mln/io/pgm/save.hh> + +#include <mln/morpho/closing/leveling.hh> +#include <mln/morpho/attribute/sum.hh> + +#include "tests/data.hh" + + +int main() +{ + using namespace mln; + using value::int_u8; + + typedef image2d<int_u8> I; + I lena; + + io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm"); + + typedef morpho::attribute::sum<I> A; + io::pgm::save(morpho::closing::leveling(lena, c4(), A(), 10000), + "out.pgm"); +} Index: trunk/milena/tests/morpho/closing/Makefile.am =================================================================== --- trunk/milena/tests/morpho/closing/Makefile.am (revision 3441) +++ trunk/milena/tests/morpho/closing/Makefile.am (revision 3442) @@ -6,14 +6,14 @@ leveling \ algebraic \ height \ - card \ + area \ volume \ sum leveling_SOURCES = leveling.cc algebraic_SOURCES = algebraic.cc height_SOURCES = height.cc -card_SOURCES = card.cc +area_SOURCES = area.cc volume_SOURCES = volume.cc sum_SOURCES = sum.cc Index: trunk/milena/tests/morpho/closing/volume.cc =================================================================== --- trunk/milena/tests/morpho/closing/volume.cc (revision 3441) +++ trunk/milena/tests/morpho/closing/volume.cc (revision 3442) @@ -55,6 +55,6 @@ "ref.pgm"); typedef morpho::attribute::volume<I> A; - io::pgm::save(morpho::closing_attribute<A>(lena, c4(), 10000), + io::pgm::save(morpho::closing::leveling(lena, c4(), A(), 10000), "out.pgm"); } Index: trunk/milena/tests/morpho/opening/sum.cc =================================================================== --- trunk/milena/tests/morpho/opening/sum.cc (revision 0) +++ trunk/milena/tests/morpho/opening/sum.cc (revision 3442) @@ -0,0 +1,58 @@ +// Copyright (C) 2007, 2008, 2009 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/closing/sum.cc +/// +/// Test on mln::morpho::closing::sum. + +#include <mln/core/image/image2d.hh> +#include <mln/value/int_u8.hh> +#include <mln/core/alias/neighb2d.hh> + +#include <mln/io/pgm/load.hh> +#include <mln/io/pgm/save.hh> + +#include <mln/morpho/opening/leveling.hh> +#include <mln/morpho/attribute/sum.hh> + +#include "tests/data.hh" + + +int main() +{ + using namespace mln; + using value::int_u8; + + typedef image2d<int_u8> I; + I lena; + + typedef morpho::attribute::sum<I> A; + io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm"); + io::pgm::save(morpho::opening::leveling(lena, c4(), A(), 10000), + "out.pgm"); +} Index: trunk/milena/tests/morpho/opening/Makefile.am =================================================================== --- trunk/milena/tests/morpho/opening/Makefile.am (revision 3441) +++ trunk/milena/tests/morpho/opening/Makefile.am (revision 3442) @@ -6,14 +6,14 @@ leveling \ algebraic \ height \ - card \ + area \ volume \ sum leveling_SOURCES = leveling.cc algebraic_SOURCES = algebraic.cc height_SOURCES = height.cc -card_SOURCES = card.cc +area_SOURCES = area.cc volume_SOURCES = volume.cc sum_SOURCES = sum.cc Index: trunk/milena/mln/morpho/closing/volume.hh =================================================================== --- trunk/milena/mln/morpho/closing/volume.hh (revision 3441) +++ trunk/milena/mln/morpho/closing/volume.hh (revision 3442) @@ -33,7 +33,7 @@ /// /// Morphological volume closing. -# include <mln/morpho/closing/attribute.hh> +# include <mln/morpho/closing/leveling.hh> # include <mln/morpho/attribute/volume.hh> @@ -66,7 +66,7 @@ mln_precondition(exact(input).is_valid()); mln_concrete(I) output; - output = closing::attribute< attribute::volume<I> >(input, nbh, lambda); + output = closing::leveling(input, nbh, attribute::volume<I>(), lambda); trace::exiting("morpho::closing::volume"); return output; Index: trunk/milena/mln/morpho/closing/area.hh =================================================================== --- trunk/milena/mln/morpho/closing/area.hh (revision 3441) +++ trunk/milena/mln/morpho/closing/area.hh (revision 3442) @@ -66,7 +66,7 @@ mln_precondition(exact(input).is_valid()); mln_concrete(I) output; - output = closing::algebraic< attribute::card<I> >(input, nbh, lambda); + output = closing::algebraic(input, nbh, attribute::card<I>(), lambda); trace::exiting("morpho::closing::area"); return output; Index: trunk/milena/mln/morpho/closing/height.hh =================================================================== --- trunk/milena/mln/morpho/closing/height.hh (revision 3441) +++ trunk/milena/mln/morpho/closing/height.hh (revision 3442) @@ -35,7 +35,7 @@ /// /// \todo The test result looks very weird... Debug! -# include <mln/morpho/closing/algebraic.hh> +# include <mln/morpho/closing/leveling.hh> # include <mln/morpho/attribute/height.hh> @@ -68,7 +68,7 @@ mln_precondition(exact(input).is_valid()); mln_concrete(I) output; - output = closing::leveling< attribute::height<I> >(input, nbh, lambda); + output = closing::leveling(input, nbh, attribute::height<I>(), lambda); trace::exiting("morpho::closing::height"); return output; Index: trunk/milena/mln/morpho/closing/algebraic.hh =================================================================== --- trunk/milena/mln/morpho/closing/algebraic.hh (revision 3441) +++ trunk/milena/mln/morpho/closing/algebraic.hh (revision 3442) @@ -62,7 +62,7 @@ trace::entering("morpho::closing::algebraic"); mln_precondition(exact(input).is_valid()); - mln_precondition(mlc_equal(mln_trait_accumulator_when_pix(A), + mln_precondition(mlc_not_equal(mln_trait_accumulator_when_pix(A), trait::accumulator::when_pix::not_ok)::value); mln_concrete(I) output; Index: trunk/milena/mln/morpho/attribute/height.hh =================================================================== --- trunk/milena/mln/morpho/attribute/height.hh (revision 3441) +++ trunk/milena/mln/morpho/attribute/height.hh (revision 3442) @@ -46,7 +46,7 @@ // Forward declaration. namespace morpho { namespace attribute { - template <typename I> class volume; + template <typename I> class height; } } @@ -56,7 +56,7 @@ namespace trait { template <typename I> - struct accumulator_< morpho::attribute::volume<I> > + struct accumulator_< morpho::attribute::height<I> > { typedef accumulator::has_untake::no has_untake; typedef accumulator::has_set_value::no has_set_value; @@ -152,7 +152,9 @@ void height<I>::take(const height<I>& other) { - mln_invariant(ref_ < cur_ xor other.ref_ > other.cur_); + mln_invariant(((ref_ <= cur_) && (other.ref_ <= other.cur_)) + || ((ref_ >= cur_) && (other.ref_ >= other.cur_))); + if (!is_valid()) { ref_ = other.ref_; @@ -195,8 +197,8 @@ unsigned height<I>::to_result() const { - mln_invariant(initialized_); - if (is_valid()) + mln_invariant(is_valid()); + return math::diff_abs(ref_, cur_); } Index: trunk/milena/mln/morpho/opening/leveling.hh =================================================================== --- trunk/milena/mln/morpho/opening/leveling.hh (revision 3441) +++ trunk/milena/mln/morpho/opening/leveling.hh (revision 3442) @@ -62,8 +62,8 @@ trace::entering("morpho::opening::leveling"); mln_precondition(exact(input).is_valid()); - mln_precondition(mlc_equal(mln_trait_accumulator_when_pix(A), - trait::accumulator::when_pix::not_ok)::value) + mln_precondition(mlc_not_equal(mln_trait_accumulator_when_pix(A), + trait::accumulator::when_pix::not_ok)::value); mln_concrete(I) output; output = leveling_filter(input, nbh, accu, lambda, Index: trunk/milena/mln/morpho/opening/volume.hh =================================================================== --- trunk/milena/mln/morpho/opening/volume.hh (revision 3441) +++ trunk/milena/mln/morpho/opening/volume.hh (revision 3442) @@ -63,7 +63,7 @@ mln_precondition(exact(input).is_valid()); mln_concrete(I) output; - output = opening::leveling< attribute::volume<I> >(input, nbh, lambda); + output = opening::leveling(input, nbh, attribute::volume<I>(), lambda); trace::exiting("morpho::opening::volume"); return output; Index: trunk/milena/mln/morpho/opening/area.hh =================================================================== --- trunk/milena/mln/morpho/opening/area.hh (revision 3441) +++ trunk/milena/mln/morpho/opening/area.hh (revision 3442) @@ -66,7 +66,7 @@ mln_precondition(exact(input).is_valid()); mln_concrete(I) output; - output = opening::algebraic< attribute::card<I> >(input, nbh, lambda); + output = opening::algebraic(input, nbh, attribute::card<I>(), lambda); trace::exiting("morpho::opening::area"); return output; Index: trunk/milena/mln/morpho/opening/height.hh =================================================================== --- trunk/milena/mln/morpho/opening/height.hh (revision 3441) +++ trunk/milena/mln/morpho/opening/height.hh (revision 3442) @@ -33,7 +33,7 @@ /// /// Morphological height opening. -# include <mln/morpho/opening/attribute.hh> +# include <mln/morpho/opening/leveling.hh> # include <mln/morpho/attribute/height.hh> @@ -65,7 +65,7 @@ mln_precondition(exact(input).is_valid()); mln_concrete(I) output; - output = opening::leveling< attribute::height<I> >(input, nbh, lambda); + output = opening::leveling(input, nbh, attribute::height<I>(), lambda); trace::exiting("morpho::opening::height"); return output; Index: trunk/milena/mln/morpho/opening/algebraic.hh =================================================================== --- trunk/milena/mln/morpho/opening/algebraic.hh (revision 3441) +++ trunk/milena/mln/morpho/opening/algebraic.hh (revision 3442) @@ -62,8 +62,8 @@ trace::entering("morpho::opening::algebraic"); mln_precondition(exact(input).is_valid()); - mln_precondition(mlc_equal(mln_trait_accumulator_when_pix(A), - trait::accumulator::when_pix::not_ok)::value) + mln_precondition(mlc_not_equal(mln_trait_accumulator_when_pix(A), + trait::accumulator::when_pix::not_ok)::value); mln_concrete(I) output; output = algebraic_filter(input, nbh, accu, lambda,
participants (1)
-
Frederic Bour