27 #ifndef SCRIBO_PRIMITIVE_GROUP_APPLY_HH
28 # define SCRIBO_PRIMITIVE_GROUP_APPLY_HH
34 # include <mln/fun/i2v/array.hh>
35 # include <mln/make/relabelfun.hh>
36 # include <mln/labeling/relabel.hh>
38 # include <scribo/core/object_links.hh>
39 # include <scribo/core/object_groups.hh>
40 # include <scribo/core/component_set.hh>
42 # include <scribo/primitive/group/from_single_link.hh>
63 apply(
const object_groups<L>& groups);
68 apply(
const object_links<L>& links);
72 # ifndef MLN_INCLUDE_ONLY
77 apply(
const object_groups<L>& groups,
81 mln_trace(
"scribo::primitive::group::apply");
83 mln_precondition(groups.is_valid());
85 const component_set<L>&
components = groups.components();
92 for_all_groups(g, groups)
93 if (!groups(g).is_valid())
94 for_all_elements(c, groups(g).component_ids())
95 tmp(groups(g).component_ids()(c)) = 0;
97 mln_value(L) new_nlabels;
98 relabel_fun = mln::make::relabelfun(tmp,
99 components.nelements(),
105 component_set<L> output(labeled_image, new_nlabels);
111 template <typename L>
113 apply(const object_groups<L>& groups)
116 return apply(groups, relabel_fun);
120 template <
typename L>
122 apply(
const object_links<L>& links)
125 mln_trace(
"scribo::primitive::group::apply");
127 mln_precondition(links.is_valid());
130 component_set<L> output =
apply(group);
136 # endif // ! MLN_INCLUDE_ONLY
144 #endif // ! SCRIBO_PRIMITIVE_GROUP_APPLY_HH