BUG: Allow rgb2grey to be called on grey-level images.

This commit is contained in:
Stefan van der Walt
2012-07-08 17:49:17 -07:00
parent de74ee7879
commit 4d1809a63c
2 changed files with 6 additions and 0 deletions
+3
View File
@@ -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
+3
View File
@@ -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])