27 #ifndef MLN_LABELING_BLOBS_AND_COMPUTE_HH
28 # define MLN_LABELING_BLOBS_AND_COMPUTE_HH
35 # include <mln/core/concept/image.hh>
36 # include <mln/core/concept/neighborhood.hh>
38 # include <mln/labeling/blobs.hh>
39 # include <mln/labeling/compute.hh>
41 # include <mln/util/couple.hh>
60 template <
typename I,
typename N,
typename L,
typename A>
61 util::couple<mln_ch_value(I,L),
62 util::couple<util::array<mln_result(A)>,
65 L& nlabels,
const Accumulator<A>& accu);
69 # ifndef MLN_INCLUDE_ONLY
80 template <
typename L,
typename A>
81 struct compute_functor
83 typedef mln_result(A) accu_result;
84 typedef mln_argument(A) accu_argument;
85 typedef util::couple<util::array<accu_result>,
86 util::array<A> > result;
88 compute_functor(const mln_value(L)& nlabels)
101 void new_label(
const mln_value(L)& l)
108 void process_p(
const mln_site(L)&
p)
110 process__(accu_argument(), p);
114 void process_n(
const mln_site(L)& n)
116 process__(accu_argument(), n);
128 void process__(
const mln_psite(L)&,
const mln_site(L)& p)
130 accus_[current_lbl_].take(p);
134 void process__(
const mln_value(L)&,
const mln_site(L)&)
136 accus_[current_lbl_].take(current_lbl_);
139 template <
typename V>
141 void process__(
const V&,
const mln_site(L)&)
143 mlc_abort(V)::check();
147 util::array<mln_result(A)> result_;
148 util::array<A> accus_;
149 mln_value(L) current_lbl_;
150 mln_value(L) nlabels_;
160 template <typename I, typename N, typename L, typename A>
161 util::couple<mln_ch_value(I,L),
162 util::couple<util::array<mln_result(A)>,
165 L& nlabels, const Accumulator<A>& accu)
167 mln_trace(
"labeling::blobs_and_compute");
170 mlc_equal(mln_trait_image_kind(I),
171 mln::trait::image::kind::binary)::check();
172 mln_precondition(
exact(input).is_valid());
174 typedef mln_ch_value(I,L) out_t;
175 typedef internal::compute_functor<out_t,A> func_t;
176 func_t functor(nlabels);
178 output = canvas::
labeling::
blobs(input, nbh, nlabels, functor);
180 util::couple<out_t, typename func_t::result>
181 result = make::couple(output,
182 make::couple(functor.result_, functor.accus_));
188 # endif // ! MLN_INCLUDE_ONLY
196 #endif // ! MLN_LABELING_BLOBS_AND_COMPUTE_HH