26 #ifndef MLN_MORPHO_MEYER_WST_HH
27 # define MLN_MORPHO_MEYER_WST_HH
49 # include <mln/trait/ch_value.hh>
52 # include <mln/util/greater_psite.hh>
53 # include <mln/morpho/includes.hh>
54 # include <mln/literal/zero.hh>
55 # include <mln/labeling/regional_minima.hh>
57 # include <mln/core/site_set/p_queue_fast.hh>
58 # include <mln/core/site_set/p_priority.hh>
77 template <
typename L,
typename I,
typename N>
79 meyer_wst(const Image<I>& input, const Neighborhood<N>& nbh,
98 template <typename L, typename I, typename N>
100 meyer_wst(const Image<I>& input, const Neighborhood<N>& nbh);
104 # ifndef MLN_INCLUDE_ONLY
106 template <
typename L,
typename I,
typename N>
111 trace::entering(
"morpho::meyer_wst");
114 const I input = exact(input_);
115 const N nbh = exact(nbh_);
120 typedef mln_value(I) V;
121 const V max = mln_max(V);
124 mln_ch_value(I, marker) output =
127 typedef mln_psite(I) psite;
134 mln_ch_value(I,
bool) in_queue;
141 mln_piter(I) p(output.domain());
142 mln_niter(N) n(nbh, p);
144 if (output(p) == unmarked)
146 if (output.domain().has(n) && output(n) != unmarked)
148 queue.
push(max - input(p), p);
156 while (! queue.is_empty())
158 psite p = queue.
front();
161 marker adjacent_marker = unmarked;
163 bool single_adjacent_marker_p =
true;
164 mln_niter(N) n(nbh, p);
166 if (output.domain().has(n) && output(n) != unmarked)
168 if (adjacent_marker == unmarked)
170 adjacent_marker = output(n);
171 single_adjacent_marker_p =
true;
174 if (adjacent_marker != output(n))
176 single_adjacent_marker_p =
false;
184 if (single_adjacent_marker_p)
186 output(p) = adjacent_marker;
188 if (output.domain().has(n) && output(n) == unmarked
191 queue.
push(max - input(n), n);
196 trace::exiting(
"morpho::meyer_wst");
200 template <
typename L,
typename I,
typename N>
205 return meyer_wst<L>(input, nbh, nbasins);
208 # endif // ! MLN_INCLUDE_ONLY
215 #endif // ! MLN_MORPHO_MEYER_WST_HH