27 #ifndef MLN_LABELING_MEAN_VALUES_HH
28 # define MLN_LABELING_MEAN_VALUES_HH
39 # include <mln/core/concept/image.hh>
40 # include <mln/core/alias/vec3d.hh>
42 # include <mln/accu/stat/mean.hh>
44 # include <mln/data/transform.hh>
46 # include <mln/labeling/compute.hh>
48 # include <mln/literal/colors.hh>
57 template <
unsigned n>
struct rgb;
72 template <
typename I,
typename L>
75 const Image<L>& lbl, mln_value(L) nlabels);
78 # ifndef MLN_INCLUDE_ONLY
83 template <
typename I,
typename L>
85 mean_values_tests(
const Image<I>& input,
86 const Image<L>& lbl, mln_value(L) nlabels)
88 mln_precondition(
exact(input).is_valid());
89 mln_precondition(
exact(lbl).is_valid());
104 template <
typename I,
typename L>
106 mean_values(const Image<I>& input_,
107 const Image<L>& lbl_, mln_value(L) nlabels)
109 mln_trace(
"mln::labeling::impl::generic::mean_values");
111 internal::mean_values_tests(input_, lbl_, nlabels);
113 const I& input =
exact(input_);
114 const L& lbl =
exact(lbl_);
115 typedef mln_value(L) LV;
116 typedef mln_value(I) IV;
118 util::array<
float> m_3f
136 template <typename I, typename L>
138 mean_values_rgb(const Image<I>& input_,
139 const Image<L>& lbl_, mln_value(L) nlabels)
141 mln_trace(
"mln::labeling::impl::mean_values_rgb");
143 internal::mean_values_tests(input_, lbl_, nlabels);
145 const I& input =
exact(input_);
146 const L& lbl =
exact(lbl_);
154 util::array<mln_value(I)> m;
159 convert::to< fun::i2v::array<mln_value(I)> >(m));
171 template <
unsigned n,
typename I,
typename L>
173 mean_values_dispatch(const
value::rgb<n>&,
174 const Image<I>& input,
175 const Image<L>& lbl, mln_value(L) nlabels)
177 return impl::mean_values_rgb(input, lbl, nlabels);
180 template <
typename I,
typename L>
182 mean_values_dispatch(const mln_value(I)&,
183 const Image<I>& input,
184 const Image<L>& lbl, mln_value(L) nlabels)
186 return impl::generic::mean_values(input, lbl, nlabels);
189 template <
typename I,
typename L>
191 mean_values_dispatch(const Image<I>& input,
192 const Image<L>& lbl, mln_value(L) nlabels)
194 return mean_values_dispatch(mln_value(I)(), input, lbl, nlabels);
203 template <
typename I,
typename L>
205 mean_values(const Image<I>& input,
206 const Image<L>& lbl, mln_value(L) nlabels)
209 mln_trace(
"mln::labeling::mean_values");
211 internal::mean_values_tests(input, lbl, nlabels);
213 mln_concrete(I) output = internal::mean_values_dispatch(input, lbl, nlabels);
219 # endif // !MLN_INCLUDE_ONLY
225 #endif // ! MLN_LABELING_MEAN_VALUES_HH