30 #ifndef SCRIBO_PRIMITIVE_MERGE_COMPONENTS_HH
31 # define SCRIBO_PRIMITIVE_MERGE_COMPONENTS_HH
33 # include <mln/core/concept/function.hh>
34 # include <mln/core/image/vmorph/fun_image.hh>
35 # include <mln/data/fill.hh>
36 # include <mln/pw/all.hh>
38 # include <scribo/core/component_set.hh>
53 # ifndef MLN_INCLUDE_ONLY
67 rebase_label(
const V& base_label)
68 : base_label_(base_label)
71 V operator()(
const V& v)
const
88 components(
const component_set<L>& lhs,
const component_set<L>& rhs)
90 mln_trace(
"scribo::primitive::merge::components");
92 const L& lhs_lbl = lhs.labeled_image();
93 const L& rhs_lbl = rhs.labeled_image();
95 typedef mln_value(L) V;
98 V nlabels =
unsigned(lhs.nelements()) +
unsigned(rhs.nelements());
107 internal::rebase_label<V> f(lhs.nelements());
108 fun_image<internal::rebase_label<V>, L> fima(f, rhs_lbl);
109 data::
fill((lbl_merge | (pw::
value(lbl_merge) == pw::cst(0))).rw(), fima);
111 component_set<L> output(lbl_merge, nlabels);
116 # endif // ! MLN_INCLUDE_ONLY
125 #endif // ! SCRIBO_PRIMITIVE_MERGE_COMPONENTS_HH