26 #ifndef MLN_MORPHO_ELEMENTARY_LIKE_ERO_SET_HH
27 # define MLN_MORPHO_ELEMENTARY_LIKE_ERO_SET_HH
33 # include <mln/morpho/includes.hh>
45 template <
typename I,
typename N>
47 like_ero_set(
bool val[5],
48 const Image<I>& input, const Neighborhood<N>& nbh);
51 # ifndef MLN_INCLUDE_ONLY
59 template <
typename I,
typename N>
61 like_ero_set(
bool val[5],
62 const Image<I>& input_, const Neighborhood<N>& nbh_)
64 trace::entering(
"morpho::elementary::impl::generic::like_ero_set");
68 do_duplicate = val[1],
73 const I& input = exact(input_);
74 const N& nbh = exact(nbh_);
78 mln_concrete(I) output;
87 mln_piter(I) p(input.domain());
88 mln_niter(N) n(nbh, p);
90 if (input(p) == on_input_p)
92 if (input.has(n) && input(n) == on_input_n)
95 trace::exiting("morpho::elementary::impl::generic::like_ero_set");
102 template <typename I, typename N>
104 like_ero_set_fastest(
bool val[5],
105 const Image<I>& input_, const Neighborhood<N>& nbh_)
107 trace::entering(
"morpho::elementary::impl::like_ero_set_fastest");
111 do_duplicate = val[1],
116 const I& input = exact(input_);
117 const N& nbh = exact(nbh_);
121 mln_concrete(I) output;
130 mln_pixter(
const I) p_in(input);
131 mln_pixter(I) p_out(output);
132 mln_nixter(const I, N) n(p_in, nbh);
133 for_all_2(p_in, p_out)
134 if (p_in.val() == on_input_p)
136 if (n.val() == on_input_n)
137 p_out.val() = output_p;
139 trace::exiting("morpho::elementary::impl::like_ero_set_fastest");
149 template <
typename I,
typename N>
151 like_ero_set_dispatch(metal::false_,
153 const I& input, const N& nbh)
155 return impl::generic::like_ero_set(val, input, nbh);
158 template <
typename I,
typename N>
160 like_ero_set_dispatch(metal::true_,
162 const I& input, const N& nbh)
164 return impl::like_ero_set_fastest(val, input, nbh);
167 template <
typename I,
typename N>
169 like_ero_set_dispatch(
bool val[5],
170 const I& input, const N& nbh)
172 typedef mlc_equal(mln_trait_image_speed(I),
173 trait::image::speed::fastest) I_fastest;
174 typedef mln_window(N) W;
175 typedef mln_is_simple_window(W) N_simple;
177 return like_ero_set_dispatch(mlc_and(I_fastest, N_simple)(),
186 template <typename I, typename N>
188 like_ero_set(
bool val[5],
189 const Image<I>& input, const Neighborhood<N>& nbh)
191 return internal::like_ero_set_dispatch(val, exact(input), exact(nbh));
194 # endif // ! MLN_INCLUDE_ONLY
203 #endif // ! MLN_MORPHO_ELEMENTARY_LIKE_ERO_SET_HH