URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-02-28 Frederic Bour <bour(a)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,
URL: https://svn.lrde.epita.fr/svn/oln/trunk
ChangeLog:
2009-02-28 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Add leveling/algebraic morpho tests.
* configure.ac: Add opening/closing subdirs to generate Makefile.
* milena/mln/morpho/closing/leveling.hh: Missing file from
last commit.
* milena/mln/morpho/opening/leveling.hh: Missing file from
last commit.
* milena/tests/morpho/closing/Makefile.am: New.
* milena/tests/morpho/closing/algebraic.cc: Test file for
algebraic closing filter.
* milena/tests/morpho/closing/leveling.cc: Test file for
leveling closing filter.
* milena/tests/morpho/opening/Makefile.am: New.
* milena/tests/morpho/opening/algebraic.cc: Test file for
algebraic opening filter.
* milena/tests/morpho/opening/leveling.cc: Test file for
leveling opening filter.
---
configure.ac | 2
milena/mln/morpho/closing/leveling.hh | 86 +++++++++++++++++++++++++++++++
milena/mln/morpho/opening/leveling.hh | 86 +++++++++++++++++++++++++++++++
milena/tests/morpho/closing/Makefile.am | 20 +++++++
milena/tests/morpho/closing/algebraic.cc | 10 +--
milena/tests/morpho/closing/leveling.cc | 67 ++++++++++++++++++++++++
milena/tests/morpho/opening/Makefile.am | 20 +++++++
milena/tests/morpho/opening/algebraic.cc | 67 ++++++++++++++++++++++++
milena/tests/morpho/opening/leveling.cc | 67 ++++++++++++++++++++++++
9 files changed, 420 insertions(+), 5 deletions(-)
Index: trunk/configure.ac
===================================================================
--- trunk/configure.ac (revision 3439)
+++ trunk/configure.ac (revision 3440)
@@ -244,6 +244,8 @@
milena/tests/morpho/elementary/Makefile
milena/tests/morpho/tree/Makefile
milena/tests/morpho/watershed/Makefile
+ milena/tests/morpho/closing/Makefile
+ milena/tests/morpho/opening/Makefile
milena/tests/norm/Makefile
milena/tests/opt/Makefile
milena/tests/pw/Makefile
Index: trunk/milena/tests/morpho/closing/Makefile.am
===================================================================
--- trunk/milena/tests/morpho/closing/Makefile.am (revision 0)
+++ trunk/milena/tests/morpho/closing/Makefile.am (revision 3440)
@@ -0,0 +1,20 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS =
+ leveling \
+ algebraic \
+ height \
+ card \
+ volume \
+ sum
+
+leveling_SOURCES = leveling.cc
+algebraic_SOURCES = algebraic.cc
+height_SOURCES = height.cc
+card_SOURCES = card.cc
+volume_SOURCES = volume.cc
+sum_SOURCES = sum.cc
+
+TESTS = $(check_PROGRAMS)
\ No newline at end of file
Index: trunk/milena/tests/morpho/closing/leveling.cc
===================================================================
--- trunk/milena/tests/morpho/closing/leveling.cc (revision 0)
+++ trunk/milena/tests/morpho/closing/leveling.cc (revision 3440)
@@ -0,0 +1,67 @@
+// Copyright (C) 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/leveling.cc
+///
+/// Test on mln::morpho::closing::leveling.
+
+#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/volume.hh>
+#include <mln/accu/count.hh>
+
+#include "tests/data.hh"
+
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ trace::quiet = false;
+
+ typedef image2d<int_u8> I;
+ I lena;
+ io::pgm::load(lena, MLN_IMG_DIR "/tiny.pgm");
+ {
+ accu::count<point2d> a;
+ io::pgm::save(morpho::closing::leveling(lena, c4(), a, 10),
+ "ref.pgm");
+ }
+ {
+ morpho::attribute::volume<I> a;
+ io::pgm::save(morpho::closing::leveling(lena, c4(), a, 10),
+ "out.pgm");
+ }
+}
Property changes on: trunk/milena/tests/morpho/closing/leveling.cc
___________________________________________________________________
Name: svn:mergeinfo
+
Index: trunk/milena/tests/morpho/closing/algebraic.cc
===================================================================
--- trunk/milena/tests/morpho/closing/algebraic.cc (revision 3439)
+++ trunk/milena/tests/morpho/closing/algebraic.cc (revision 3440)
@@ -25,9 +25,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/morpho/closing_algebraic.cc
+/// \file tests/morpho/closing/algebraic.cc
///
-/// Test on mln::morpho::closing_algebraic.
+/// Test on mln::morpho::closing::algebraic.
#include <mln/core/image/image2d.hh>
#include <mln/value/int_u8.hh>
@@ -36,7 +36,7 @@
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
-#include <mln/morpho/closing_algebraic.hh>
+#include <mln/morpho/closing/algebraic.hh>
#include <mln/morpho/attribute/card.hh>
#include <mln/accu/count.hh>
@@ -56,12 +56,12 @@
io::pgm::load(lena, MLN_IMG_DIR "/tiny.pgm");
{
accu::count<point2d> a;
- io::pgm::save(morpho::closing_algebraic(lena, c4(), a, 10),
+ io::pgm::save(morpho::closing::algebraic(lena, c4(), a, 10),
"ref.pgm");
}
{
morpho::attribute::card<I> a;
- io::pgm::save(morpho::closing_algebraic(lena, c4(), a, 10),
+ io::pgm::save(morpho::closing::algebraic(lena, c4(), a, 10),
"out.pgm");
}
}
Index: trunk/milena/tests/morpho/opening/Makefile.am
===================================================================
--- trunk/milena/tests/morpho/opening/Makefile.am (revision 0)
+++ trunk/milena/tests/morpho/opening/Makefile.am (revision 3440)
@@ -0,0 +1,20 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS =
+ leveling \
+ algebraic \
+ height \
+ card \
+ volume \
+ sum
+
+leveling_SOURCES = leveling.cc
+algebraic_SOURCES = algebraic.cc
+height_SOURCES = height.cc
+card_SOURCES = card.cc
+volume_SOURCES = volume.cc
+sum_SOURCES = sum.cc
+
+TESTS = $(check_PROGRAMS)
\ No newline at end of file
Index: trunk/milena/tests/morpho/opening/leveling.cc
===================================================================
--- trunk/milena/tests/morpho/opening/leveling.cc (revision 0)
+++ trunk/milena/tests/morpho/opening/leveling.cc (revision 3440)
@@ -0,0 +1,67 @@
+// Copyright (C) 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/opening/leveling.cc
+///
+/// Test on mln::morpho::opening::leveling.
+
+#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/volume.hh>
+#include <mln/accu/count.hh>
+
+#include "tests/data.hh"
+
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ trace::quiet = false;
+
+ typedef image2d<int_u8> I;
+ I lena;
+ io::pgm::load(lena, MLN_IMG_DIR "/tiny.pgm");
+ {
+ accu::count<point2d> a;
+ io::pgm::save(morpho::opening::leveling(lena, c4(), a, 10),
+ "ref.pgm");
+ }
+ {
+ morpho::attribute::volume<I> a;
+ io::pgm::save(morpho::opening::leveling(lena, c4(), a, 10),
+ "out.pgm");
+ }
+}
Index: trunk/milena/tests/morpho/opening/algebraic.cc
===================================================================
--- trunk/milena/tests/morpho/opening/algebraic.cc (revision 0)
+++ trunk/milena/tests/morpho/opening/algebraic.cc (revision 3440)
@@ -0,0 +1,67 @@
+// Copyright (C) 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/opening/algebraic.cc
+///
+/// Test on mln::morpho::opening::algebraic.
+
+#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/algebraic.hh>
+#include <mln/morpho/attribute/card.hh>
+#include <mln/accu/count.hh>
+
+#include "tests/data.hh"
+
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ trace::quiet = false;
+
+ typedef image2d<int_u8> I;
+ I lena;
+ io::pgm::load(lena, MLN_IMG_DIR "/tiny.pgm");
+ {
+ accu::count<point2d> a;
+ io::pgm::save(morpho::opening::algebraic(lena, c4(), a, 10),
+ "ref.pgm");
+ }
+ {
+ morpho::attribute::card<I> a;
+ io::pgm::save(morpho::opening::algebraic(lena, c4(), a, 10),
+ "out.pgm");
+ }
+}
Property changes on: trunk/milena/tests/morpho/opening/algebraic.cc
___________________________________________________________________
Name: svn:mergeinfo
+
Index: trunk/milena/mln/morpho/closing/leveling.hh
===================================================================
--- trunk/milena/mln/morpho/closing/leveling.hh (revision 0)
+++ trunk/milena/mln/morpho/closing/leveling.hh (revision 3440)
@@ -0,0 +1,86 @@
+// 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.
+
+#ifndef MLN_MORPHO_OPENING_LEVELING_HH
+# define MLN_MORPHO_CLOSING_LEVELING_HH
+
+/// \file mln/morpho/closing/leveling.hh
+///
+/// Morphological leveling closing.
+
+# include <mln/morpho/includes.hh>
+# include <mln/morpho/leveling_filter.hh>
+
+
+namespace mln {
+ namespace morpho {
+ namespace closing {
+
+ /// Morphological leveling closing.
+ template <typename I, typename N, typename A>
+ mln_concrete(I)
+ leveling(const Image<I>& input, const Neighborhood<N>& nbh,
+ const Accumulator<A>& accu, const mln_result(A)& lambda);
+
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename I, typename N, typename A>
+ inline
+ mln_concrete(I)
+ leveling(const Image<I>& input, const Neighborhood<N>& nbh,
+ const Accumulator<A>& accu, const mln_result(A)& lambda)
+ {
+ trace::entering("morpho::closing::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_concrete(I) output;
+ output = leveling_filter(input, nbh, accu, lambda,
+ /* increasing = */ true);
+
+ mln_postcondition(output >= input);
+
+ trace::exiting("morpho::closing::leveling");
+ return output;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho::closing
+ } // end of namespace mln::morpho
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_CLOSING_LEVELING_HH
Index: trunk/milena/mln/morpho/opening/leveling.hh
===================================================================
--- trunk/milena/mln/morpho/opening/leveling.hh (revision 0)
+++ trunk/milena/mln/morpho/opening/leveling.hh (revision 3440)
@@ -0,0 +1,86 @@
+// 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.
+
+#ifndef MLN_MORPHO_OPENING_LEVELING_HH
+# define MLN_MORPHO_OPENING_LEVELING_HH
+
+/// \file mln/morpho/opening/leveling.hh
+///
+/// Morphological leveling opening.
+
+# include <mln/morpho/includes.hh>
+# include <mln/morpho/leveling_filter.hh>
+
+
+namespace mln {
+ namespace morpho {
+ namespace opening {
+
+ /// Morphological leveling opening.
+ template <typename I, typename N, typename A>
+ mln_concrete(I)
+ leveling(const Image<I>& input, const Neighborhood<N>& nbh,
+ const Accumulator<A>& accu, const mln_result(A)& lambda);
+
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename I, typename N, typename A>
+ inline
+ mln_concrete(I)
+ leveling(const Image<I>& input, const Neighborhood<N>& nbh,
+ const Accumulator<A>& accu, const mln_result(A)& lambda)
+ {
+ 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_concrete(I) output;
+ output = leveling_filter(input, nbh, accu, lambda,
+ /* increasing = */ false);
+
+ mln_postcondition(output <= input);
+
+ trace::exiting("morpho::opening::leveling");
+ return output;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho::opening
+ } // end of namespace mln::morpho
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_OPENING_LEVELING_HH
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-02-28 Frederic Bour <bour(a)lrde.epita.fr>
Closing and opening area, volume, height naming change..
* closing/area.hh: New.
* closing/height.hh: New.
* closing/volume.hh: New.
* closing_area.hh: Remove.
* closing_height.hh: Remove.
* closing_volume.hh: Remove.
* opening/area.hh: New.
* opening/height.hh: New.
* opening/volume.hh: New.
* opening_area.hh: Remove.
* opening_height.hh: Remove.
* opening_volume.hh: Remove.
---
closing/area.hh | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++
closing/height.hh | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
closing/volume.hh | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++
opening/area.hh | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++
opening/height.hh | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++
opening/volume.hh | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 502 insertions(+)
Index: trunk/milena/mln/morpho/closing_volume.hh (deleted)
===================================================================
Index: trunk/milena/mln/morpho/closing_area.hh (deleted)
===================================================================
Index: trunk/milena/mln/morpho/closing_height.hh (deleted)
===================================================================
Index: trunk/milena/mln/morpho/opening_volume.hh (deleted)
===================================================================
Index: trunk/milena/mln/morpho/opening_height.hh (deleted)
===================================================================
Index: trunk/milena/mln/morpho/opening_area.hh (deleted)
===================================================================
Index: trunk/milena/mln/morpho/closing/volume.hh
===================================================================
--- trunk/milena/mln/morpho/closing/volume.hh (revision 0)
+++ trunk/milena/mln/morpho/closing/volume.hh (revision 3438)
@@ -0,0 +1,84 @@
+// Copyright (C) 2007, 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.
+
+#ifndef MLN_MORPHO_CLOSING_VOLUME_HH
+# define MLN_MORPHO_CLOSING_VOLUME_HH
+
+/// \file mln/morpho/closing/volume.hh
+///
+/// Morphological volume closing.
+
+# include <mln/morpho/closing/attribute.hh>
+# include <mln/morpho/attribute/volume.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace closing
+ {
+
+ /// Morphological volume closing.
+ template <typename I, typename N>
+ mln_concrete(I)
+ volume(const Image<I>& input, const Neighborhood<N>& nbh,
+ unsigned lambda);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename N>
+ inline
+ mln_concrete(I)
+ volume(const Image<I>& input, const Neighborhood<N>& nbh,
+ unsigned lambda)
+ {
+ trace::entering("morpho::closing::volume");
+
+ mln_precondition(exact(input).is_valid());
+
+ mln_concrete(I) output;
+ output = closing::attribute< attribute::volume<I> >(input, nbh, lambda);
+
+ trace::exiting("morpho::closing::volume");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho::closing
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_CLOSING_VOLUME_HH
Index: trunk/milena/mln/morpho/closing/area.hh
===================================================================
--- trunk/milena/mln/morpho/closing/area.hh (revision 0)
+++ trunk/milena/mln/morpho/closing/area.hh (revision 3438)
@@ -0,0 +1,84 @@
+// Copyright (C) 2007, 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.
+
+#ifndef MLN_MORPHO_CLOSING_AREA_HH
+# define MLN_MORPHO_CLOSING_AREA_HH
+
+/// \file mln/morpho/closing/area.hh
+///
+/// Morphological area closing.
+
+# include <mln/morpho/closing/algebraic.hh>
+# include <mln/morpho/attribute/card.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace closing
+ {
+
+ /// Morphological area closing.
+ template <typename I, typename N>
+ mln_concrete(I)
+ area(const Image<I>& input, const Neighborhood<N>& nbh,
+ unsigned lambda);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename N>
+ inline
+ mln_concrete(I)
+ area(const Image<I>& input, const Neighborhood<N>& nbh,
+ unsigned lambda)
+ {
+ trace::entering("morpho::closing::area");
+
+ mln_precondition(exact(input).is_valid());
+
+ mln_concrete(I) output;
+ output = closing::algebraic< attribute::card<I> >(input, nbh, lambda);
+
+ trace::exiting("morpho::closing::area");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho::closing
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_CLOSING_AREA_HH
Index: trunk/milena/mln/morpho/closing/height.hh
===================================================================
--- trunk/milena/mln/morpho/closing/height.hh (revision 0)
+++ trunk/milena/mln/morpho/closing/height.hh (revision 3438)
@@ -0,0 +1,86 @@
+// Copyright (C) 2007, 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.
+
+#ifndef MLN_MORPHO_CLOSING_HEIGHT_HH
+# define MLN_MORPHO_CLOSING_HEIGHT_HH
+
+/// \file mln/morpho/closing/height.hh
+///
+/// Morphological height closing.
+///
+/// \todo The test result looks very weird... Debug!
+
+# include <mln/morpho/closing/algebraic.hh>
+# include <mln/morpho/attribute/height.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace closing
+ {
+
+ /// Morphological height closing.
+ template <typename I, typename N>
+ mln_concrete(I)
+ height(const Image<I>& input, const Neighborhood<N>& nbh,
+ unsigned lambda);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename N>
+ inline
+ mln_concrete(I)
+ height(const Image<I>& input, const Neighborhood<N>& nbh,
+ unsigned lambda)
+ {
+ trace::entering("morpho::closing::height");
+
+ mln_precondition(exact(input).is_valid());
+
+ mln_concrete(I) output;
+ output = closing::leveling< attribute::height<I> >(input, nbh, lambda);
+
+ trace::exiting("morpho::closing::height");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho::closing
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_CLOSING_HEIGHT_HH
Index: trunk/milena/mln/morpho/opening/volume.hh
===================================================================
--- trunk/milena/mln/morpho/opening/volume.hh (revision 0)
+++ trunk/milena/mln/morpho/opening/volume.hh (revision 3438)
@@ -0,0 +1,81 @@
+// Copyright (C) 2007, 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.
+
+#ifndef MLN_MORPHO_OPENING_VOLUME_HH
+# define MLN_MORPHO_OPENING_VOLUME_HH
+
+/// \file mln/morpho/opening/volume.hh
+///
+/// Morphological volume opening.
+
+# include <mln/morpho/opening/leveling.hh>
+# include <mln/morpho/attribute/volume.hh>
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace opening {
+
+ /// Morphological volume opening.
+ template <typename I, typename N>
+ mln_concrete(I)
+ volume(const Image<I>& input, const Neighborhood<N>& nbh,
+ unsigned lambda);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename N>
+ inline
+ mln_concrete(I)
+ volume(const Image<I>& input, const Neighborhood<N>& nbh,
+ unsigned lambda)
+ {
+ trace::entering("morpho::opening::volume");
+ mln_precondition(exact(input).is_valid());
+
+ mln_concrete(I) output;
+ output = opening::leveling< attribute::volume<I> >(input, nbh, lambda);
+
+ trace::exiting("morpho::opening::volume");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho::opening
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_OPENING_VOLUME_HH
Index: trunk/milena/mln/morpho/opening/area.hh
===================================================================
--- trunk/milena/mln/morpho/opening/area.hh (revision 0)
+++ trunk/milena/mln/morpho/opening/area.hh (revision 3438)
@@ -0,0 +1,84 @@
+// Copyright (C) 2007, 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.
+
+#ifndef MLN_MORPHO_OPENING_AREA_HH
+# define MLN_MORPHO_OPENING_AREA_HH
+
+/// \file mln/morpho/opening/area.hh
+///
+/// Morphological area opening.
+
+# include <mln/morpho/opening/algebraic.hh>
+# include <mln/morpho/attribute/card.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace opening
+ {
+
+ /// Morphological area opening.
+ template <typename I, typename N>
+ mln_concrete(I)
+ area(const Image<I>& input, const Neighborhood<N>& nbh,
+ unsigned lambda);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename N>
+ inline
+ mln_concrete(I)
+ area(const Image<I>& input, const Neighborhood<N>& nbh,
+ unsigned lambda)
+ {
+ trace::entering("morpho::opening::area");
+
+ mln_precondition(exact(input).is_valid());
+
+ mln_concrete(I) output;
+ output = opening::algebraic< attribute::card<I> >(input, nbh, lambda);
+
+ trace::exiting("morpho::opening::area");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho::opening
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_OPENING_AREA_HH
Index: trunk/milena/mln/morpho/opening/height.hh
===================================================================
--- trunk/milena/mln/morpho/opening/height.hh (revision 0)
+++ trunk/milena/mln/morpho/opening/height.hh (revision 3438)
@@ -0,0 +1,83 @@
+// Copyright (C) 2007, 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.
+
+#ifndef MLN_MORPHO_OPENING_HEIGHT_HH
+# define MLN_MORPHO_OPENING_HEIGHT_HH
+
+/// \file mln/morpho/opening/height.hh
+///
+/// Morphological height opening.
+
+# include <mln/morpho/opening/attribute.hh>
+# include <mln/morpho/attribute/height.hh>
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace opening
+ {
+
+ /// Morphological height opening.
+ template <typename I, typename N>
+ mln_concrete(I)
+ height(const Image<I>& input, const Neighborhood<N>& nbh,
+ unsigned lambda);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename N>
+ inline
+ mln_concrete(I)
+ height(const Image<I>& input, const Neighborhood<N>& nbh,
+ unsigned lambda)
+ {
+ trace::entering("morpho::opening::height");
+ mln_precondition(exact(input).is_valid());
+
+ mln_concrete(I) output;
+ output = opening::leveling< attribute::height<I> >(input, nbh, lambda);
+
+ trace::exiting("morpho::opening::height");
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho::opening
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_OPENING_HEIGHT_HH
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-02-28 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Create opening and closing morpho subdir and move opening and.
* mln/morpho/algebraic_filter.hh: Add precondition and test.
* mln/morpho/closing/algebraic.hh: New.
* mln/morpho/closing_algebraic.hh: Remove.
* mln/morpho/leveling_filter.hh: Add precondition and test.
* mln/morpho/opening/algebraic.hh: New.
* mln/morpho/opening_algebraic.hh: Remove.
* tests/morpho/closing/algebraic.cc: New.
* tests/morpho/closing/area.cc: New.
* tests/morpho/closing/height.cc: New.
* tests/morpho/closing/volume.cc: New.
* tests/morpho/closing: New.
* tests/morpho/closing_algebraic.cc: Remove.
* tests/morpho/closing_area.cc: Remove.
* tests/morpho/closing_height.cc: Remove.
* tests/morpho/closing_volume.cc: Remove.
* tests/morpho/opening/area.cc: New.
* tests/morpho/opening/height.cc: New.
* tests/morpho/opening/volume.cc: New.
* tests/morpho/opening: New.
* tests/morpho/opening_area.cc: Remove.
* tests/morpho/opening_height.cc: Remove.
* tests/morpho/opening_volume.cc: Remove.
---
mln/morpho/algebraic_filter.hh | 29 ++++++++++--
mln/morpho/closing/algebraic.hh | 86 ++++++++++++++++++++++++++++++++++++++
mln/morpho/leveling_filter.hh | 24 ++++++++++
mln/morpho/opening/algebraic.hh | 86 ++++++++++++++++++++++++++++++++++++++
tests/morpho/closing/algebraic.cc | 67 +++++++++++++++++++++++++++++
tests/morpho/closing/area.cc | 54 +++++++++++++++++++++++
tests/morpho/closing/height.cc | 52 ++++++++++++++++++++++
tests/morpho/closing/volume.cc | 60 ++++++++++++++++++++++++++
tests/morpho/opening/area.cc | 56 ++++++++++++++++++++++++
tests/morpho/opening/height.cc | 54 +++++++++++++++++++++++
tests/morpho/opening/volume.cc | 54 +++++++++++++++++++++++
11 files changed, 616 insertions(+), 6 deletions(-)
Index: trunk/milena/tests/morpho/closing_volume.cc (deleted)
===================================================================
Index: trunk/milena/tests/morpho/closing_area.cc (deleted)
===================================================================
Index: trunk/milena/tests/morpho/closing_height.cc (deleted)
===================================================================
Index: trunk/milena/tests/morpho/opening_volume.cc (deleted)
===================================================================
Index: trunk/milena/tests/morpho/opening_area.cc (deleted)
===================================================================
Index: trunk/milena/tests/morpho/opening_height.cc (deleted)
===================================================================
Index: trunk/milena/tests/morpho/closing_algebraic.cc (deleted)
===================================================================
Index: trunk/milena/tests/morpho/closing/volume.cc
===================================================================
--- trunk/milena/tests/morpho/closing/volume.cc (revision 0)
+++ trunk/milena/tests/morpho/closing/volume.cc (revision 3437)
@@ -0,0 +1,60 @@
+// 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_volume.cc
+///
+/// Test on mln::morpho::closing_volume.
+
+#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_volume.hh>
+#include <mln/morpho/attribute/volume.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");
+ io::pgm::save(morpho::closing_volume(lena, c4(), 10000),
+ "ref.pgm");
+
+ typedef morpho::attribute::volume<I> A;
+ io::pgm::save(morpho::closing_attribute<A>(lena, c4(), 10000),
+ "out.pgm");
+}
Index: trunk/milena/tests/morpho/closing/area.cc
===================================================================
--- trunk/milena/tests/morpho/closing/area.cc (revision 0)
+++ trunk/milena/tests/morpho/closing/area.cc (revision 3437)
@@ -0,0 +1,54 @@
+// Copyright (C) 2007, 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/closing_area.cc
+///
+/// Test on mln::morpho::closing_area.
+
+#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_area.hh>
+
+#include "tests/data.hh"
+
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<int_u8> lena;
+ io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ io::pgm::save(morpho::closing_area(lena, c4(), 510), "out.pgm");
+}
Index: trunk/milena/tests/morpho/closing/height.cc
===================================================================
--- trunk/milena/tests/morpho/closing/height.cc (revision 0)
+++ trunk/milena/tests/morpho/closing/height.cc (revision 3437)
@@ -0,0 +1,52 @@
+// Copyright (C) 2007, 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/closing_height.cc
+///
+/// Test on mln::morpho::closing_height.
+
+#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_height.hh>
+
+#include "tests/data.hh"
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<int_u8> lena;
+ io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ io::pgm::save(morpho::closing_height(lena, c4(), 20), "out.pgm");
+}
Index: trunk/milena/tests/morpho/closing/algebraic.cc
===================================================================
--- trunk/milena/tests/morpho/closing/algebraic.cc (revision 0)
+++ trunk/milena/tests/morpho/closing/algebraic.cc (revision 3437)
@@ -0,0 +1,67 @@
+// Copyright (C) 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_algebraic.cc
+///
+/// Test on mln::morpho::closing_algebraic.
+
+#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_algebraic.hh>
+#include <mln/morpho/attribute/card.hh>
+#include <mln/accu/count.hh>
+
+#include "tests/data.hh"
+
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ trace::quiet = false;
+
+ typedef image2d<int_u8> I;
+ I lena;
+ io::pgm::load(lena, MLN_IMG_DIR "/tiny.pgm");
+ {
+ accu::count<point2d> a;
+ io::pgm::save(morpho::closing_algebraic(lena, c4(), a, 10),
+ "ref.pgm");
+ }
+ {
+ morpho::attribute::card<I> a;
+ io::pgm::save(morpho::closing_algebraic(lena, c4(), a, 10),
+ "out.pgm");
+ }
+}
Property changes on: trunk/milena/tests/morpho/closing/algebraic.cc
___________________________________________________________________
Name: svn:mergeinfo
+
Index: trunk/milena/tests/morpho/opening/volume.cc
===================================================================
--- trunk/milena/tests/morpho/opening/volume.cc (revision 0)
+++ trunk/milena/tests/morpho/opening/volume.cc (revision 3437)
@@ -0,0 +1,54 @@
+// Copyright (C) 2007, 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/opening_volume.cc
+///
+/// Test on mln::morpho::opening_volume.
+
+#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_volume.hh>
+
+#include "tests/data.hh"
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<int_u8> lena;
+ io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ image2d<int_u8> out(lena.domain());
+
+ out = morpho::opening_volume(lena, c4(), 10000);
+ io::pgm::save(out, "out.pgm");
+}
Index: trunk/milena/tests/morpho/opening/area.cc
===================================================================
--- trunk/milena/tests/morpho/opening/area.cc (revision 0)
+++ trunk/milena/tests/morpho/opening/area.cc (revision 3437)
@@ -0,0 +1,56 @@
+// Copyright (C) 2007, 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/opening_area.cc
+///
+/// Test on mln::morpho::opening_area.
+
+#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_area.hh>
+
+#include "tests/data.hh"
+
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<int_u8> lena;
+ io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ image2d<int_u8> out(lena.domain());
+
+ out = morpho::opening_area(lena, c4(), 510);
+ io::pgm::save(out, "out.pgm");
+}
Index: trunk/milena/tests/morpho/opening/height.cc
===================================================================
--- trunk/milena/tests/morpho/opening/height.cc (revision 0)
+++ trunk/milena/tests/morpho/opening/height.cc (revision 3437)
@@ -0,0 +1,54 @@
+// Copyright (C) 2007, 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/opening_height.cc
+///
+/// Test on mln::morpho::opening_height.
+
+#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_height.hh>
+
+#include "tests/data.hh"
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<int_u8> lena;
+ io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ image2d<int_u8> out(lena.domain());
+
+ out = morpho::opening_height(lena, c4(), 20);
+ io::pgm::save(out, "out.pgm");
+}
Index: trunk/milena/mln/morpho/closing_algebraic.hh (deleted)
===================================================================
Index: trunk/milena/mln/morpho/opening_algebraic.hh (deleted)
===================================================================
Index: trunk/milena/mln/morpho/closing/algebraic.hh
===================================================================
--- trunk/milena/mln/morpho/closing/algebraic.hh (revision 0)
+++ trunk/milena/mln/morpho/closing/algebraic.hh (revision 3437)
@@ -0,0 +1,86 @@
+// 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.
+
+#ifndef MLN_MORPHO_CLOSING_ALGEBRAIC_HH
+# define MLN_MORPHO_CLOSING_ALGEBRAIC_HH
+
+/// \file mln/morpho/closing/algebraic.hh
+///
+/// Morphological algebraic closing.
+
+# include <mln/morpho/includes.hh>
+# include <mln/morpho/algebraic_filter.hh>
+
+
+namespace mln {
+ namespace morpho {
+ namespace closing {
+
+ /// Morphological algebraic closing.
+ template <typename I, typename N, typename A>
+ mln_concrete(I)
+ algebraic(const Image<I>& input, const Neighborhood<N>& nbh,
+ const Accumulator<A>& accu, const mln_result(A)& lambda);
+
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename I, typename N, typename A>
+ inline
+ mln_concrete(I)
+ algebraic(const Image<I>& input, const Neighborhood<N>& nbh,
+ const Accumulator<A>& accu, const mln_result(A)& lambda)
+ {
+ trace::entering("morpho::closing::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_concrete(I) output;
+ output = algebraic_filter(input, nbh, accu, lambda,
+ /* increasing = */ true);
+
+ mln_postcondition(output >= input);
+
+ trace::exiting("morpho::closing::algebraic");
+ return output;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho::closing
+ } // end of namespace mln::morpho
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_CLOSING_ALGEBRAIC_HH
Property changes on: trunk/milena/mln/morpho/closing/algebraic.hh
___________________________________________________________________
Name: svn:mergeinfo
+
Index: trunk/milena/mln/morpho/opening/algebraic.hh
===================================================================
--- trunk/milena/mln/morpho/opening/algebraic.hh (revision 0)
+++ trunk/milena/mln/morpho/opening/algebraic.hh (revision 3437)
@@ -0,0 +1,86 @@
+// 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.
+
+#ifndef MLN_MORPHO_OPENING_ALGEBRAIC_HH
+# define MLN_MORPHO_OPENING_ALGEBRAIC_HH
+
+/// \file mln/morpho/opening/algebraic.hh
+///
+/// Morphological algebraic opening.
+
+# include <mln/morpho/includes.hh>
+# include <mln/morpho/algebraic_filter.hh>
+
+
+namespace mln {
+ namespace morpho {
+ namespace opening {
+
+ /// Morphological algebraic opening.
+ template <typename I, typename N, typename A>
+ mln_concrete(I)
+ algebraic(const Image<I>& input, const Neighborhood<N>& nbh,
+ const Accumulator<A>& accu, const mln_result(A)& lambda);
+
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename I, typename N, typename A>
+ inline
+ mln_concrete(I)
+ algebraic(const Image<I>& input, const Neighborhood<N>& nbh,
+ const Accumulator<A>& accu, const mln_result(A)& lambda)
+ {
+ 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_concrete(I) output;
+ output = algebraic_filter(input, nbh, accu, lambda,
+ /* increasing = */ false);
+
+ mln_postcondition(output <= input);
+
+ trace::exiting("morpho::opening::algebraic");
+ return output;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho::opening
+ } // end of namespace mln::morpho
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_OPENING_ALGEBRAIC_HH
Property changes on: trunk/milena/mln/morpho/opening/algebraic.hh
___________________________________________________________________
Name: svn:mergeinfo
+
Index: trunk/milena/mln/morpho/leveling_filter.hh
===================================================================
--- trunk/milena/mln/morpho/leveling_filter.hh (revision 3436)
+++ trunk/milena/mln/morpho/leveling_filter.hh (revision 3437)
@@ -53,15 +53,37 @@
const Neighborhood<N>& nbh,
const Accumulator<A>& a,
const typename A::result& lambda,
+ bool increasing);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename N, typename A>
+ mln_concrete(I)
+ leveling_filter(const Image<I>& input,
+ const Neighborhood<N>& nbh,
+ const Accumulator<A>& a,
+ const typename A::result& lambda,
bool increasing)
{
+ trace::entering("morpho::opening::leveling_filter");
+
+ mln_precondition(exact(input).is_valid());
+
mlc_or(mlc_equal(mln_trait_accumulator_when_pix(A),
trait::accumulator::when_pix::use_pix),
mlc_equal(mln_trait_accumulator_when_pix(A),
trait::accumulator::when_pix::use_v))::check();
- return canvas::morpho::internal::attribute_filter_dispatch(input, nbh, a, lambda, increasing);
+ mln_concrete(I) output;
+ output = canvas::morpho::internal::attribute_filter_dispatch(input, nbh, a, lambda, increasing);
+
+ trace::exiting("morpho::opening::leveling_filter");
+
+ return output;
}
+
+# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::morpho
} // end of namespace mln
Index: trunk/milena/mln/morpho/algebraic_filter.hh
===================================================================
--- trunk/milena/mln/morpho/algebraic_filter.hh (revision 3436)
+++ trunk/milena/mln/morpho/algebraic_filter.hh (revision 3437)
@@ -28,9 +28,9 @@
#ifndef MLN_MORPHO_ALGEBRAIC_FILTER_HH_
# define MLN_MORPHO_ALGEBRAIC_FILTER_HH_
-/// \file mln/morpho/leveling_filter.hh
+/// \file mln/morpho/algebraic_filter.hh
///
-/// Leveling filter calls attribute canvas.
+/// Alegebraic filter calls attribute canvas.
# include <mln/core/concept/image.hh>
@@ -53,19 +53,38 @@
const Neighborhood<N>& nbh,
const Accumulator<A>& a,
const typename A::result& lambda,
+ bool increasing);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename N, typename A>
+ mln_concrete(I)
+ algebraic_filter(const Image<I>& input,
+ const Neighborhood<N>& nbh,
+ const Accumulator<A>& a,
+ const typename A::result& lambda,
bool increasing)
{
+ trace::entering("morpho::opening::algebraic_filter");
+
+ mln_precondition(exact(input).is_valid());
+
mlc_or(mlc_equal(mln_trait_accumulator_when_pix(A),
trait::accumulator::when_pix::use_none),
mlc_equal(mln_trait_accumulator_when_pix(A),
trait::accumulator::when_pix::use_p))::check();
- return canvas::morpho::internal::attribute_filter_dispatch(input, nbh, a, lambda, increasing);
+ mln_concrete(I) output;
+ output = canvas::morpho::internal::attribute_filter_dispatch(input, nbh, a, lambda, increasing);
+
+ trace::exiting("morpho::opening::algebraic_filter");
+
+ return output;
}
+# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::morpho
} // end of namespace mln
-
-
#endif /* !MLN_MORPHO_ALGEBRAIC_FILTER_HH_ */
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-02-28 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Add height attribute, and implement untake and set_value method.
* mln/morpho/attribute/height.hh: New.
* mln/morpho/attribute/sum.hh: Implements untake and set_value
methods.
* mln/morpho/attribute/volume.hh: s/level_/cur_level_.
* tests/morpho/attribute/Makefile.am:
* tests/morpho/attribute/height.cc: Add height test file.
---
mln/morpho/attribute/height.hh | 217 +++++++++++++++++++++++++++++++++++++
mln/morpho/attribute/sum.hh | 45 +++++++
mln/morpho/attribute/volume.hh | 12 +-
sandbox/edwin/tree/tree.cc | 33 +++--
tests/morpho/attribute/Makefile.am | 4
tests/morpho/attribute/height.cc | 62 ++++++++++
6 files changed, 354 insertions(+), 19 deletions(-)
Index: trunk/milena/tests/morpho/attribute/Makefile.am
===================================================================
--- trunk/milena/tests/morpho/attribute/Makefile.am (revision 3435)
+++ trunk/milena/tests/morpho/attribute/Makefile.am (revision 3436)
@@ -5,10 +5,12 @@
check_PROGRAMS = \
card \
sum \
- volume
+ volume \
+ height
card_SOURCES = card.cc
sum_SOURCES = sum.cc
volume_SOURCES = volume.cc
+height_SOURCES = height.cc
TESTS = $(check_PROGRAMS)
Index: trunk/milena/tests/morpho/attribute/height.cc
===================================================================
--- trunk/milena/tests/morpho/attribute/height.cc (revision 0)
+++ trunk/milena/tests/morpho/attribute/height.cc (revision 3436)
@@ -0,0 +1,62 @@
+// Copyright (C) 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/attribute/height.cc
+///
+/// Test on mln::morpho::attribute::height.
+#include <mln/core/image/image1d.hh>
+#include <mln/morpho/attribute/height.hh>
+#include <iostream>
+
+int main()
+{
+ using namespace mln;
+
+ int t[5] = {3, 3, 8, 9, 10};
+
+ typedef morpho::attribute::height< image1d<int> > A;
+
+ A accu;
+ for (int i = 0; i < 5; i++)
+ accu.take(t[i]);
+
+ mln_assertion(accu.to_result() == 7);
+
+
+ A accu2;
+ accu = A();
+ for (int i = 4; i >= 0; i--)
+ {
+ accu.take(t[i] + 2);
+ accu2.take(t[i] - 2);
+ }
+ mln_assertion(accu.to_result() == 7);
+ mln_assertion(accu2.to_result() == 7);
+ accu.take(accu2);
+ mln_assertion(accu.to_result() == 11);
+}
+
Index: trunk/milena/mln/morpho/attribute/sum.hh
===================================================================
--- trunk/milena/mln/morpho/attribute/sum.hh (revision 3435)
+++ trunk/milena/mln/morpho/attribute/sum.hh (revision 3436)
@@ -61,8 +61,8 @@
template <typename I, typename S>
struct accumulator_< morpho::attribute::sum<I,S> >
{
- typedef accumulator::has_untake::no has_untake;
- typedef accumulator::has_set_value::no has_set_value;
+ typedef accumulator::has_untake::yes has_untake;
+ typedef accumulator::has_set_value::yes has_set_value;
typedef accumulator::has_stop::no has_stop;
typedef accumulator::when_pix::use_v when_pix;
};
@@ -107,6 +107,15 @@
/// Return always true.
bool is_valid() const;
+ /// Untake a value from the accumulator.
+ void untake(const argument& v);
+ void untake(const util::pix<I>& px);
+
+ /// Set the return value of the accumalator.
+ void set_value(const argument& v);
+ void set_value(const util::pix<I>& px);
+
+
protected:
/// The sum value.
@@ -178,6 +187,38 @@
template <typename I, typename S>
inline
+ void
+ sum<I,S>::untake(const argument& v)
+ {
+ s_ -= v;
+ }
+
+ template <typename I, typename S>
+ inline
+ void
+ sum<I,S>::untake(const util::pix<I>& px)
+ {
+ untake(px.v());
+ }
+
+ template <typename I, typename S>
+ inline
+ void
+ sum<I,S>::set_value(const argument& v)
+ {
+ s_ = v;
+ }
+
+ template <typename I, typename S>
+ inline
+ void
+ sum<I,S>::set_value(const util::pix<I>& px)
+ {
+ set_value(px.v());
+ }
+
+ template <typename I, typename S>
+ inline
S
sum<I,S>::to_result() const
{
Index: trunk/milena/mln/morpho/attribute/volume.hh
===================================================================
--- trunk/milena/mln/morpho/attribute/volume.hh (revision 3435)
+++ trunk/milena/mln/morpho/attribute/volume.hh (revision 3436)
@@ -109,7 +109,7 @@
protected:
/// The current level.
- mln_value(I) level_;
+ mln_value(I) cur_level_;
/// The area of the component.
unsigned area_;
/// The volume of the component.
@@ -147,8 +147,8 @@
return;
}
++area_;
- volume_ += 1 + math::diff_abs(v, level_);
- level_ = v;
+ volume_ += 1 + math::diff_abs(v, cur_level_);
+ cur_level_ = v;
}
template <typename I>
@@ -169,8 +169,8 @@
area_ += other.area_;
volume_ +=
other.volume_ +
- other.area_ * math::diff_abs(other.level_, level_);
- // level_ do not change.
+ other.area_ * math::diff_abs(other.cur_level_, cur_level_);
+ // cur_level_ do not change.
}
template <typename I>
@@ -178,7 +178,7 @@
void
volume<I>::take_as_init(const mln_value(I)& v)
{
- level_ = v;
+ cur_level_ = v;
area_ = 1;
volume_ = 1;
}
Index: trunk/milena/mln/morpho/attribute/height.hh
===================================================================
--- trunk/milena/mln/morpho/attribute/height.hh (revision 0)
+++ trunk/milena/mln/morpho/attribute/height.hh (revision 3436)
@@ -0,0 +1,217 @@
+// Copyright (C) 2007, 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.
+
+#ifndef MLN_MORPHO_ATTRIBUTE_HEIGHT_HH
+# define MLN_MORPHO_ATTRIBUTE_HEIGHT_HH
+
+/// \file mln/morpho/attribute/height.hh
+/// Define an accumulator that computes the height of a
+/// component through one of its pixels.
+
+# include <mln/accu/internal/base.hh>
+
+# include <mln/util/pix.hh>
+# include <mln/math/diff_abs.hh>
+# include <mln/math/min.hh>
+# include <mln/math/max.hh>
+
+
+namespace mln {
+
+ // Forward declaration.
+ namespace morpho {
+ namespace attribute {
+ template <typename I> class volume;
+ }
+ }
+
+
+ // Traits.
+
+ namespace trait {
+
+ template <typename I>
+ struct accumulator_< morpho::attribute::volume<I> >
+ {
+ typedef accumulator::has_untake::no has_untake;
+ typedef accumulator::has_set_value::no has_set_value;
+ typedef accumulator::has_stop::no has_stop;
+ typedef accumulator::when_pix::use_v when_pix;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace morpho {
+ namespace attribute {
+
+ /// Height accumulator class.
+ ///
+ /// The parameter \p I is the image type on which the accumulator
+ /// of pixels is built.
+ template <typename I>
+ struct height
+ : public mln::accu::internal::base< unsigned , height<I> >
+ {
+ typedef mln_value(I) argument;
+
+ height();
+
+ /// Manipulators.
+ /// \{
+ void init();
+ void take(const mln_value(I)& v);
+ void take(const util::pix<I>& v);
+ void take(const height<I>& other);
+ void take_as_init(const mln_value(I)& v);
+ void take_as_init(const util::pix<I>& px);
+ /// \}
+
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
+ /// Get the value of the accumulator.
+ unsigned to_result() const;
+
+
+ protected:
+ /// The reference level in the component.
+ unsigned ref_;
+ /// The current level in the component.
+ unsigned cur_;
+ /// Mark of initialization
+ bool initialized_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ inline
+ height<I>::height()
+ : initialized_ (false)
+ {
+ }
+
+ template <typename I>
+ inline
+ void
+ height<I>::init()
+ {
+ mln_invariant(0);
+ }
+
+ template <typename I>
+ inline
+ void
+ height<I>::take(const mln_value(I)& v)
+ {
+ if (!is_valid ())
+ {
+ take_as_init(v);
+ }
+ cur_ = v;
+ }
+
+ template <typename I>
+ inline
+ void
+ height<I>::take(const util::pix<I>& px)
+ {
+ take(px.v());
+ }
+
+ template <typename I>
+ inline
+ void
+ height<I>::take(const height<I>& other)
+ {
+ mln_invariant(ref_ < cur_ xor other.ref_ > other.cur_);
+ if (!is_valid())
+ {
+ ref_ = other.ref_;
+ cur_ = other.cur_;
+ }
+ else if (ref_ < cur_)
+ {
+ // Values are increasing.
+ ref_ = math::min(ref_, other.ref_);
+ cur_ = math::max(cur_, other.cur_);
+ }
+ else
+ {
+ // Values are decreasing.
+ ref_ = math::max(ref_, other.ref_);
+ cur_ = math::min(cur_, other.cur_);
+ }
+ }
+
+ template <typename I>
+ inline
+ void
+ height<I>::take_as_init(const mln_value(I)& v)
+ {
+ cur_ = ref_ = v;
+ initialized_ = true;
+ }
+
+ template <typename I>
+ inline
+ void
+ height<I>::take_as_init(const util::pix<I>& px)
+ {
+ take_as_init(px.v());
+ }
+
+
+ template <typename I>
+ inline
+ unsigned
+ height<I>::to_result() const
+ {
+ mln_invariant(initialized_);
+ if (is_valid())
+ return math::diff_abs(ref_, cur_);
+ }
+
+ template <typename I>
+ inline
+ bool
+ height<I>::is_valid() const
+ {
+ return initialized_;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::morpho::attribute
+ } // end of namespace mln::morpho
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_ATTRIBUTE_HEIGHT_HH
Index: trunk/milena/sandbox/edwin/tree/tree.cc
===================================================================
--- trunk/milena/sandbox/edwin/tree/tree.cc (revision 3435)
+++ trunk/milena/sandbox/edwin/tree/tree.cc (revision 3436)
@@ -57,6 +57,7 @@
} // mln
+using namespace mln;
int echo = 0;
template <typename I, typename A>
@@ -64,7 +65,6 @@
void
create_tree_and_compute(Image<I>& f_, Accumulator<A> a_, float lambda, float lambda2 = mln_max(float))
{
- using namespace mln;
using value::int_u8;
I f = exact(f_);
@@ -100,7 +100,6 @@
int main(int argc, char* argv[])
{
- using namespace mln;
using value::int_u8;
mln_VAR(nbh, c4());
@@ -127,21 +126,35 @@
IM img(6);
morpho::attribute::volume<IM> accu;
img.element(0) = 50;
- img.element(1) = 40;
- img.element(2) = 20;
- img.element(3) = 20;
- img.element(4) = 40;
- img.element(5) = 50;
+ img.element(1) = 50;
+ img.element(2) = 40;
+ img.element(3) = 40;
+ img.element(4) = 20;
+ img.element(5) = 20;
mln_piter_(image1d<int>) p(img.domain());
- for_all(p)
- accu.take(img(p));
+ int tab[6] = { 50, 50, 40, 40, 20, 20 };
+ for (int i = 0; i < 6; i++)
+ {
+ accu.take(tab[i]);
+ std::cout << "(" << tab[i] << "," << accu.to_result() << "):";
+ }
std::cout << "Volume:" << accu.to_result() << std::endl;
+
+ accu.init ();
+ for (int i = 5; i >= 0; i--)
+ {
+ accu.take(tab[i]);
+ std::cout << "(" << tab[i] << "," << accu.to_result() << "):";
+ }
+ std::cout << "Volume:" << accu.to_result() << std::endl;
+
+
//create_tree_and_compute(img, morpho::attribute::volume<I2>());
//
- create_tree_and_compute(f, morpho::attribute::coccupation<I>(), lambda1, lambda2);
+ create_tree_and_compute(f, morpho::attribute::occupation<I>(), lambda1, lambda2);
}
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-02-28 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Clean and separate connected (leveling/algebraic) filters.
* mln/canvas/morpho/attribute_filter.hh: Move
algebraic/leveling facade from attribute filter and change dispatch.
* mln/canvas/morpho/connected_filter.hh: Remove.
* mln/morpho/algebraic_filter.hh: Facade for algebraic filter.
* mln/morpho/closing: New.
* mln/morpho/leveling_filter.hh: Facade for leveling filter.
* mln/morpho/opening: New.
* sandbox/edwin/tree/propagate.hh
* sandbox/edwin/tree/tree.cc: Correct some bugs.
* tests/canvas/morpho/attribute_filter.cc: Test file for
attribute filters.
* tests/canvas/morpho/connected_filter.cc: Remove.
---
mln/canvas/morpho/attribute_filter.hh | 461 ++++++++++++++++++++++++++++++++
mln/morpho/algebraic_filter.hh | 71 ++++
mln/morpho/leveling_filter.hh | 69 ++++
sandbox/edwin/tree/propagate.hh | 4
sandbox/edwin/tree/tree.cc | 17 -
tests/canvas/morpho/attribute_filter.cc | 108 +++++++
6 files changed, 721 insertions(+), 9 deletions(-)
Index: trunk/milena/tests/canvas/morpho/connected_filter.cc (deleted)
===================================================================
Index: trunk/milena/tests/canvas/morpho/attribute_filter.cc
===================================================================
--- trunk/milena/tests/canvas/morpho/attribute_filter.cc (revision 0)
+++ trunk/milena/tests/canvas/morpho/attribute_filter.cc (revision 3435)
@@ -0,0 +1,108 @@
+// 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.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/io/pgm/all.hh>
+#include <mln/util/timer.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/morpho/attribute/volume.hh>
+#include <mln/morpho/attribute/card.hh>
+#include <mln/morpho/leveling_filter.hh>
+#include <mln/morpho/algebraic_filter.hh>
+
+#include "tests/data.hh"
+
+int main(int argc, char** argv)
+{
+ using namespace mln;
+ using value::int_u8;
+
+ if (argc != 2)
+ {
+ std::cout << "Usage: ./connected_filter lambda" << std::endl;
+ return 0;
+ }
+
+ typedef mln::image2d<int_u8> I;
+ I lena;
+
+ float elapsed;
+ mln::util::timer chrono;
+ mln::morpho::attribute::volume<I> c;
+ mln::morpho::attribute::card<I> c2;
+ int lambda = atoi(argv[1]);
+
+ mln::io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
+ I out;
+
+ std::cout << "Test with card attribute:" << std::endl;
+ chrono.start();
+ out = mln::canvas::morpho::attribute_filter(lena, c4(), c2, lambda, true);
+ elapsed = chrono.stop();
+ std::cout << "(Full auto) " << elapsed << "s" << std::endl;
+ mln::io::pgm::save(out, "alg_auto.pgm");
+
+ chrono.start();
+ out = mln::morpho::algebraic_filter(lena, c4(), c2, lambda, true);
+ elapsed = chrono.stop();
+ std::cout << "(Algebraic Auto) " << elapsed << "s" << std::endl;
+ mln::io::pgm::save(out, "alg_algebraic.pgm");
+
+ chrono.start();
+ out = mln::canvas::morpho::internal::attribute_filter_dispatch(metal::false_(), lena, c4(), c2, lambda, true);
+ elapsed = chrono.stop();
+ std::cout << "(Force Slow) " << elapsed << "s" << std::endl;
+ mln::io::pgm::save(out, "alg_slow.pgm");
+
+ // Try force algebraic dispatch with wrong accu (volume).
+ // mln::morpho::algebraic_filter(lena, c4(), c, lambda, true);
+
+ std::cout << "Test with volume attribute:" << std::endl;
+ chrono.start();
+ out = mln::canvas::morpho::attribute_filter(lena, c4(), c, lambda, true);
+ elapsed = chrono.stop();
+ std::cout << "(Full auto) " << elapsed << "s" << std::endl;
+ mln::io::pgm::save(out, "lev_auto.pgm");
+
+ chrono.start();
+ out = mln::morpho::leveling_filter(lena, c4(), c, lambda, true);
+ elapsed = chrono.stop();
+ std::cout << "(Leveling Auto) " << elapsed << "s" << std::endl;
+ mln::io::pgm::save(out, "lev_leveling.pgm");
+
+ chrono.start();
+ out = mln::canvas::morpho::internal::attribute_filter_dispatch(metal::false_(), lena, c4(), c, lambda, true);
+ elapsed = chrono.stop();
+ std::cout << "(Force Slow) " << elapsed << "s" << std::endl;
+ mln::io::pgm::save(out, "lev_slow.pgm");
+
+ // Try force leveling dispatch with wrong accu (card).
+ // mln::morpho::leveling_filter(lena, c4(), c2, lambda, true);
+
+
+}
Index: trunk/milena/mln/morpho/leveling_filter.hh
===================================================================
--- trunk/milena/mln/morpho/leveling_filter.hh (revision 0)
+++ trunk/milena/mln/morpho/leveling_filter.hh (revision 3435)
@@ -0,0 +1,69 @@
+// 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.
+
+#ifndef MLN_MORPHO_LEVELING_FILTER_HH_
+# define MLN_MORPHO_LEVELING_FILTER_HH_
+
+/// \file mln/morpho/leveling_filter.hh
+///
+/// Leveling filter calls attribute canvas.
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/concept/accumulator.hh>
+
+# include <mln/trait/accumulators.hh>
+
+# include <mln/level/sort_psites.hh>
+# include <mln/level/sort_offsets.hh>
+
+# include <mln/canvas/morpho/attribute_filter.hh>
+
+namespace mln {
+ namespace morpho {
+
+ template <typename I, typename N, typename A>
+ mln_concrete(I)
+ leveling_filter(const Image<I>& input,
+ const Neighborhood<N>& nbh,
+ const Accumulator<A>& a,
+ const typename A::result& lambda,
+ bool increasing)
+ {
+ mlc_or(mlc_equal(mln_trait_accumulator_when_pix(A),
+ trait::accumulator::when_pix::use_pix),
+ mlc_equal(mln_trait_accumulator_when_pix(A),
+ trait::accumulator::when_pix::use_v))::check();
+
+ return canvas::morpho::internal::attribute_filter_dispatch(input, nbh, a, lambda, increasing);
+ }
+ } // end of namespace mln::morpho
+} // end of namespace mln
+
+
+#endif /* !MLN_MORPHO_LEVELING_FILTER_HH_ */
Index: trunk/milena/mln/morpho/algebraic_filter.hh
===================================================================
--- trunk/milena/mln/morpho/algebraic_filter.hh (revision 0)
+++ trunk/milena/mln/morpho/algebraic_filter.hh (revision 3435)
@@ -0,0 +1,71 @@
+// 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.
+#ifndef MLN_MORPHO_ALGEBRAIC_FILTER_HH_
+# define MLN_MORPHO_ALGEBRAIC_FILTER_HH_
+
+/// \file mln/morpho/leveling_filter.hh
+///
+/// Leveling filter calls attribute canvas.
+
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/concept/accumulator.hh>
+
+# include <mln/trait/accumulators.hh>
+
+# include <mln/level/sort_psites.hh>
+# include <mln/level/sort_offsets.hh>
+
+# include <mln/canvas/morpho/attribute_filter.hh>
+
+namespace mln {
+ namespace morpho {
+
+ template <typename I, typename N, typename A>
+ mln_concrete(I)
+ algebraic_filter(const Image<I>& input,
+ const Neighborhood<N>& nbh,
+ const Accumulator<A>& a,
+ const typename A::result& lambda,
+ bool increasing)
+ {
+ mlc_or(mlc_equal(mln_trait_accumulator_when_pix(A),
+ trait::accumulator::when_pix::use_none),
+ mlc_equal(mln_trait_accumulator_when_pix(A),
+ trait::accumulator::when_pix::use_p))::check();
+
+ return canvas::morpho::internal::attribute_filter_dispatch(input, nbh, a, lambda, increasing);
+ }
+
+ } // end of namespace mln::morpho
+} // end of namespace mln
+
+
+
+#endif /* !MLN_MORPHO_ALGEBRAIC_FILTER_HH_ */
Index: trunk/milena/mln/canvas/morpho/connected_filter.hh (deleted)
===================================================================
Index: trunk/milena/mln/canvas/morpho/attribute_filter.hh
===================================================================
--- trunk/milena/mln/canvas/morpho/attribute_filter.hh (revision 0)
+++ trunk/milena/mln/canvas/morpho/attribute_filter.hh (revision 3435)
@@ -0,0 +1,461 @@
+// 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.
+
+#ifndef MLN_CANVAS_MORPHO_ATTRIBUTE_FILTER_HH
+# define MLN_CANVAS_MORPHO_ATTRIBUTE_FILTER_HH
+
+/// \file mln/canvas/morpho/attribute_filter.hh
+///
+/// Connected filters dispatch (algebraic & leveling filters).
+
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/concept/accumulator.hh>
+
+# include <mln/trait/accumulators.hh>
+
+# include <mln/util/pix.hh>
+
+# include <mln/data/fill.hh>
+
+namespace mln {
+ namespace canvas {
+ namespace morpho {
+
+ // Facade Fwd Declaration
+ template <typename I, typename N, typename A>
+ mln_concrete(I)
+ attribute_filter(const Image<I>& input, const Neighborhood<N>& nbh,
+ const Accumulator<A>& a, const typename A::result& lambda,
+ bool increasing);
+
+ template <typename I, typename N, typename A>
+ mln_concrete(I)
+ algebraic_filter(const Image<I>& input, const Neighborhood<N>& nbh,
+ const Accumulator<A>& a, const typename A::result& lambda,
+ bool increasing);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl {
+
+ template <typename A, typename I>
+ void take_as_init_fastest (trait::accumulator::when_pix::use_none, A& accu,
+ const I& input, const unsigned p)
+ {
+ (void)input;
+ (void)p;
+ accu.take_as_init ();
+ }
+
+ template <typename A, typename I, typename P>
+ void take_as_init (trait::accumulator::when_pix::use_p, A& accu,
+ const I& input, const P& p)
+ {
+ (void)input;
+ accu.take_as_init (p);
+ }
+
+ template <typename A, typename I, typename P>
+ void take_as_init (trait::accumulator::when_pix::use_none, A& accu,
+ const I& input, const P& p)
+ {
+ (void)input;
+ accu.take_as_init (p);
+ }
+
+ template <typename A, typename I, typename P>
+ void take_as_init (trait::accumulator::when_pix::use_pix, A& accu,
+ const I& input, const P& p)
+ {
+ accu.take_as_init (make::pix(input, p));
+ }
+
+ template <typename A, typename I, typename P>
+ void take_as_init (trait::accumulator::when_pix::use_v, A& accu,
+ const I& input, const P& p)
+ {
+ accu.take_as_init (make::pix(input, p));
+ }
+
+ template <typename A, typename I>
+ void take_as_init_fastest (trait::accumulator::when_pix::use_v, A& accu,
+ const I& input, const unsigned p)
+ {
+ accu.take_as_init (input.element (p));
+ }
+
+
+ template <typename A, typename I, typename P>
+ void take_as_init (A& accu, const I& input, const P& p)
+ {
+ take_as_init (mln_trait_accumulator_when_pix(A)(), accu, input, p);
+ }
+
+ template <typename A, typename I, typename P>
+ void take_as_init_fastest (A& accu, const I& input, const P& p)
+ {
+ take_as_init_fastest (mln_trait_accumulator_when_pix(A)(), accu, input, p);
+ }
+
+
+ namespace generic {
+
+
+ ////////////////////////
+ /// Generic version. ///
+ ////////////////////////
+
+
+ template <typename I>
+ static inline
+ mln_psite(I)
+ find_root(I& parent, const mln_psite(I) & x)
+ {
+ if (parent(x) == x)
+ return x;
+ else
+ return parent(x) = find_root(parent, parent(x));
+ }
+
+ template <typename I, typename N, typename S, typename A>
+ mln_concrete(I)
+ attribute_filter (const Image<I>& input_,
+ const Neighborhood<N>& nbh_,
+ const Site_Set<S>& s_,
+ const Accumulator<A>& a_,
+ const typename A::result& lambda)
+ {
+ trace::entering("canvas::morpho::impl::generic::attribute_filter");
+ // FIXME: Test?!
+
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+ const S& s = exact(s_);
+ (void)a_; // To avoid warning at compilation
+
+ mln_concrete(I) output;
+ initialize(output, input);
+
+ // Local type.
+ typedef mln_psite(I) P;
+
+
+ // Auxiliary data.
+ mln_ch_value(I, bool) deja_vu;
+ mln_ch_value(I, bool) activity;
+ mln_ch_value(I, P) parent;
+ mln_ch_value(I, A) data;
+
+ // Initialization.
+ {
+ initialize(deja_vu, input);
+ data::fill(deja_vu, false);
+ initialize(activity, input);
+ data::fill(activity, true);
+ initialize(parent, input);
+ initialize(data, input);
+ //a.init(); // init required.
+ }
+
+ // First pass.
+ {
+ mln_fwd_piter(S) p(s); // s required.
+ mln_niter(N) n(nbh, p);
+
+ for_all(p)
+ {
+ // Make set.
+ {
+ parent(p) = p;
+
+ // Check accumulator trait to handle argument type (Pix or Site).
+ take_as_init (data(p), input, p);
+ }
+
+ for_all(n)
+ if (input.domain().has(n) && deja_vu(n))
+ {
+ //do_union(n, p);
+ P r = find_root(parent, n);
+ if (r != p)
+ {
+ if (input(r) == input(p) || (activity(r) && (data(r) < lambda))) // Equiv(r, p)
+ // Either a flat zone or the component of r is still growing.
+ {
+ /* FIXME: Same remark as above concerning the
+ initialization of data(p); instead of
+
+ data(p).take(data(r));
+
+ we should (or could) have
+
+ unite_data(p, r);
+
+ so as to keep the generic aspect of this canvas
+ (as long as the set of acceptable types for the
+ template parameter A is not bound). */
+
+ data(p).take(data(r));
+ parent(r) = p;
+ if (activity(r) == false)
+ activity(p) = false;
+ }
+ else
+ {
+ activity(p) = false;
+ }
+ }
+ }
+ deja_vu(p) = true;
+ }
+ }
+
+ // Second pass.
+ {
+ mln_bkd_piter(S) p(s);
+ for_all(p)
+ if (parent(p) == p) // p is root.
+ output(p) = input(p);
+ else
+ output(p) = output(parent(p));
+ }
+
+ trace::exiting("canvas::morpho::impl::generic::attribute_filter");
+ return output;
+ }
+
+ } // end of namespace mln::canvas::morpho::impl::generic
+
+
+ ////////////////////////
+ /// Fastest version. ///
+ ////////////////////////
+
+ template <typename I>
+ inline
+ unsigned
+ find_root_fastest(I& parent, unsigned x)
+ {
+ if (parent.element(x) == x)
+ return x;
+ else
+ return parent.element(x) = find_root_fastest(parent, parent.element(x));
+ }
+
+ template <typename I, typename N, typename A>
+ mln_concrete(I)
+ attribute_filter_fastest(const Image<I>& input_,
+ const Neighborhood<N>& nbh_,
+ const util::array<unsigned>& s,
+ const Accumulator<A>& a_,
+ const typename A::result& lambda)
+ {
+ trace::entering("canvas::morpho::impl::attribute_filter_fastest");
+ // FIXME: Tests?
+
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+ (void)a_;
+
+ mln_concrete(I) output;
+ initialize(output, input);
+
+ // Local type.
+ typedef mln_psite(I) P;
+
+ // Auxiliary data.
+ mln_ch_value(I, bool) deja_vu;
+ mln_ch_value(I, bool) activity;
+ mln_ch_value(I, unsigned) parent;
+ mln_ch_value(I, A) data;
+
+ // Initialization.
+ {
+ initialize(deja_vu, input);
+ data::fill(deja_vu, false);
+ initialize(activity, input);
+ data::fill(activity, true);
+ initialize(parent, input);
+ data::fill(parent, 0);
+ initialize(data, input);
+ }
+
+ util::array<int> dp = offsets_wrt(input, nbh);
+ const unsigned n_nbhs = dp.nelements();
+ const unsigned n_points = s.nelements();
+
+ // First pass.
+ {
+ for (unsigned i = 0; i < n_points; ++i)
+ {
+ unsigned p = s[i]; // An offset.
+
+ // Make set.
+ parent.element(p) = p;
+
+ // Check accumulator trait to handle argument type (Value or None).
+ take_as_init_fastest (data.element(p), input, p);
+
+ for (unsigned j = 0; j < n_nbhs; ++j)
+ {
+ unsigned n = p + dp[j];
+ if (!deja_vu.element(n))
+ continue;
+
+ unsigned r = find_root_fastest(parent, n);
+ if (r != p)
+ {
+ if (input.element(r) == input.element(p)
+ || (activity.element(r)
+ && (data.element(r) < lambda)))
+ {
+ data.element(p).take(data.element(r));
+ parent.element(r) = p;
+ if (activity.element(r) == false)
+ activity.element(p) = false;
+ }
+ else
+ activity.element(p) = false;
+ }
+ }
+
+ deja_vu.element(p) = true;
+ }
+ }
+
+
+ // Second pass.
+ {
+ for (int i = n_points - 1; i >= 0 ; --i)
+ {
+ unsigned p = s[i];
+ if (parent.element(p) == p) // p is root.
+ output.element(p) = input.element(p);
+ else
+ output.element(p) = output.element(parent.element(p));
+ }
+ }
+
+ trace::exiting("canvas::morpho::impl::attribute_filter_fastest");
+ return output;
+ }
+ } // end of namespace mln::canvas::morpho::impl
+
+
+
+
+ // Dispatch.
+
+
+ namespace internal
+ {
+ // Dispatch to generic.
+ template <typename I, typename N, typename A>
+ inline
+ mln_concrete(I)
+ attribute_filter_dispatch(metal::false_,
+ const Image<I>& input,
+ const Neighborhood<N>& nbh,
+ const Accumulator<A>& a,
+ const typename A::result& lambda,
+ bool increasing)
+ {
+ p_array<mln_psite(I)> s = increasing ?
+ level::sort_psites_increasing(input) :
+ level::sort_psites_decreasing(input);
+
+ return impl::generic::attribute_filter(input, nbh, s, a, lambda);
+ }
+
+ // Dispatch to fastest.
+ template <typename I, typename N, typename A>
+ inline
+ mln_concrete(I)
+ attribute_filter_dispatch(metal::true_,
+ const Image<I>& input,
+ const Neighborhood<N>& nbh,
+ const Accumulator<A>& a,
+ const typename A::result& lambda,
+ bool increasing)
+ {
+ util::array<unsigned> s =
+ increasing ?
+ level::sort_offsets_increasing(input) :
+ level::sort_offsets_decreasing(input);
+
+ return impl::attribute_filter_fastest(input, nbh, s, a, lambda);
+ }
+
+
+
+ template <typename I, typename N, typename A>
+ inline
+ mln_concrete(I)
+ attribute_filter_dispatch(const Image<I>& input,
+ const Neighborhood<N>& nbh,
+ const Accumulator<A>& a,
+ const typename A::result& lambda,
+ bool increasing)
+ {
+ enum {
+ test = (mlc_equal(mln_trait_image_speed(I),
+ trait::image::speed::fastest)::value &&
+ mln_is_simple_neighborhood(N)::value &&
+ (mlc_equal(mln_trait_accumulator_when_pix(A),
+ trait::accumulator::when_pix::use_none)::value ||
+ mlc_equal(mln_trait_accumulator_when_pix(A),
+ trait::accumulator::when_pix::use_v)::value))
+ };
+ return attribute_filter_dispatch(metal::bool_<test>(), input, nbh, a, lambda, increasing);
+ }
+ } // end of namespace mln::canvas::morpho::internal
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ // Facade.
+
+ template <typename I, typename N, typename A>
+ mln_concrete(I)
+ attribute_filter(const Image<I>& input,
+ const Neighborhood<N>& nbh,
+ const Accumulator<A>& a,
+ const typename A::result& lambda,
+ bool increasing)
+ {
+ return internal::attribute_filter_dispatch(input, nbh, a, lambda, increasing);
+ }
+
+ } // end of namespace mln::canvas::morpho
+ } // end of namespace mln::canvas
+} // end of namespace mln
+
+
+#endif // ! MLN_CANVAS_MORPHO_ATTRIBUTE_FILTER_HH
Index: trunk/milena/sandbox/edwin/tree/propagate.hh
===================================================================
--- trunk/milena/sandbox/edwin/tree/propagate.hh (revision 3434)
+++ trunk/milena/sandbox/edwin/tree/propagate.hh (revision 3435)
@@ -60,9 +60,9 @@
void
back_propagate_subbranch(const T& t, A& a, mln_value(A) v)
{
- mln_fwd_piter(T) p(t.domain());
+ mln_bkd_piter(T) p(t.domain());
for_all(p)
- if (t.is_a_node(p) && a(t.parent(p)) == v)
+ if (a(t.parent(p)) == v)
{
mln_assertion(t.is_a_node(t.parent(p)));
a(p) = a(t.parent(p));
Index: trunk/milena/sandbox/edwin/tree/tree.cc
===================================================================
--- trunk/milena/sandbox/edwin/tree/tree.cc (revision 3434)
+++ trunk/milena/sandbox/edwin/tree/tree.cc (revision 3435)
@@ -44,8 +44,8 @@
if (echo) io::pbm::save(aa, "before.pbm");
if (echo > 1) debug::println("aa (before)", aa);
- //back_propagate_subbranch(t, aa, true);
- //if (echo > 1) debug::println("aa (After subbranch propagation)", aa);
+ back_propagate_subbranch(t, aa, true);
+ if (echo > 1) debug::println("aa (After subbranch propagation)", aa);
back_propagate_level(t, aa);
if (echo > 1) debug::println("aa (Final)", aa);
@@ -62,7 +62,7 @@
template <typename I, typename A>
inline
void
-create_tree_and_compute(I& f_, A a_, float lambda = mln_min(float), float lambda2 = mln_max(float))
+create_tree_and_compute(Image<I>& f_, Accumulator<A> a_, float lambda, float lambda2 = mln_max(float))
{
using namespace mln;
using value::int_u8;
@@ -84,13 +84,14 @@
debug::println("a | nodes", a | t.nodes());
}
- image2d<bool> b = duplicate((pw::value(a) < pw::cst(lambda1) && pw::value(a) < pw::cst(lambda2)) | a.domain());
+ std::cout << lambda;
+ image2d<bool> b = duplicate((pw::cst(lambda) < pw::value(a) && pw::value(a) < pw::cst(lambda2)) | a.domain());
sample(t, b, echo);
}
void usage(char* argv[])
{
- std::cerr << "usage: " << argv[0] << " input.pgm echo lambda" << std::endl;
+ std::cerr << "usage: " << argv[0] << " input.pgm echo lambda1 lamda2" << std::endl;
std::cerr << "\techo:\t0 (none)" << std::endl
<< "\t\t1 (img output)" << std::endl
<< "\t\t2 (debug)" << std::endl;
@@ -104,10 +105,12 @@
mln_VAR(nbh, c4());
- if (argc != 4)
+ if (argc < 4)
usage(argv);
echo = std::atoi(argv[2]);
+ float lambda1 = atof(argv[3]);
+ float lambda2 = (argc == 5) ? atof(argv[4]) : mln_max(float);
typedef image2d<int_u8> I;
@@ -139,6 +142,6 @@
//create_tree_and_compute(img, morpho::attribute::volume<I2>());
//
- create_tree_and_compute(f, morpho::attribute::card<I>(), std::atof(argv[3]));
+ create_tree_and_compute(f, morpho::attribute::coccupation<I>(), lambda1, lambda2);
}