diff --git a/skimage/color/colorconv.py b/skimage/color/colorconv.py index 274581b5..5e2fa5e1 100644 --- a/skimage/color/colorconv.py +++ b/skimage/color/colorconv.py @@ -511,6 +511,9 @@ def rgb2grey(rgb): >>> lena = imread(os.path.join(data_dir, 'lena.png')) >>> lena_grey = rgb2grey(lena) """ + if rgb.ndim == 2: + return rgb + return _convert(grey_from_rgb, rgb[:, :, :3])[..., 0] rgb2gray = rgb2grey diff --git a/skimage/color/tests/test_colorconv.py b/skimage/color/tests/test_colorconv.py index 84c921b8..cfe81c58 100644 --- a/skimage/color/tests/test_colorconv.py +++ b/skimage/color/tests/test_colorconv.py @@ -146,6 +146,9 @@ class TestColorconv(TestCase): assert_equal(g.shape, (1, 1)) + def test_rgb2grey_on_grey(self): + rgb2grey(np.random.random((5, 5))) + def test_gray2rgb(): x = np.array([0, 0.5, 1])