27 #ifndef MLN_DATA_STRETCH_HH
28 # define MLN_DATA_STRETCH_HH
39 # include <mln/estim/min_max.hh>
40 # include <mln/value/int_u.hh>
41 # include <mln/fun/v2v/linear.hh>
42 # include <mln/data/transform.hh>
44 # include <mln/value/internal/encoding.hh>
65 template <
typename V,
typename I>
67 stretch(const V& v, const Image<I>& input);
70 # ifndef MLN_INCLUDE_ONLY
82 template <
typename V,
typename I>
85 stretch(const V&, const Image<I>& input)
87 mln_trace(
"data::impl::stretch");
89 mlc_converts_to(
float, V)::check();
91 mln_ch_value(I, V) output;
93 mln_value(I) min_, max_;
94 estim::min_max(input, min_, max_);
102 epsilon = mln_epsilon(
float),
103 M = mln_max(V) + 0.5f - epsilon,
104 m = 0.0f - 0.5f + epsilon,
105 a = (M - m) / (
max - min),
107 fun::v2v::linear_sat<mln_value(I), double, V> f(a, b);
113 mln_trace_warning(
"output has no significative data!");
125 template <
typename V,
typename I>
128 stretch(const V&, const Image<I>& input)
130 mln_trace(
"data::stretch");
132 mln_precondition(
exact(input).is_valid());
134 mln_ch_value(I, V) output = impl::
stretch(V(), input);
139 # endif // ! MLN_INCLUDE_ONLY
146 #endif // ! MLN_DATA_STRETCH_HH