00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef MLN_MORPHO_TREE_FILTER_FILTER_HH
00027 # define MLN_MORPHO_TREE_FILTER_FILTER_HH
00028
00035 # include <mln/core/concept/function.hh>
00036 # include <mln/morpho/tree/data.hh>
00037 # include <mln/morpho/tree/propagate_if.hh>
00038
00039 namespace mln
00040 {
00041
00042 namespace morpho
00043 {
00044
00045 namespace tree
00046 {
00047
00048 namespace filter
00049 {
00050
00051
00062 template <typename T, typename F, typename P>
00063 inline
00064 void
00065 filter(const T& tree, Image<F>& f_, const Function_v2b<P>& pred_, const mln_value(F)& v);
00066
00067
00068 # ifndef MLN_INCLUDE_ONLY
00069
00070 template <typename T, typename F, typename P>
00071 inline
00072 void
00073 filter(const T& tree, Image<F>& f_, const Function_v2b<P>& pred_, const mln_value(F)& v)
00074 {
00075 F& f = exact(f_);
00076 const P& pred = exact(pred_);
00077
00078 trace::entering("mln::morpho::tree::filter::filter");
00079
00080 mln_ch_value(F, bool) mark;
00081 initialize(mark, f);
00082 mln::data::fill(mark, false);
00083
00084 mln_dn_node_piter(T) n(tree);
00085 for_all(n)
00086 if (mark(tree.parent(n)) || !pred(n))
00087 {
00088 f(n) = v;
00089 mark(n) = true;
00090 }
00091
00092 trace::exiting("mln::morpho::tree::filter::filter");
00093 }
00094
00095 # endif // ! MLN_INCLUDE_ONLY
00096
00097 }
00098
00099 }
00100
00101 }
00102
00103 }
00104
00105
00106 #endif // ! MLN_MORPHO_TREE_FILTER_FILTER_HH