Fix rgb2grey for alpha channel

This commit is contained in:
Johannes Schönberger
2016-01-31 21:50:56 +01:00
parent f4e0370bc2
commit 4e5c4d3c4d
2 changed files with 5 additions and 1 deletions
+1 -1
View File
@@ -711,7 +711,7 @@ def rgb2gray(rgb):
if rgb.ndim == 2:
return np.ascontiguousarray(rgb)
rgb = _prepare_colorarray(rgb)
rgb = _prepare_colorarray(rgb[..., :3])
gray = 0.2125 * rgb[..., 0]
gray[:] += 0.7154 * rgb[..., 1]
+4
View File
@@ -231,6 +231,10 @@ class TestColorconv(TestCase):
assert rgb2grey(x).flags["C_CONTIGUOUS"]
assert rgb2grey(x[:5, :5]).flags["C_CONTIGUOUS"]
def test_rgb2grey_alpha(self):
x = np.random.rand(10, 10, 4)
assert rgb2grey(x).ndim == 2
def test_rgb2grey_on_grey(self):
rgb2grey(np.random.rand(5, 5))