mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-13 17:45:20 +08:00
Fix rgb2grey for alpha channel
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user