27 #ifndef MLN_LABELING_VALUE_HH
28 # define MLN_LABELING_VALUE_HH
34 # include <mln/core/concept/image.hh>
35 # include <mln/core/concept/neighborhood.hh>
36 # include <mln/canvas/labeling/video.hh>
37 # include <mln/data/fill.hh>
56 template <
typename I,
typename N,
typename L>
58 value(const Image<I>& input, const mln_value(I)& val,
59 const Neighborhood<N>& nbh, L& nlabels);
62 # ifndef MLN_INCLUDE_ONLY
70 template <
typename I,
typename N,
typename L>
72 value_tests(
const Image<I>& input,
const mln_value(I)& val,
const Neighborhood<N>& nbh,
75 mln_precondition(exact(input).is_valid());
76 mln_precondition(exact(nbh).is_valid());
93 template <
typename I,
typename L>
96 typedef mln_psite(I) P;
99 const mln_value(I)& val;
103 typedef mln_domain(I) S;
108 bool handles(
const P& p)
const {
return input(p) == val; }
109 bool equiv(
const P& n,
const P&)
const {
return input(n) == val; }
110 bool labels(
const P&)
const {
return true; }
111 void do_no_union(
const P&,
const P&) {}
112 void init_attr(
const P&) {}
113 void merge_attr(
const P&,
const P&) {}
114 void set_new_label(
const P&,
const L&) {}
115 void set_label(
const P&,
const L&) {}
121 bool handles_(
unsigned p)
const {
return input.element(p) == val; }
122 bool equiv_(
unsigned n,
unsigned)
const {
return input.element(n) == val; }
123 bool labels_(
unsigned)
const {
return true; }
124 void do_no_union_(
unsigned,
unsigned) {}
125 void init_attr_(
unsigned) {}
126 void merge_attr_(
unsigned,
unsigned) {}
127 void set_new_label_(
unsigned,
const L&) {}
128 void set_label_(
unsigned,
const L&) {}
133 value_functor(
const Image<I>& input_,
const mln_value(I)& val)
134 : input(exact(input_)),
147 template <
typename I,
typename N,
typename L>
152 trace::entering(
"labeling::value");
154 internal::value_tests(input, val, nbh, nlabels);
156 mln_ch_value(I, L) output;
157 impl::value_functor<I,L> f(input, val);
158 output = canvas::labeling::video(input, nbh, nlabels, f);
160 trace::exiting(
"labeling::value");
164 # endif // ! MLN_INCLUDE_ONLY
171 #endif // ! MLN_LABELING_VALUE_HH