27 #ifndef MLN_LABELING_FLAT_ZONES_HH
28 # define MLN_LABELING_FLAT_ZONES_HH
34 # include <mln/core/concept/image.hh>
35 # include <mln/core/concept/neighborhood.hh>
36 # include <mln/canvas/labeling/video.hh>
52 template <
typename I,
typename N,
typename L>
54 flat_zones(const Image<I>& input, const Neighborhood<N>& nbh,
59 # ifndef MLN_INCLUDE_ONLY
66 template <
typename I,
typename L>
67 struct flat_zones_functor
73 typedef mln_psite(I) P;
76 bool handles(
const P&)
const {
return true; }
78 bool equiv(
const P& n,
const P& p)
const
79 {
return input(n) == input(p); }
81 bool labels(
const P&)
const {
return true; }
82 void do_no_union(
const P&,
const P&) {}
83 void init_attr(
const P&) {}
84 void merge_attr(
const P&,
const P&) {}
85 void set_new_label(
const P&,
const L&){}
86 void set_label(
const P&,
const L&) {}
94 bool handles_(
unsigned)
const
97 bool equiv_(
unsigned n,
unsigned p)
const
98 {
return input.element(n) == input.element(p); }
100 bool labels_(
unsigned)
const {
return true; }
101 void do_no_union_(
unsigned,
unsigned) {}
102 void init_attr_(
unsigned) {}
103 void merge_attr_(
unsigned,
unsigned) {}
104 void set_new_label_(
unsigned,
const L&) {}
105 void set_label_(
unsigned,
const L&) {}
110 flat_zones_functor(
const I& input)
122 template <
typename I,
typename N,
typename L>
127 trace::entering(
"labeling::flat_zones");
129 const I& input = exact(input_);
130 const N& nbh = exact(nbh_);
131 mln_precondition(input.is_valid());
134 typedef impl::flat_zones_functor<I,L> F;
137 output = canvas::labeling::video(input, nbh, nlabels, f);
139 trace::exiting(
"labeling::flat_zones");
143 # endif // ! MLN_INCLUDE_ONLY
150 #endif // ! MLN_LABELING_FLAT_ZONES_HH