27 #ifndef MLN_HISTO_EQUALIZE_HH
28 # define MLN_HISTO_EQUALIZE_HH
31 # include <mln/core/concept/image.hh>
32 # include <mln/histo/all.hh>
52 mln_concrete(I)
equalize(const Image<I>& input);
55 # ifndef MLN_INCLUDE_ONLY
61 mln_trace(
"mln::histo::equalize");
63 const I& input =
exact(input_);
64 mln_precondition(input.is_valid());
66 typedef mln_value(I) V;
67 array<V> histogram =
compute(input);
68 array<V> histo_correction;
71 V max_color = mln_max(V);
73 unsigned h_min = nsites;
74 mln_viter(mln::
value::set<V>) v(histogram.vset());
78 if (histogram(v) > 0 && h_min > histogram(v))
84 if (histogram(v) != 0)
86 cdf_v += histogram(v);
88 =
round((cdf_v - h_min) / (
float)(nsites - h_min) * max_color);
91 mln_concrete(I) output;
93 mln_piter(I)
p(input.domain());
95 output(
p) = histo_correction[input(
p)];
100 # endif // ! MLN_INCLUDE_ONLY
108 #endif // ! MLN_HISTO_EQUALIZE_HH