27 #ifndef MLN_LABELING_REGIONAL_MINIMA_HH
28 # define MLN_LABELING_REGIONAL_MINIMA_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>
63 # ifndef MLN_INCLUDE_ONLY
71 struct regional_minima_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)
92 mln_invariant(input(n) < input(p));
96 void init_attr(
const P&) {}
97 void merge_attr(
const P& r,
const P& p) { attr(p) = attr(p) &&
103 bool handles_(
unsigned)
const {
return true; }
104 bool labels_(
unsigned p)
const {
return attr.element(p); }
105 bool equiv_(
unsigned n,
unsigned p)
const {
return input.element(n) ==
107 void do_no_union_(
unsigned n,
unsigned p)
113 mln_invariant(input.element(n) < input.element(p));
114 attr.element(p) =
false;
117 void init_attr_(
unsigned) {}
118 void merge_attr_(
unsigned r,
unsigned p) { attr.element(p) = attr.element(p) &&
123 mln_ch_value(I,
bool) attr;
125 regional_minima_functor(const I& input)
139 template <
typename I,
typename N,
typename L>
144 mln_trace(
"labeling::regional_minima");
146 const I& input =
exact(input_);
147 const N& nbh =
exact(nbh_);
148 mln_precondition(input.is_valid());
153 typedef impl::regional_minima_functor<I> F;
161 # endif // ! MLN_INCLUDE_ONLY
168 #endif // ! MLN_LABELING_REGIONAL_MINIMA_HH