26 #ifndef MLN_LABELING_COMPUTE_IN_WINDOW_HH
27 # define MLN_LABELING_COMPUTE_IN_WINDOW_HH
34 # include <mln/accu/image/init.hh>
35 # include <mln/accu/image/to_result.hh>
36 # include <mln/core/concept/meta_accumulator.hh>
37 # include <mln/border/mirror.hh>
38 # include <mln/extension/adjust.hh>
39 # include <mln/value/succ.hh>
41 # include <mln/debug/println_with_border.hh>
52 template <
typename A,
typename I,
typename L,
typename W>
55 const Image<L>& label,
const mln_value(L)& nlabels,
56 const Window<W>& win);
64 template <
typename A,
typename I,
typename L,
typename W>
67 const Image<L>& label,
const mln_value(L)& nlabels,
68 const Window<W>& win);
71 # ifndef MLN_INCLUDE_ONLY
76 template <
typename A,
typename I,
typename L,
typename W>
78 compute_in_window_tests(
const Accumulator<A>& a,
const Image<I>& input_,
79 const Image<L>& label_,
const mln_value(L)& nlabels,
80 const Window<W>& win_)
84 const W& win = exact(win_);
85 const I& input = exact(input_);
86 const L& label = exact(label_);
88 mln_assertion(win.is_valid());
89 mln_assertion(input.is_valid());
90 mln_assertion(label.is_valid());
102 template <
typename A,
typename I,
typename L,
typename W>
105 const Image<L>& label_,
const mln_value(L)& nlabels,
106 const Window<W>& win_)
108 trace::entering(
"mln::impl::generic::compute_in_window");
110 const I& input = exact(input_);
111 const L& label = exact(label_);
112 const W& win = exact(win_);
114 internal::compute_in_window_tests(a_, input, label, nlabels, win);
118 mln_piter(I) p(input.domain());
119 mln_qiter(W) q(win, p);
123 if (input.domain().has(q))
124 accu[label(p)].take(input(q));
126 mln::util::array<mln_result(A)> output;
127 convert::from_to(accu, output);
129 trace::exiting("mln::impl::generic::compute_in_window");
143 template <
typename A,
typename I,
typename L,
typename W>
145 compute_in_window_dispatch(
const Accumulator<A>& a,
const Image<I>& input,
146 const Image<L>& label,
const mln_value(L)& nlabels,
147 const Window<W>& win,
148 trait::image::speed::any)
150 return impl::generic::compute_in_window(a, input, label, nlabels, win);
153 template <
typename A,
typename I,
typename L,
typename W>
155 compute_in_window_dispatch(
const Accumulator<A>& a,
const Image<I>& input,
156 const Image<L>& label,
const mln_value(L)& nlabels,
157 const Window<W>& win)
159 return compute_in_window_dispatch(a, input, label, nlabels, win,
160 mln_trait_image_speed(I)());
169 template <
typename A,
typename I,
typename L,
typename W>
172 const Image<L>& label,
const mln_value(L)& nlabels,
175 trace::entering(
"labeling::compute_in_window");
177 internal::compute_in_window_tests(a, input, win);
179 mln_ch_value(I, mln_result(A))
180 output = labeling::internal::compute_in_window_dispatch(a, input, win);
182 trace::exiting(
"labeling::compute_in_window");
187 template <
typename A,
typename I,
typename L,
typename W>
190 const Image<L>& label,
const mln_value(L)& nlabels,
193 typedef mln_accu_with(A, mln_value(I)) A_;
194 A_ a_ = accu::unmeta(exact(a), mln_value(I)());
196 return labeling::compute_in_window(a_, input, label, nlabels, win);
199 # endif // ! MLN_INCLUDE_ONLY
206 #endif // ! MLN_LABELING_COMPUTE_IN_WINDOW_HH