From 487f16562257778b4aced56de126f7fddffc9159 Mon Sep 17 00:00:00 2001 From: Andreas Mueller Date: Thu, 29 Sep 2011 13:30:53 +0200 Subject: [PATCH] slightly faster image conversion by creating less temporaries. --- scikits/image/util/dtype.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scikits/image/util/dtype.py b/scikits/image/util/dtype.py index b859f044..b1b5600d 100644 --- a/scikits/image/util/dtype.py +++ b/scikits/image/util/dtype.py @@ -75,7 +75,10 @@ def _convert(image, dtype, prec_loss): # Do scaling/shifting calculations in floating point image = image.astype(np.float64) - out = round_fn((image - imin) * scale + shift).astype(dtype) + out = image - imin + out *= scale + out += shift + out = round_fn(out).astype(dtype) return out