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>
57 template <
typename I,
typename N,
typename L>
64 # ifndef MLN_INCLUDE_ONLY
72 struct regional_maxima_functor
74 typedef mln_psite(I) P;
83 bool handles(
const P&)
const {
return true; }
84 bool labels(
const P&
p)
const {
return attr(p); }
85 bool equiv(
const P& n,
const P&
p)
const {
return input(n) ==
87 void do_no_union(
const P& n,
const P&
p) { mln_invariant(input(n) >
89 attr(p) =
false; (void)n; }
90 void init_attr(
const P&) {}
91 void merge_attr(
const P& r,
const P& p) { attr(p) = attr(p) &&
97 bool handles_(
unsigned)
const {
return true; }
98 bool labels_(
unsigned p)
const {
return attr.element(p); }
99 bool equiv_(
unsigned n,
unsigned p)
const {
return input.element(n) ==
101 void do_no_union_(
unsigned n,
unsigned p) {
103 attr.element(p) =
false;
106 void init_attr_(
unsigned) {}
107 void merge_attr_(
unsigned r,
unsigned p) { attr.element(p) = attr.element(p) &&
112 mln_ch_value(I,
bool) attr;
114 regional_maxima_functor(const I& input)
129 template <
typename I,
typename N,
typename L>
134 mln_trace(
"labeling::regional_maxima");
136 const I& input =
exact(input_);
137 const N& nbh =
exact(nbh_);
138 mln_precondition(input.is_valid());
140 typedef impl::regional_maxima_functor<I> F;
148 # endif // ! MLN_INCLUDE_ONLY
155 #endif // ! MLN_LABELING_REGIONAL_MAXIMA_HH