Make sure rgb2gray output is contiguous

This commit is contained in:
Johannes Schönberger
2016-01-31 19:35:53 +01:00
parent 65a29071fe
commit f4e0370bc2
2 changed files with 7 additions and 1 deletions
+2 -1
View File
@@ -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
+5
View File
@@ -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))