27 #ifndef MLN_LABELING_REGIONAL_MAXIMA_HH
28 # define MLN_LABELING_REGIONAL_MAXIMA_HH
34 # include <mln/core/concept/image.hh>
35 # include <mln/core/concept/neighborhood.hh>
36 # include <mln/canvas/labeling/sorted.hh>
37 # include <mln/data/fill.hh>
38 # include <mln/data/sort_psites.hh>
56 template <
typename I,
typename N,
typename L>
63 # ifndef MLN_INCLUDE_ONLY
71 struct regional_maxima_functor
73 typedef mln_psite(I) P;
82 bool handles(
const P&)
const {
return true; }
83 bool labels(
const P& p)
const {
return attr(p); }
84 bool equiv(
const P& n,
const P& p)
const {
return input(n) ==
86 void do_no_union(
const P& n,
const P& p) { mln_invariant(input(n) >
88 attr(p) =
false; (void)n; }
89 void init_attr(
const P&) {}
90 void merge_attr(
const P& r,
const P& p) { attr(p) = attr(p) &&
96 bool handles_(
unsigned)
const {
return true; }
97 bool labels_(
unsigned p)
const {
return attr.element(p); }
98 bool equiv_(
unsigned n,
unsigned p)
const {
return input.element(n) ==
100 void do_no_union_(
unsigned n,
unsigned p) {
102 attr.element(p) =
false;
105 void init_attr_(
unsigned) {}
106 void merge_attr_(
unsigned r,
unsigned p) { attr.element(p) = attr.element(p) &&
111 mln_ch_value(I,
bool) attr;
113 regional_maxima_functor(const I& input)
128 template <
typename I,
typename N,
typename L>
133 trace::entering(
"labeling::regional_maxima");
135 const I& input = exact(input_);
136 const N& nbh = exact(nbh_);
137 mln_precondition(input.is_valid());
139 typedef impl::regional_maxima_functor<I> F;
142 output = canvas::labeling::sorted(input, nbh, nlabels, f,
true);
144 trace::exiting(
"labeling::regional_maxima");
148 # endif // ! MLN_INCLUDE_ONLY
155 #endif // ! MLN_LABELING_REGIONAL_MAXIMA_HH