27 #ifndef MLN_LABELING_SUPERPOSE_HH
28 # define MLN_LABELING_SUPERPOSE_HH
35 # include <mln/core/concept/image.hh>
36 # include <mln/util/array.hh>
37 # include <mln/labeling/relabel.hh>
38 # include <mln/data/paste.hh>
39 # include <mln/pw/all.hh>
41 # include <mln/value/next.hh>
42 # include <mln/value/equiv.hh>
71 template <
typename I,
typename J>
73 superpose(const Image<I>& lhs, const mln_value(I)& lhs_nlabels,
74 const Image<J>&
rhs, const mln_value(J)& rhs_nlabels,
75 mln_value(I)& new_nlabels);
80 # ifndef MLN_INCLUDE_ONLY
82 template <
typename I,
typename J>
84 superpose(const Image<I>& lhs_, const mln_value(I)& lhs_nlabels,
85 const Image<J>& rhs_, const mln_value(J)& rhs_nlabels,
86 mln_value(I)& new_nlabels)
88 mln_trace(
"mln::labeling::superpose");
90 const I& lhs =
exact(lhs_);
91 const J& rhs =
exact(rhs_);
93 mlc_converts_to(mln_value(I), mln_value(J))::check();
94 mln_precondition(lhs.is_valid());
95 mln_precondition(rhs.is_valid());
96 mln_precondition(lhs.domain() == rhs.domain());
101 util::array<mln_value(J)>
102 rebase_lbl(
value::next(rhs_nlabels));
105 for (
unsigned i = 1; i <= rhs_nlabels; ++i)
106 rebase_lbl(i) = i +
value::equiv(lhs_nlabels);
109 | (pw::
value(rhs) != pw::cst(literal::zero)),
112 new_nlabels =
value::equiv(lhs_nlabels)
113 +
value::equiv(rhs_nlabels) + 1;
119 # endif // ! MLN_INCLUDE_ONLY
126 #endif // ! MLN_LABELING_SUPERPOSE_HH