mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-24 13:20:43 +08:00
Add tests for discontiguous out arrays in grey morpho
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user