mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-04 17:40:07 +08:00
BUG: Allow RGB images to be passed to grey2rgb.
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user