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>
56 template <
typename I,
typename N,
typename L>
62 # ifndef MLN_INCLUDE_ONLY
70 struct regional_minima_functor
72 typedef mln_psite(I) P;
81 bool handles(
const P&)
const {
return true; }
82 bool labels(
const P& p)
const {
return attr(p); }
83 bool equiv(
const P& n,
const P& p)
const {
return input(n) ==
85 void do_no_union(
const P& n,
const P& p)
91 mln_invariant(input(n) < input(p));
95 void init_attr(
const P&) {}
96 void merge_attr(
const P& r,
const P& p) { attr(p) = attr(p) &&
102 bool handles_(
unsigned)
const {
return true; }
103 bool labels_(
unsigned p)
const {
return attr.element(p); }
104 bool equiv_(
unsigned n,
unsigned p)
const {
return input.element(n) ==
106 void do_no_union_(
unsigned n,
unsigned p)
112 mln_invariant(input.element(n) < input.element(p));
113 attr.element(p) =
false;
116 void init_attr_(
unsigned) {}
117 void merge_attr_(
unsigned r,
unsigned p) { attr.element(p) = attr.element(p) &&
122 mln_ch_value(I,
bool) attr;
124 regional_minima_functor(const I& input)
138 template <
typename I,
typename N,
typename L>
143 trace::entering(
"labeling::regional_minima");
145 const I& input = exact(input_);
146 const N& nbh = exact(nbh_);
147 mln_precondition(input.is_valid());
152 typedef impl::regional_minima_functor<I> F;
155 output = canvas::labeling::sorted(input, nbh, nlabels, f,
false);
157 trace::exiting(
"labeling::regional_minima");
161 # endif // ! MLN_INCLUDE_ONLY
168 #endif // ! MLN_LABELING_REGIONAL_MINIMA_HH