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>
45 # include <mln/value/internal/encoding.hh>
63 template <
typename V,
typename I>
65 stretch(const V& v, const Image<I>& input);
68 # ifndef MLN_INCLUDE_ONLY
80 template <
typename V,
typename I>
85 trace::entering(
"data::impl::stretch");
88 mlc_converts_to(
float, V)::check();
90 mln_ch_value(I, V) output;
92 mln_value(I) min_, max_;
101 epsilon = mln_epsilon(
float),
102 M = mln_max(V) + 0.5f - epsilon,
103 m = 0.0f - 0.5f + epsilon,
104 a = (M - m) / (max - min),
105 b = (m * max - M * min) / (max - min);
106 fun::v2v::linear_sat<mln_value(I), double, V> f(a, b);
112 trace::warning(
"output has no significative data!");
115 trace::exiting(
"data::impl::stretch");
125 template <
typename V,
typename I>
130 trace::entering(
"data::stretch");
133 mln_precondition(exact(input).is_valid());
137 trace::exiting(
"data::stretch");
141 # endif // ! MLN_INCLUDE_ONLY
148 #endif // ! MLN_DATA_STRETCH_HH