mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-12 22:16:49 +08:00
use existing functionality for fix
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user