
* edwin/mln/morpho/tree/filter.hh: group strategies for non-increasing attribute filtering. * edwin/attributes/bbox.hh, * edwin/attributes/occupation.hh, * edwin/attributes, * edwin/mln/morpho/attribute, * edwin/mln/morpho/tree/components.hh, * edwin/mln/morpho/tree/propagate.hh, * edwin/mln/morpho/tree/propagate_if.hh, * edwin/mln/morpho/tree/propagate_node.hh, * edwin/mln/morpho/tree, * edwin/mln/morpho, * edwin/mln, * edwin/rush/exo2/test.cc, * edwin/tests, * edwin/tree/components.hh, * edwin/tree/propagate.hh, * edwin/tree/propagate_if.hh, * edwin/tree/propagate_node.hh, move all tree materials in edwin/mln/morpho/tree. --- milena/sandbox/ChangeLog | 25 +++ .../{attributes => mln/morpho/attribute}/bbox.hh | 0 .../morpho/attribute}/occupation.hh | 0 .../edwin/{ => mln/morpho}/tree/components.hh | 2 +- milena/sandbox/edwin/mln/morpho/tree/filter.hh | 205 ++++++++++++++++++++ .../edwin/{ => mln/morpho}/tree/propagate.hh | 14 +- .../edwin/{ => mln/morpho}/tree/propagate_if.hh | 2 +- .../edwin/{ => mln/morpho}/tree/propagate_node.hh | 0 milena/sandbox/edwin/rush/exo2/test.cc | 1 + 9 files changed, 240 insertions(+), 9 deletions(-) rename milena/sandbox/edwin/{attributes => mln/morpho/attribute}/bbox.hh (100%) rename milena/sandbox/edwin/{attributes => mln/morpho/attribute}/occupation.hh (100%) rename milena/sandbox/edwin/{ => mln/morpho}/tree/components.hh (99%) create mode 100644 milena/sandbox/edwin/mln/morpho/tree/filter.hh rename milena/sandbox/edwin/{ => mln/morpho}/tree/propagate.hh (92%) rename milena/sandbox/edwin/{ => mln/morpho}/tree/propagate_if.hh (99%) rename milena/sandbox/edwin/{ => mln/morpho}/tree/propagate_node.hh (100%) diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog index be85cde..3cffc50 100644 --- a/milena/sandbox/ChangeLog +++ b/milena/sandbox/ChangeLog @@ -1,3 +1,28 @@ +2009-05-10 Edwin Carlinet <carlinet@lrde.epita.fr> + + Make clean in tree files and procedures. + * edwin/mln/morpho/tree/filter.hh: + group strategies for non-increasing attribute filtering. + + * edwin/attributes/bbox.hh, + * edwin/attributes/occupation.hh, + * edwin/attributes, + * edwin/mln/morpho/attribute, + * edwin/mln/morpho/tree/components.hh, + * edwin/mln/morpho/tree/propagate.hh, + * edwin/mln/morpho/tree/propagate_if.hh, + * edwin/mln/morpho/tree/propagate_node.hh, + * edwin/mln/morpho/tree, + * edwin/mln/morpho, + * edwin/mln, + * edwin/rush/exo2/test.cc, + * edwin/tests, + * edwin/tree/components.hh, + * edwin/tree/propagate.hh, + * edwin/tree/propagate_if.hh, + * edwin/tree/propagate_node.hh, + move all tree materials in edwin/mln/morpho/tree. + 2009-05-07 Thierry Geraud <thierry.geraud@lrde.epita.fr> Fix missing updates about debug colorize. diff --git a/milena/sandbox/edwin/attributes/bbox.hh b/milena/sandbox/edwin/mln/morpho/attribute/bbox.hh similarity index 100% rename from milena/sandbox/edwin/attributes/bbox.hh rename to milena/sandbox/edwin/mln/morpho/attribute/bbox.hh diff --git a/milena/sandbox/edwin/attributes/occupation.hh b/milena/sandbox/edwin/mln/morpho/attribute/occupation.hh similarity index 100% rename from milena/sandbox/edwin/attributes/occupation.hh rename to milena/sandbox/edwin/mln/morpho/attribute/occupation.hh diff --git a/milena/sandbox/edwin/tree/components.hh b/milena/sandbox/edwin/mln/morpho/tree/components.hh similarity index 99% rename from milena/sandbox/edwin/tree/components.hh rename to milena/sandbox/edwin/mln/morpho/tree/components.hh index 2b4cfac..6485241 100644 --- a/milena/sandbox/edwin/tree/components.hh +++ b/milena/sandbox/edwin/mln/morpho/tree/components.hh @@ -227,7 +227,7 @@ namespace mln { unsigned* nb_leaves = uses_leaves ? new unsigned(0) : 0; initialize(activity, a); - data::fill(activity, true); + mln::data::fill(activity, true); internal::sort(max_arr, a); do diff --git a/milena/sandbox/edwin/mln/morpho/tree/filter.hh b/milena/sandbox/edwin/mln/morpho/tree/filter.hh new file mode 100644 index 0000000..26e4f9a --- /dev/null +++ b/milena/sandbox/edwin/mln/morpho/tree/filter.hh @@ -0,0 +1,205 @@ +// 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_HH_ +# define MLN_MORPHO_TREE_FILTER_HH_ + +/** +** @file mln/morpho/tree/filter.hh +** +** @brief Methods to handle component tree filtering strategies with +** non-increasing attribute. Nevertheless, it works on increasing +** predicate as well. In this case, all strategies have the same +** result but min filter or direct filter should be used in term +** of performance. If a predicate test is not enough fast, then +** prefer the min filter that minimizes call to predicate. +*/ + +# 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 { + + template <typename T, typename F, typename P2B> + inline + void + min(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_); + + template <typename T, typename F, typename P2B> + inline + void + max(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_); + + template <typename T, typename F, typename P2B> + inline + void + direct(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_); + + template <typename T, typename F, typename P2B> + inline + void + subtractive(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_); + + +# ifndef MLN_INCLUDE_ONLY + namespace internal + { + + template <typename P2B> + struct not_pred_ : Function_p2b< not_pred_<P2B> > + { + not_pred_(const Function_p2b<P2B>& f) : + f_ (exact(f)) + { + } + + template <typename P> + bool operator() (const P& p) const + { + return !(f_(p)); + } + + private: + const P2B& f_; + }; + + template <typename P2B> + inline + not_pred_<P2B> + not_pred(const Function_p2b<P2B>& f) + { + return not_pred_<P2B>(f); + } + + } + + + template <typename T, typename F, typename P2B> + inline + void + min(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_) + { + F& f = exact(f_); + const P2B& pred = exact(pred_); + + //FIXME precondition + 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) = f(tree.parent(n)); + mark(n) = true; + } + //FIXME postcondition + } + + template <typename T, typename F, typename P2B> + inline + void + max(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_) + { + F& f = exact(f_); + const P2B& pred = exact(pred_); + + //FIXME precondition + mln_ch_value(F, bool) mark; + initialize(mark, f); + mln::data::fill(mark, true); + + { + mln_up_node_piter(T) n(tree); + for_all(n) + if (!mark(n)) + mark(tree.parent(n)) = false; + else if (pred(n)) + { + mark(tree.parent(n)) = false; + mark(n) = false; + } + } + + { + mln_dn_node_piter(T) n(tree); + for_all(n) + if (mark(n)) + f(n) = f(tree.parent(n)); + } + } + + template <typename T, typename F, typename P2B> + inline + void + direct(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_) + { + F& f = exact(f_); + const P2B& pred = exact(pred_); + + //FIXME precondition + mln_dn_node_piter(T) n(tree); + for_all(n) + if (!pred(n)) + f(n) = f(tree.parent(n)); + //FIXME postcondition + } + + template <typename T, typename F, typename P2B> + inline + void + subtractive(const T& tree, Image<F>& f_, const Function_p2b<P2B>& pred_) + { + F& f = exact(f_); + const P2B& pred = exact(pred_); + + //FIXME precondition + + morpho::tree::propagate_if(tree, f, morpho::tree::desc_propagation (), internal::not_pred(pred)); + + mln_up_node_piter(T) n(tree); + for_all(n) + if (!pred(n)) + f(n) = f(tree.parent(n)); + //FIXME postcondition + } + +# 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_HH_ */ diff --git a/milena/sandbox/edwin/tree/propagate.hh b/milena/sandbox/edwin/mln/morpho/tree/propagate.hh similarity index 92% rename from milena/sandbox/edwin/tree/propagate.hh rename to milena/sandbox/edwin/mln/morpho/tree/propagate.hh index d25f811..58a0e8f 100644 --- a/milena/sandbox/edwin/tree/propagate.hh +++ b/milena/sandbox/edwin/mln/morpho/tree/propagate.hh @@ -33,7 +33,7 @@ /// Functions to propagate a node value in the tree. # include <mln/morpho/tree/data.hh> -# include "propagate_node.hh" +# include <mln/morpho/tree/propagate_node.hh> namespace mln { namespace morpho { @@ -41,10 +41,10 @@ namespace mln { /// Propagate the representative point's value to - /// non-representative points of the same node. + /// non-representative node points. template <typename T, typename A> void - propagate_representant(const T& t, Image<A>& a_) + propagate_representative(const T& t, Image<A>& a_) { A a = exact(a_); mln_up_site_piter(T) p(t); @@ -80,7 +80,7 @@ namespace mln { const A& a = exact(attr_image); A out; initialize(out, a); - data::fill(out, null); + mln::data::fill(out, null); mln_piter(p_array<mln_psite(A)>) p(component_list); for_all(p) @@ -88,7 +88,7 @@ namespace mln { out(p) = a(p); morpho::tree::propagate_node_to_descendants(p, tree, out, a(p)); } - morpho::tree::propagate_representant(tree, out); + morpho::tree::propagate_representative(tree, out); return out; } @@ -103,7 +103,7 @@ namespace mln { { mln_ch_value(typename T::function, V) out; initialize(out, tree.f()); - data::fill(out, null); + mln::data::fill(out, null); mln_piter(p_array< mln_psite(T) >) p(component_list); for_all(p) @@ -111,7 +111,7 @@ namespace mln { out(p) = value; morpho::tree::propagate_node_to_descendants(p, tree, out); } - morpho::tree::propagate_representant(tree, out); + morpho::tree::propagate_representative(tree, out); return out; } diff --git a/milena/sandbox/edwin/tree/propagate_if.hh b/milena/sandbox/edwin/mln/morpho/tree/propagate_if.hh similarity index 99% rename from milena/sandbox/edwin/tree/propagate_if.hh rename to milena/sandbox/edwin/mln/morpho/tree/propagate_if.hh index d8c1b03..c310857 100644 --- a/milena/sandbox/edwin/tree/propagate_if.hh +++ b/milena/sandbox/edwin/mln/morpho/tree/propagate_if.hh @@ -38,7 +38,7 @@ */ # include <mln/morpho/tree/data.hh> -# include "propagate_node.hh" +# include <mln/morpho/tree/propagate_node.hh> # include <mln/data/fill.hh> # include <mln/pw/all.hh> diff --git a/milena/sandbox/edwin/tree/propagate_node.hh b/milena/sandbox/edwin/mln/morpho/tree/propagate_node.hh similarity index 100% rename from milena/sandbox/edwin/tree/propagate_node.hh rename to milena/sandbox/edwin/mln/morpho/tree/propagate_node.hh diff --git a/milena/sandbox/edwin/rush/exo2/test.cc b/milena/sandbox/edwin/rush/exo2/test.cc index eeca8bf..40a0f66 100755 --- a/milena/sandbox/edwin/rush/exo2/test.cc +++ b/milena/sandbox/edwin/rush/exo2/test.cc @@ -18,6 +18,7 @@ #include <mln/fun/p2v/ternary.hh> #include <mln/pw/all.hh> + namespace mln { // Sharpness Attribute -> Height Attribute -- 1.6.1.2