mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-21 12:50:27 +08:00
BUG: Allow rgb2grey to be called on grey-level images.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user