Skip to content

Commit

Permalink
workaround: convert dtype(image) to image.astype(dtype)
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Warner (Mac) committed Mar 21, 2013
1 parent c64350a commit 4b43e9f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions skimage/util/dtype.py
Expand Up @@ -176,7 +176,7 @@ def _scale(a, n, m, copy=True):


if kind_in == 'b': if kind_in == 'b':
# from binary image, to float and to integer # from binary image, to float and to integer
result = dtype(image) result = image.astype(dtype)
if kind != 'f': if kind != 'f':
result *= dtype(dtype_range[dtype][1]) result *= dtype(dtype_range[dtype][1])
return result return result
Expand All @@ -195,7 +195,7 @@ def _scale(a, n, m, copy=True):
# floating point -> floating point # floating point -> floating point
if itemsize_in > itemsize: if itemsize_in > itemsize:
prec_loss() prec_loss()
return dtype(image) return image.astype(dtype)


# floating point -> integer # floating point -> integer
prec_loss() prec_loss()
Expand All @@ -218,7 +218,7 @@ def _scale(a, n, m, copy=True):
image *= (imax - imin + 1.0) / 2.0 image *= (imax - imin + 1.0) / 2.0
np.floor(image, out=image) np.floor(image, out=image)
np.clip(image, imin, imax, out=image) np.clip(image, imin, imax, out=image)
return dtype(image) return image.astype(dtype)


if kind == 'f': if kind == 'f':
# integer -> floating point # integer -> floating point
Expand All @@ -236,7 +236,7 @@ def _scale(a, n, m, copy=True):
image *= 2.0 image *= 2.0
image += 1.0 image += 1.0
image /= imax_in - imin_in image /= imax_in - imin_in
return dtype(image) return image.astype(dtype)


if kind_in == 'u': if kind_in == 'u':
if kind == 'i': if kind == 'i':
Expand All @@ -262,7 +262,7 @@ def _scale(a, n, m, copy=True):
image -= imin_in image -= imin_in
image = _scale(image, 8 * itemsize_in, 8 * itemsize, copy=False) image = _scale(image, 8 * itemsize_in, 8 * itemsize, copy=False)
image += imin image += imin
return dtype(image) return image.astype(dtype)




def img_as_float(image, force_copy=False): def img_as_float(image, force_copy=False):
Expand Down

0 comments on commit 4b43e9f

Please sign in to comment.