* mln/data/stretch.hh,
* mln/data/stretch_inplace.hh: always perform stretch if min !=
max.
---
milena/ChangeLog | 8 ++++++++
milena/mln/data/stretch.hh | 10 ++++++++--
milena/mln/data/stretch_inplace.hh | 28 +++++++++++++++++-----------
3 files changed, 33 insertions(+), 13 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 5d8ff07..3b4dc77 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,11 @@
+2013-04-29 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Always perform data::stretch if min != max.
+
+ * mln/data/stretch.hh,
+ * mln/data/stretch_inplace.hh: always perform stretch if min !=
+ max.
+
2013-04-26 Guillaume Lazzara <z(a)lrde.epita.fr>
Regen generated files in Milena.
diff --git a/milena/mln/data/stretch.hh b/milena/mln/data/stretch.hh
index e8a6d09..2473494 100644
--- a/milena/mln/data/stretch.hh
+++ b/milena/mln/data/stretch.hh
@@ -80,7 +80,7 @@ namespace mln
template <typename V, typename I>
inline
mln_ch_value(I, V)
- stretch(const V& v, const Image<I>& input)
+ stretch(const V& v, const Image<I>& input)
{
mln_trace("data::impl::stretch");
@@ -91,8 +91,14 @@ namespace mln
mln_value(I) min_, max_;
estim::min_max(input, min_, max_);
- if (max_ != min_ && (mln_max(V) > max_ || mln_min(V) < min_))
+ if (max_ != min_)
{
+ // We always want to perform this algorithm even if (min_ ==
+ // mln_min(V) and max_ == mln_max(V)) since we need to
+ // convert the input image towards the given type and a
+ // default conversion function may not exist between V and
+ // mln_value(I).
+
//FIXME: we would like to use float instead of double but we
//can't for precision reasons. See ticket #179.
double
diff --git a/milena/mln/data/stretch_inplace.hh b/milena/mln/data/stretch_inplace.hh
index c0630e1..698f342 100644
--- a/milena/mln/data/stretch_inplace.hh
+++ b/milena/mln/data/stretch_inplace.hh
@@ -90,18 +90,24 @@ namespace mln
V min_, max_;
estim::min_max(ima, min_, max_);
- if (max_ != min_ && (mln_max(V) > max_ || mln_min(V) < min_))
+ if (max_ != min_)
{
- //FIXME: we would like to use float instead of double but we
- //can't for precision reasons. See ticket #179.
- double
- min = double(min_),
- max = double(max_),
- epsilon = mln_epsilon(float),
- M = mln_max(V) + 0.5f - epsilon,
- m = 0.0f - 0.5f + epsilon,
- a = (M - m) / (max - min),
- b = (m * max - M * min) / (max - min);
+ // We always want to perform this algorithm even if (min_ ==
+ // mln_min(V) and max_ == mln_max(V)) since we need to
+ // convert the input image towards the given type and a
+ // default conversion function may not exist between V and
+ // mln_value(I).
+
+ //FIXME: we would like to use float instead of double but we
+ //can't for precision reasons. See ticket #179.
+ double
+ min = double(min_),
+ max = double(max_),
+ epsilon = mln_epsilon(float),
+ M = mln_max(V) + 0.5f - epsilon,
+ m = 0.0f - 0.5f + epsilon,
+ a = (M - m) / (max - min),
+ b = (m * max - M * min) / (max - min);
fun::v2v::linear_sat<V, double, V> f(a, b);
data::transform_inplace(ima, f);
stretched = true;
--
1.7.2.5
Show replies by date