26 #ifndef MLN_TOPO_SKELETON_BREADTH_FIRST_THINNING_HH
27 # define MLN_TOPO_SKELETON_BREADTH_FIRST_THINNING_HH
35 # include <mln/core/routine/duplicate.hh>
37 # include <mln/core/concept/image.hh>
38 # include <mln/core/concept/neighborhood.hh>
40 # include <mln/core/site_set/p_set.hh>
42 # include <mln/fun/p2b/tautology.hh>
67 template <
typename I,
typename N,
typename F,
typename G,
typename H>
69 breadth_first_thinning(const Image<I>& input,
70 const Neighborhood<N>& nbh,
71 Function_v2b<F>& is_simple,
73 const Function_v2b<H>& constraint =
74 fun::p2b::tautology());
77 # ifndef MLN_INCLUDE_ONLY
79 template <
typename I,
typename N,
typename F,
typename G,
typename H>
82 breadth_first_thinning(const Image<I>& input_,
83 const Neighborhood<N>& nbh_,
84 Function_v2b<F>& is_simple_,
86 const Function_v2b<H>& constraint_)
88 const I& input = exact(input_);
89 const N& nbh = exact(nbh_);
90 F& is_simple = exact(is_simple_);
91 const H& constraint = exact(constraint_);
95 is_simple.set_image(output);
97 typedef mln_psite(I) psite;
98 typedef p_set<psite> set_t;
101 mln_piter(I) p_(output.domain());
110 if (output(p) && constraint(p) && is_simple(p))
114 while (!
set.is_empty())
123 mln_piter(set_t) ps(set);
129 for (
unsigned i = 0; i <
set.nsites(); ++i)
137 if (constraint(p) && is_simple(p))
140 mln_niter(N) n(nbh, p);
142 if (output.domain().has(n)
143 && output(n) && constraint(p) && is_simple(n))
148 std::swap(set, next_set);
153 # endif // MLN_INCLUDE_ONLY
161 #endif // ! MLN_TOPO_SKELETON_BREADTH_FIRST_THINNING_HH