mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-03 01:09:26 +08:00
Merge pull request #477 from JDWarner/convert_dtype_to_astype
Use `image.astype(dtype)` instead of `dtype(image)`
This commit is contained in:
@@ -176,7 +176,7 @@ def convert(image, dtype, force_copy=False, uniform=False):
|
||||
|
||||
if kind_in == 'b':
|
||||
# from binary image, to float and to integer
|
||||
result = dtype(image)
|
||||
result = image.astype(dtype)
|
||||
if kind != 'f':
|
||||
result *= dtype(dtype_range[dtype][1])
|
||||
return result
|
||||
@@ -195,7 +195,7 @@ def convert(image, dtype, force_copy=False, uniform=False):
|
||||
# floating point -> floating point
|
||||
if itemsize_in > itemsize:
|
||||
prec_loss()
|
||||
return dtype(image)
|
||||
return image.astype(dtype)
|
||||
|
||||
# floating point -> integer
|
||||
prec_loss()
|
||||
@@ -218,7 +218,7 @@ def convert(image, dtype, force_copy=False, uniform=False):
|
||||
image *= (imax - imin + 1.0) / 2.0
|
||||
np.floor(image, out=image)
|
||||
np.clip(image, imin, imax, out=image)
|
||||
return dtype(image)
|
||||
return image.astype(dtype)
|
||||
|
||||
if kind == 'f':
|
||||
# integer -> floating point
|
||||
@@ -236,7 +236,7 @@ def convert(image, dtype, force_copy=False, uniform=False):
|
||||
image *= 2.0
|
||||
image += 1.0
|
||||
image /= imax_in - imin_in
|
||||
return dtype(image)
|
||||
return image.astype(dtype)
|
||||
|
||||
if kind_in == 'u':
|
||||
if kind == 'i':
|
||||
@@ -262,7 +262,7 @@ def convert(image, dtype, force_copy=False, uniform=False):
|
||||
image -= imin_in
|
||||
image = _scale(image, 8 * itemsize_in, 8 * itemsize, copy=False)
|
||||
image += imin
|
||||
return dtype(image)
|
||||
return image.astype(dtype)
|
||||
|
||||
|
||||
def img_as_float(image, force_copy=False):
|
||||
|
||||
Reference in New Issue
Block a user