URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-05-28 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Move tests for component tree filtering.
* mln/morpho/tree/filter/filter.hh:
Special increasing attribute filtering routine.
* tests/morpho/tree/Makefile.am,
* tests/morpho/tree/filter/Makefile.am,
* tests/morpho/tree/filter/filter.cc,
* tests/morpho/tree/filter,
* tests/unit_test/unit-tests.mk,
Tests for tree filtering.
---
mln/morpho/tree/filter/filter.hh | 99 ++++++++++++++++++++++++++++++
tests/morpho/tree/Makefile.am | 3
tests/morpho/tree/filter/Makefile.am | 10 +++
tests/morpho/tree/filter/filter.cc | 114 +++++++++++++++++++++++++++++++++++
tests/unit_test/unit-tests.mk | 20 ++++++
5 files changed, 246 insertions(+)
Index: trunk/milena/tests/morpho/tree/filter/Makefile.am
===================================================================
--- trunk/milena/tests/morpho/tree/filter/Makefile.am (revision 0)
+++ trunk/milena/tests/morpho/tree/filter/Makefile.am (revision 3898)
@@ -0,0 +1,10 @@
+## Process this file through Automake to create Makefile.in.
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ filter
+
+filter_SOURCES = filter.cc
+
+TESTS = $(check_PROGRAMS)
Property changes on: trunk/milena/tests/morpho/tree/filter/Makefile.am
___________________________________________________________________
Added: svn:mergeinfo
Index: trunk/milena/tests/morpho/tree/filter/filter.cc
===================================================================
--- trunk/milena/tests/morpho/tree/filter/filter.cc (revision 0)
+++ trunk/milena/tests/morpho/tree/filter/filter.cc (revision 3898)
@@ -0,0 +1,114 @@
+// 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/tree/filter/filter.cc
+///
+/// Test on:
+/// mln::morpho::reconstruction::filter::min
+/// mln::morpho::reconstruction::filter::max
+/// mln::morpho::reconstruction::filter::direct
+/// mln::morpho::reconstruction::filter::subtractive
+
+
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/core/var.hh>
+#include <mln/pw/all.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/level/sort_psites.hh>
+#include <mln/morpho/tree/data.hh>
+#include <mln/morpho/tree/compute_attribute_image.hh>
+#include <mln/morpho/attribute/card.hh>
+
+#include <mln/morpho/tree/filter/all.hh>
+#include <mln/morpho/tree/propagate_representative.hh>
+
+#include <mln/morpho/closing/area.hh>
+
+#include "tests/data.hh"
+
+#include <iostream>
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+
+ typedef image2d<int_u8> I;
+ I input;
+ io::pgm::load(input, MLN_IMG_DIR "/tiny.pgm");
+
+ typedef p_array< mln_site_(I) > S;
+ typedef morpho::tree::data<I,S> tree_t;
+
+ S sorted_sites = level::sort_psites_decreasing(input);
+ tree_t tree(input, sorted_sites, c4());
+
+ // Test with increasing attribute -> area closing.
+ {
+ typedef morpho::attribute::card<I> attribute_t;
+ typedef mln_ch_value_(I, unsigned) A;
+
+ A a = morpho::tree::compute_attribute_image(attribute_t (), tree);
+
+ unsigned lambda = 5;
+ mln_VAR(predicate, pw::value(a) >= pw::cst(lambda));
+ I ref = morpho::closing::area(input, c4(), lambda);
+
+ {
+ I out = duplicate(input);
+ morpho::tree::filter::min(tree, out, predicate);
+ morpho::tree::propagate_representative(tree, out);
+ mln_assertion(out == ref);
+ }
+
+ {
+ I out = duplicate(input);
+ morpho::tree::filter::max(tree, out, predicate);
+ morpho::tree::propagate_representative(tree, out);
+ mln_assertion(out == ref);
+ }
+
+ {
+ I out = duplicate(input);
+ morpho::tree::filter::direct(tree, out, predicate);
+ morpho::tree::propagate_representative(tree, out);
+ mln_assertion(out == ref);
+ }
+
+ // Not for subtractive strategy (removal procedure differs).
+ }
+}
+
+
Index: trunk/milena/tests/morpho/tree/Makefile.am
===================================================================
--- trunk/milena/tests/morpho/tree/Makefile.am (revision 3897)
+++ trunk/milena/tests/morpho/tree/Makefile.am (revision 3898)
@@ -14,3 +14,6 @@
max_SOURCES = max.cc
TESTS = $(check_PROGRAMS)
+
+SUBDIRS = \
+ filter
\ No newline at end of file
Index: trunk/milena/tests/unit_test/unit-tests.mk
===================================================================
--- trunk/milena/tests/unit_test/unit-tests.mk (revision 3897)
+++ trunk/milena/tests/unit_test/unit-tests.mk (revision 3898)
@@ -921,7 +921,16 @@
mln_morpho_tree_compute_attribute_image \
mln_morpho_tree_compute_parent \
mln_morpho_tree_data \
+mln_morpho_tree_filter_all \
+mln_morpho_tree_filter_direct \
+mln_morpho_tree_filter_filter \
+mln_morpho_tree_filter_max \
+mln_morpho_tree_filter_min \
+mln_morpho_tree_filter_subtractive \
mln_morpho_tree_max \
+mln_morpho_tree_propagate_if \
+mln_morpho_tree_propagate_node \
+mln_morpho_tree_propagate_representative \
mln_morpho_tree_utils \
mln_morpho_watershed_all \
mln_morpho_watershed_flooding \
@@ -1222,6 +1231,7 @@
mln_value_stack \
mln_value_super_value \
mln_value_viter \
+mln_version \
mln_win_all \
mln_win_backdiag2d \
mln_win_ball \
@@ -2183,7 +2193,16 @@
mln_morpho_tree_compute_attribute_image_SOURCES =
mln_morpho_tree_compute_attribute_image.cc
mln_morpho_tree_compute_parent_SOURCES = mln_morpho_tree_compute_parent.cc
mln_morpho_tree_data_SOURCES = mln_morpho_tree_data.cc
+mln_morpho_tree_filter_all_SOURCES = mln_morpho_tree_filter_all.cc
+mln_morpho_tree_filter_direct_SOURCES = mln_morpho_tree_filter_direct.cc
+mln_morpho_tree_filter_filter_SOURCES = mln_morpho_tree_filter_filter.cc
+mln_morpho_tree_filter_max_SOURCES = mln_morpho_tree_filter_max.cc
+mln_morpho_tree_filter_min_SOURCES = mln_morpho_tree_filter_min.cc
+mln_morpho_tree_filter_subtractive_SOURCES = mln_morpho_tree_filter_subtractive.cc
mln_morpho_tree_max_SOURCES = mln_morpho_tree_max.cc
+mln_morpho_tree_propagate_if_SOURCES = mln_morpho_tree_propagate_if.cc
+mln_morpho_tree_propagate_node_SOURCES = mln_morpho_tree_propagate_node.cc
+mln_morpho_tree_propagate_representative_SOURCES =
mln_morpho_tree_propagate_representative.cc
mln_morpho_tree_utils_SOURCES = mln_morpho_tree_utils.cc
mln_morpho_watershed_all_SOURCES = mln_morpho_watershed_all.cc
mln_morpho_watershed_flooding_SOURCES = mln_morpho_watershed_flooding.cc
@@ -2484,6 +2503,7 @@
mln_value_stack_SOURCES = mln_value_stack.cc
mln_value_super_value_SOURCES = mln_value_super_value.cc
mln_value_viter_SOURCES = mln_value_viter.cc
+mln_version_SOURCES = mln_version.cc
mln_win_all_SOURCES = mln_win_all.cc
mln_win_backdiag2d_SOURCES = mln_win_backdiag2d.cc
mln_win_ball_SOURCES = mln_win_ball.cc
Index: trunk/milena/mln/morpho/tree/filter/filter.hh
===================================================================
--- trunk/milena/mln/morpho/tree/filter/filter.hh (revision 0)
+++ trunk/milena/mln/morpho/tree/filter/filter.hh (revision 3898)
@@ -0,0 +1,99 @@
+// 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.
+
+#ifndef MLN_MORPHO_TREE_FILTER_FILTER_HH_
+# define MLN_MORPHO_TREE_FILTER_FILTER_HH_
+
+/**
+** \file mln/morpho/tree/filter/filter.hh
+**
+**
+*/
+
+# include <mln/core/concept/function.hh>
+# include <mln/morpho/tree/data.hh>
+# include <mln/morpho/tree/propagate_if.hh>
+
+namespace mln {
+ namespace morpho {
+ namespace tree {
+ namespace filter {
+
+
+ /**
+ ** Filter the image \p f_ with a given value. The
+ ** sub-components of nodes that does not match the predicate
+ ** \p pred_ are filled with the given value \p v.
+ **
+ ** @param tree Component tree.
+ ** @param f_ Image function.
+ ** @param pred_ Predicate.
+ ** @param v Value to propagate.
+ */
+ template <typename T, typename F, typename P2B>
+ inline
+ void
+ filter(const T& tree, Image<F>& f_, const Function_p2b<P2B>&
pred_, const mln_value(F)& v);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T, typename F, typename P2B>
+ inline
+ void
+ filter(const T& tree, Image<F>& f_, const Function_p2b<P2B>&
pred_, const mln_value(F)& v)
+ {
+ F& f = exact(f_);
+ const P2B& pred = exact(pred_);
+
+ trace::entering("mln::morpho::tree::filter::filter");
+
+ mln_ch_value(F, bool) mark;
+ initialize(mark, f);
+ mln::data::fill(mark, false);
+
+ mln_dn_node_piter(T) n(tree);
+ for_all(n)
+ if (mark(tree.parent(n)) || !pred(n))
+ {
+ f(n) = v;
+ mark(n) = true;
+ }
+
+ trace::exiting("mln::morpho::tree::filter::filter");
+ }
+
+# endif /* !MLN_INCLUDE_ONLY */
+
+ } // end of namespace mln::morpho::tree::filter
+ } // end of namespace mln::morpho::tree
+ } // end of namespace mln::morpho
+} // end of namespace mln
+
+
+#endif /* !MLN_MORPHO_TREE_FILTER_FILTER_HH_ */
Property changes on: trunk/milena/mln/morpho/tree/filter/filter.hh
___________________________________________________________________
Added: svn:mergeinfo