mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-03 07:10:47 +08:00
Make sure rgb2gray output is contiguous
This commit is contained in:
@@ -709,7 +709,7 @@ def rgb2gray(rgb):
|
||||
"""
|
||||
|
||||
if rgb.ndim == 2:
|
||||
return rgb
|
||||
return np.ascontiguousarray(rgb)
|
||||
|
||||
rgb = _prepare_colorarray(rgb)
|
||||
|
||||
@@ -719,6 +719,7 @@ def rgb2gray(rgb):
|
||||
|
||||
return gray
|
||||
|
||||
|
||||
rgb2grey = rgb2gray
|
||||
|
||||
|
||||
|
||||
@@ -226,6 +226,11 @@ class TestColorconv(TestCase):
|
||||
|
||||
assert_equal(g.shape, (1, 1))
|
||||
|
||||
def test_rgb2grey_contiguous(self):
|
||||
x = np.random.rand(10, 10, 3)
|
||||
assert rgb2grey(x).flags["C_CONTIGUOUS"]
|
||||
assert rgb2grey(x[:5, :5]).flags["C_CONTIGUOUS"]
|
||||
|
||||
def test_rgb2grey_on_grey(self):
|
||||
rgb2grey(np.random.rand(5, 5))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user