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>
59 template <
typename I,
typename N,
typename L,
typename A>
60 util::couple<mln_ch_value(I,L),
61 util::couple<util::array<mln_result(A)>,
64 L& nlabels,
const Accumulator<A>& accu);
68 # ifndef MLN_INCLUDE_ONLY
76 template <
typename L,
typename A>
77 struct compute_functor
79 typedef mln_result(A) accu_result;
80 typedef mln_argument(A) accu_argument;
81 typedef util::couple<util::array<accu_result>,
82 util::array<A> > result;
84 compute_functor(const mln_value(L)& nlabels)
97 void new_label(
const mln_value(L)& l)
104 void process_p(
const mln_site(L)& p)
106 process__(accu_argument(), p);
110 void process_n(
const mln_site(L)& n)
112 process__(accu_argument(), n);
118 convert::from_to(accus_, result_);
124 void process__(
const mln_psite(L)&,
const mln_site(L)& p)
126 accus_[current_lbl_].take(p);
130 void process__(
const mln_value(L)&,
const mln_site(L)&)
132 accus_[current_lbl_].take(current_lbl_);
135 template <
typename V>
137 void process__(
const V&,
const mln_site(L)&)
139 mlc_abort(V)::check();
143 util::array<mln_result(A)> result_;
144 util::array<A> accus_;
145 mln_value(L) current_lbl_;
146 mln_value(L) nlabels_;
156 template <typename I, typename N, typename L, typename A>
157 util::couple<mln_ch_value(I,L),
158 util::couple<util::array<mln_result(A)>,
163 trace::entering(
"labeling::blobs_and_compute");
166 mlc_equal(mln_trait_image_kind(I),
167 mln::trait::image::kind::binary)::check();
168 mln_precondition(exact(input).is_valid());
170 typedef mln_ch_value(I,L) out_t;
171 typedef internal::compute_functor<out_t,A> func_t;
172 func_t functor(nlabels);
180 trace::exiting(
"labeling::blobs_and_compute");
185 # endif // ! MLN_INCLUDE_ONLY
193 #endif // ! MLN_LABELING_BLOBS_AND_COMPUTE_HH