diff --git a/skimage/color/colorconv.py b/skimage/color/colorconv.py index 7848d33d..d1129ec2 100644 --- a/skimage/color/colorconv.py +++ b/skimage/color/colorconv.py @@ -103,7 +103,7 @@ def convert_colorspace(arr, fromspace, tospace): return todict[tospace](fromdict[fromspace](arr)) -def _prepare_colorarray(arr, dtype=np.float32): +def _prepare_colorarray(arr): """Check the shape of the array, and give it the requested type.""" arr = np.asanyarray(arr) @@ -111,7 +111,7 @@ def _prepare_colorarray(arr, dtype=np.float32): msg = "the input array must be have a shape == (.,.,3))" raise ValueError(msg) - return arr.astype(dtype) + return dtype.img_as_float(arr) def rgb2hsv(rgb): @@ -303,7 +303,6 @@ def _convert(matrix, arr): out : ndarray, dtype=float The converted array. """ - arr = dtype.img_as_float(arr) arr = _prepare_colorarray(arr) arr = np.swapaxes(arr, 0, 2) oldshape = arr.shape diff --git a/skimage/color/tests/test_colorconv.py b/skimage/color/tests/test_colorconv.py index fef9bb17..03c23142 100644 --- a/skimage/color/tests/test_colorconv.py +++ b/skimage/color/tests/test_colorconv.py @@ -44,7 +44,7 @@ class TestColorconv(TestCase): # RGB to HSV def test_rgb2hsv_conversion(self): - rgb = self.img_rgb.astype("float32")[::16, ::16] + rgb = img_as_float(self.img_rgb)[::16, ::16] hsv = rgb2hsv(rgb).reshape(-1, 3) # ground truth from colorsys gt = np.array([colorsys.rgb_to_hsv(pt[0], pt[1], pt[2])