BUG: Allow RGB images to be passed to grey2rgb.

This commit is contained in:
Stefan van der Walt
2012-10-15 22:44:01 -07:00
parent 2342cdd79c
commit 120571b079
2 changed files with 15 additions and 5 deletions
+8 -5
View File
@@ -525,11 +525,14 @@ def gray2rgb(image):
If the input is not 2-dimensional.
"""
if image.ndim != 2:
raise ValueError('Gray-level image should be two-dimensional.')
M, N = image.shape
return np.dstack((image, image, image))
if image.ndim > 2:
return image
elif image.ndim == 2:
M, N = image.shape
return np.dstack((image, image, image))
else:
raise ValueError('Gray-level image should be two-dimensional, '
'RGB or RGBA.')
def xyz2lab(xyz):
+7
View File
@@ -196,5 +196,12 @@ def test_gray2rgb():
assert_equal(z[..., 0], x)
assert_equal(z[0, 1, :], [128, 128, 128])
def test_gray2rgb_rgb():
x = np.random.random((5, 5, 4))
y = gray2rgb(x)
assert_equal(x, y)
if __name__ == "__main__":
run_module_suite()