26 #ifndef MLN_MAKE_RAG_AND_LABELED_WSL_HH
27 # define MLN_MAKE_RAG_AND_LABELED_WSL_HH
40 # include <mln/core/concept/image.hh>
41 # include <mln/core/concept/neighborhood.hh>
42 # include <mln/core/image/image2d.hh>
43 # include <mln/core/alias/box2d.hh>
44 # include <mln/extension/adjust_fill.hh>
45 # include <mln/util/graph.hh>
46 # include <mln/util/couple.hh>
91 template <
typename I,
typename N>
92 util::couple<util::graph,mln_concrete(I)>
94 const Neighborhood<N>& nbh_,
95 const mln_value(I)& nbasins);
99 # ifndef MLN_INCLUDE_ONLY
105 template <
typename I,
typename N>
108 rag_and_labeled_wsl_tests(
const Image<I>& wshd,
109 const Neighborhood<N>& nbh,
112 mln_precondition(
exact(wshd).is_valid());
113 mln_precondition(
exact(nbh).is_valid());
127 template <
typename I,
typename N>
129 util::couple<util::graph,mln_concrete(I)>
131 const Neighborhood<N>& nbh_,
132 const mln_value(I)& nbasins)
134 mln_trace(
"make::impl::generic::rag_and_labeled_wsl");
136 internal::rag_and_labeled_wsl_tests(wshd_, nbh_, nbasins);
137 const I& wshd =
exact(wshd_);
138 const N& nbh =
exact(nbh_);
139 typedef mln_value(I) L;
143 mln_concrete(I) output(wshd.domain());
147 data::
fill(output, mln_max(mln_value(I)).prev());
149 std::map<util::
couple<L,L>, mln_value(I)> c2la;
150 util::array<util::
couple<L,L> > la2c;
151 mln_value(I) nlabels = literal::zero;
154 mln_piter(I)
p(wshd.domain());
155 mln_niter(N) n(nbh,
p);
163 if (wshd.has(n) && wshd(n) != 0u)
170 mln_invariant(l2 == 0u);
175 if (l2 == 0u || l1 == 0u)
182 if (c2la.find(c) == c2la.end())
193 g.add_vertices(nbasins.next());
194 for (
unsigned i = 0; i < la2c.nelements(); ++i)
195 g.add_edge(la2c[i].first(), la2c[i].second());
209 template <
typename I,
typename N>
211 util::couple<util::graph,mln_concrete(I)>
212 rag_and_labeled_wsl_dispatch(
const Image<I>& wshd,
213 const Neighborhood<N>& nbh,
214 const mln_value(I)& nbasins)
225 template <
typename I,
typename N>
227 util::couple<util::graph,mln_concrete(I)>
229 const Neighborhood<N>& nbh,
230 const mln_value(I)& nbasins)
232 mln_trace(
"make::rag_and_labeled_wsl");
234 internal::rag_and_labeled_wsl_tests(wshd, nbh, nbasins);
236 util::couple<util::graph,mln_concrete(I)>
237 result = internal::rag_and_labeled_wsl_dispatch(wshd, nbh, nbasins);
243 # endif // ! MLN_INCLUDE_ONLY
251 #endif // ! MLN_MAKE_RAG_AND_LABELED_WSL_HH