use existing functionality for fix

This commit is contained in:
Andreas Wuerl
2012-08-27 15:18:03 +02:00
parent 14d0923959
commit bcf4594170
+2 -25
View File
@@ -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