26 #ifndef MLN_MORPHO_EROSION_TOLERANT_HH
27 # define MLN_MORPHO_EROSION_TOLERANT_HH
36 # include <mln/accu/count_value.hh>
37 # include <mln/accu/logic/land.hh>
38 # include <mln/accu/logic/land_basic.hh>
39 # include <mln/accu/stat/min.hh>
40 # include <mln/accu/stat/min_h.hh>
41 # include <mln/accu/transform.hh>
42 # include <mln/morpho/general.hh>
43 # include <mln/morpho/includes.hh>
44 # include <mln/morpho/erosion.hh>
53 template <
typename I,
typename W>
59 # ifndef MLN_INCLUDE_ONLY
67 template <
typename I,
typename W>
69 erosion_tolerant_on_set(
const Image<I>& input_,
73 trace::entering(
"morpho::impl::erosion_tolerant_on_set");
75 typedef mln_concrete(I) O;
76 const I& input = exact(input_);
77 const W& win = exact(win_);
81 mln_ch_value(I,
unsigned)
82 tmp = accu::transform(input,
89 mln_piter(I) p(input.domain());
91 if (input(p) ==
true && tmp(p) >= rank)
94 trace::exiting(
"morpho::impl::erosion_tolerant_on_set");
100 template <
typename I,
typename W>
102 erosion_tolerant_on_set_fastest(
const Image<I>& input_,
106 trace::entering(
"morpho::impl::erosion_tolerant_on_set_fastest");
108 typedef mln_concrete(I) O;
109 const I& input = exact(input_);
110 const W& win = exact(win_);
114 typedef mln_ch_value(I,
unsigned) tmp_t;
115 tmp_t tmp = accu::transform(input,
122 mln_pixter(
const I) p(input);
125 if (tmp.element(p.offset()) >= rank)
126 output.element(p.offset()) =
false;
128 trace::exiting(
"morpho::impl::erosion_tolerant_on_set_fastest");
142 template <
typename I,
typename W>
144 erosion_tolerant_dispatch(trait::image::kind::any,
145 trait::image::speed::any,
146 const I& input, const W& win,
unsigned rank)
148 mlc_abort(I)::check();
150 typedef mln_concrete(I) output_t;
155 template <typename I, typename W>
157 erosion_tolerant_dispatch(trait::image::kind::logic,
158 trait::image::speed::any,
159 const I& input, const W& win,
unsigned rank)
161 return impl::erosion_tolerant_on_set(input,
166 template <
typename I,
typename W>
168 erosion_tolerant_dispatch(trait::image::kind::logic,
169 trait::image::speed::fastest,
170 const I& input, const W& win,
unsigned rank)
172 return impl::erosion_tolerant_on_set_fastest(input,
178 template <
typename I,
typename W>
181 erosion_tolerant_dispatch(const Image<I>& input,
182 const Window<W>& win,
185 return erosion_tolerant_dispatch(mln_trait_image_kind(I)(),
186 mln_trait_image_speed(I)(),
187 exact(input), exact(win), rank);
197 template <
typename I,
typename W>
203 trace::entering(
"morpho::erosion_tolerant");
204 mln_precondition(exact(input).is_valid());
205 mln_precondition(exact(win).is_valid());
208 output = internal::erosion_tolerant_dispatch(input, win, rank);
210 trace::exiting(
"morpho::erosion_tolerant");
214 # endif // ! MLN_INCLUDE_ONLY
221 #endif // ! MLN_MORPHO_EROSION_TOLERANT_HH