27 #ifndef MLN_MORPHO_APPROX_DILATION_HH
28 # define MLN_MORPHO_APPROX_DILATION_HH
34 # include <mln/core/concept/image.hh>
36 # include <mln/core/routine/duplicate.hh>
37 # include <mln/data/compare.hh>
39 # include <mln/transform/distance_front.hh>
40 # include <mln/pw/all.hh>
42 # include <mln/core/alias/neighb2d.hh>
43 # include <mln/make/w_window2d_int.hh>
44 # include <mln/win/disk2d.hh>
46 # include <mln/core/alias/neighb3d.hh>
47 # include <mln/make/w_window3d_int.hh>
48 # include <mln/win/sphere3d.hh>
65 template <
typename I,
typename W>
67 dilation(const Image<I>& input, const Window<W>&
win);
71 # ifndef MLN_INCLUDE_ONLY
84 dilation_by_distance_thresholding_2d(const Image<I>& input_,
85 const Window< win::disk2d >& win_)
87 mln_trace(
"morpho::approx::impl::dilation_by_distance_thresholding_2d");
89 const I& input =
exact(input_);
90 const win::disk2d& win =
exact(win_);
92 mln_precondition(input.is_valid());
93 mln_precondition(win.is_valid());
95 int ws[] = { 00, 11, 0, 11, 0,
100 const unsigned coef = 5;
103 radius = coef * win.diameter() / 2,
107 c4(), make::w_window2d_int(ws),
109 mln_concrete(I) output;
110 output =
duplicate((pw::
value(dmap) <= pw::cst(radius)) | input.domain());
117 template <typename I>
119 dilation_by_distance_thresholding_3d(const Image<I>& input_,
120 const Window< win::sphere3d >& win_)
122 mln_trace(
"morpho::approx::impl::dilation_by_distance_thresholding_3d");
124 const I& input =
exact(input_);
125 const win::sphere3d& win =
exact(win_);
127 mln_precondition(input.is_valid());
128 mln_precondition(win.is_valid());
130 int ws[] = { 00, 21, 00,
141 const unsigned coef = 12;
144 radius = coef * win.diameter() / 2,
148 c6(), make::w_window3d_int(ws),
150 mln_concrete(I) output;
151 output =
duplicate((pw::
value(dmap) <= pw::cst(radius)) | input.domain());
166 template <
typename I>
168 dilation_dispatch(trait::image::kind::logic,
170 const win::disk2d& win)
172 return impl::dilation_by_distance_thresholding_2d(input, win);
175 template <
typename I>
177 dilation_dispatch(trait::image::kind::logic,
179 const win::sphere3d& win)
181 return impl::dilation_by_distance_thresholding_3d(input, win);
186 template <
typename I,
typename W>
188 dilation_dispatch(const I& input, const W& win)
190 return dilation_dispatch(mln_trait_image_kind(I)(),
199 template <
typename I,
typename W>
202 dilation(const Image<I>& input, const Window<W>& win)
204 mln_trace(
"morpho::approx::dilation");
206 mln_precondition(
exact(input).is_valid());
207 mln_precondition(
exact(win).is_valid());
209 mln_concrete(I) output;
210 output = internal::dilation_dispatch(
exact(input),
exact(win));
212 if (
exact(win).is_centered())
213 mln_postcondition(output >= input);
219 # endif // ! MLN_INCLUDE_ONLY
228 #endif // ! MLN_MORPHO_APPROX_DILATION_HH