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>
48 const Image<I>& input, const Neighborhood<N>&
nbh);
51 # ifndef MLN_INCLUDE_ONLY
59 template <
typename I,
typename N>
62 const Image<I>& input_, const Neighborhood<N>& nbh_)
64 mln_trace(
"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)
101 template <typename I, typename N>
103 like_ero_set_fastest(
bool val[5],
104 const Image<I>& input_, const Neighborhood<N>& nbh_)
106 mln_trace(
"morpho::elementary::impl::like_ero_set_fastest");
110 do_duplicate = val[1],
115 const I& input =
exact(input_);
116 const N& nbh =
exact(nbh_);
120 mln_concrete(I) output;
129 mln_pixter(
const I) p_in(input);
130 mln_pixter(I) p_out(output);
131 mln_nixter(const I, N) n(p_in, nbh);
132 for_all_2(p_in, p_out)
133 if (p_in.val() == on_input_p)
135 if (n.val() == on_input_n)
136 p_out.val() = output_p;
147 template <
typename I,
typename N>
149 like_ero_set_dispatch(metal::false_,
151 const I& input, const N& nbh)
156 template <
typename I,
typename N>
158 like_ero_set_dispatch(metal::true_,
160 const I& input, const N& nbh)
162 return impl::like_ero_set_fastest(val, input, nbh);
165 template <
typename I,
typename N>
167 like_ero_set_dispatch(
bool val[5],
168 const I& input, const N& nbh)
170 typedef mlc_equal(mln_trait_image_speed(I),
171 trait::image::speed::fastest) I_fastest;
172 typedef mln_window(N) W;
173 typedef mln_is_simple_window(W) N_simple;
175 return like_ero_set_dispatch(mlc_and(I_fastest, N_simple)(),
184 template <typename I, typename N>
187 const Image<I>& input, const Neighborhood<N>& nbh)
189 return internal::like_ero_set_dispatch(val,
exact(input),
exact(nbh));
192 # endif // ! MLN_INCLUDE_ONLY
201 #endif // ! MLN_MORPHO_ELEMENTARY_LIKE_ERO_SET_HH