From 1a3ec0299c23eb4f2768baaa1b3168b51a22758d Mon Sep 17 00:00:00 2001 From: Juan Nunez-Iglesias Date: Tue, 4 Nov 2014 15:20:21 +1100 Subject: [PATCH] Add tests for discontiguous out arrays in grey morpho --- skimage/morphology/tests/test_grey.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/skimage/morphology/tests/test_grey.py b/skimage/morphology/tests/test_grey.py index 83d10b45..00f4ad37 100644 --- a/skimage/morphology/tests/test_grey.py +++ b/skimage/morphology/tests/test_grey.py @@ -6,7 +6,6 @@ from scipy import ndimage import skimage from skimage import data_dir -from skimage.util import img_as_bool from skimage.morphology import grey, selem @@ -247,5 +246,27 @@ def test_inplace(): testing.assert_raises(NotImplementedError, f, image, selem, out=out) +def test_discontiguous_out_array(): + image = np.array([[5, 6, 2], + [7, 2, 2], + [3, 5, 1]], np.uint8) + out_array_big = np.zeros((5, 5), np.uint8) + out_array = out_array_big[::2, ::2] + expected_dilation = np.array([[7, 0, 6, 0, 6], + [0, 0, 0, 0, 0], + [7, 0, 7, 0, 2], + [0, 0, 0, 0, 0], + [7, 0, 5, 0, 5]], np.uint8) + expected_erosion = np.array([[5, 0, 2, 0, 2], + [0, 0, 0, 0, 0], + [2, 0, 2, 0, 1], + [0, 0, 0, 0, 0], + [3, 0, 1, 0, 1]], np.uint8) + grey.dilation(image, out=out_array) + testing.assert_array_equal(out_array_big, expected_dilation) + grey.erosion(image, out=out_array) + testing.assert_array_equal(out_array_big, expected_erosion) + + if __name__ == '__main__': testing.run_module_suite()