From bcf45941700e3d1f7bde20c2070f237b45fcd1a3 Mon Sep 17 00:00:00 2001 From: Andreas Wuerl Date: Mon, 27 Aug 2012 15:18:03 +0200 Subject: [PATCH] use existing functionality for fix --- skimage/filter/_tv_denoise.py | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/skimage/filter/_tv_denoise.py b/skimage/filter/_tv_denoise.py index af8decfc..545f9e09 100644 --- a/skimage/filter/_tv_denoise.py +++ b/skimage/filter/_tv_denoise.py @@ -1,4 +1,5 @@ import numpy as np +from skimage.util import dtype def _tv_denoise_3d(im, weight=100, eps=2.e-4, n_iter_max=200): @@ -169,30 +170,6 @@ def _tv_denoise_2d(im, weight=50, eps=2.e-4, n_iter_max=200): E_previous = E i += 1 return out - -def _renormalize_image(image, data_type): - """ - inplace renormalize image date to obey the float range [0.0:1.0] - - Parameters - ---------- - immage: ndarray - input data to be renormalized - - data_type: type, - image data type before running tv_denoise - - Notes - ------- - the minimum and maximum values of the image data type define the range - which is mapped to the interval [0.0:1.0] - - """ - type_info = np.iinfo(data_type) - start = type_info.min - width = type_info.max - type_info.min - np.subtract(image, start, image) - np.divide(image, width, image) def tv_denoise(im, weight=50, eps=2.e-4, keep_type=False, n_iter_max=200): """ @@ -281,5 +258,5 @@ def tv_denoise(im, weight=50, eps=2.e-4, keep_type=False, n_iter_max=200): return out.astype(im_type) else: if not im_type.kind == 'f': - _renormalize_image(out, im_type) + out = dtype.convert(out.astype(im_type), np.float) return out