26 #ifndef MLN_LINEAR_CONVOLVE_HH
27 # define MLN_LINEAR_CONVOLVE_HH
33 # include <mln/core/concept/image.hh>
34 # include <mln/core/concept/weighted_window.hh>
35 # include <mln/linear/ch_convolve.hh>
36 # include <mln/accu/convolve.hh>
37 # include <mln/extension/adjust_duplicate.hh>
56 template <
typename I,
typename W>
58 convolve(const Image<I>& input, const Weighted_Window<W>& w_win);
62 # ifndef MLN_INCLUDE_ONLY
69 template <
typename I,
typename W>
71 convolve_tests(
const Image<I>& input,
72 const Weighted_Window<W>& w_win)
74 mln_precondition(exact(input).is_valid());
75 mln_precondition(exact(w_win).is_valid());
91 template <
typename I,
typename W>
93 convolve(const Image<I>& input_,
94 const Weighted_Window<W>& w_win_)
96 trace::entering(
"linear::impl::generic::convolve");
98 const I& input = exact(input_);
99 const W& w_win = exact(w_win_);
100 internal::convolve_tests(input, w_win);
104 typedef mln_ch_convolve(I, W) O;
106 initialize(output, input);
108 accu::convolve<mln_value(I), mln_weight(W)> a;
110 mln_piter(I) p(input.domain());
111 mln_qiter(W) q(w_win, p);
116 for_all(q) if (input.has(q))
117 a.take(input(q), q.w());
118 output(p) = a.to_result();
121 trace::exiting("linear::impl::generic::convolve");
128 template <typename I, typename W>
129 mln_ch_convolve(I, W)
130 convolve_fastest(const Image<I>& input_,
131 const Weighted_Window<W>& w_win_)
133 trace::entering(
"linear::impl::convolve_fastest");
135 const I& input = exact(input_);
136 const W& w_win = exact(w_win_);
137 internal::convolve_tests(input, w_win);
141 typedef mln_ch_convolve(I, W) O;
143 initialize(output, input);
144 mln_pixter(O) p_out(output);
146 accu::convolve<mln_value(I), mln_weight(W)> a;
148 mln_pixter(const I) p(input);
149 mln_qixter(const I, W) q(p, w_win);
156 a.take(q.val(), w_win.w(i++));
157 p_out.val() = a.to_result();
160 trace::exiting("linear::impl::convolve_fastest");
172 template <
typename I,
typename W>
173 mln_ch_convolve(I, W)
174 convolve_dispatch(trait::image::speed::any,
175 const Image<I>& input,
176 const Weighted_Window<W>& w_win)
178 return impl::generic::convolve(input, w_win);
181 template <
typename I,
typename W>
182 mln_ch_convolve(I, W)
183 convolve_dispatch(trait::image::speed::fastest,
184 const Image<I>& input,
185 const Weighted_Window<W>& w_win)
187 return impl::convolve_fastest(input, w_win);
190 template <
typename I,
typename W>
191 mln_ch_convolve(I, W)
192 convolve_dispatch(const Image<I>& input,
193 const Weighted_Window<W>& w_win)
195 return convolve_dispatch(mln_trait_image_speed(I)(),
204 template <
typename I,
typename W>
205 mln_ch_convolve(I, W)
206 convolve(const Image<I>& input, const Weighted_Window<W>& w_win)
208 trace::entering(
"linear::convolve");
210 internal::convolve_tests(input, w_win);
212 mln_ch_convolve(I, W) output;
213 output = internal::convolve_dispatch(mln_trait_image_speed(I)(),
216 trace::exiting("linear::convolve");
220 # endif // ! MLN_INCLUDE_ONLY
227 #endif // ! MLN_LINEAR_CONVOLVE_HH