From d9909c4db927091fe9b6e6d30c27ecb6bb23a162 Mon Sep 17 00:00:00 2001 From: Nelson Brown Date: Sun, 13 Jul 2014 12:36:05 -0700 Subject: [PATCH] Add tests for ndimage fallback for 3D white_tophat & black_tophat --- skimage/morphology/tests/test_grey.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/skimage/morphology/tests/test_grey.py b/skimage/morphology/tests/test_grey.py index 191613c4..f9a7305d 100644 --- a/skimage/morphology/tests/test_grey.py +++ b/skimage/morphology/tests/test_grey.py @@ -166,6 +166,25 @@ def test_3d_fallback_cube_selem(): new_image = function(image, cube) yield testing.assert_array_equal, new_image, image +def test_3d_fallback_white_tophat(): + image = np.zeros((7, 7, 7), dtype=bool) + image[2, 2:4, 2:4] = 1 + image[3, 2:5, 2:5] = 1 + image[4, 3:5, 3:5] = 1 + new_image = grey.white_tophat(image) + footprint = ndimage.generate_binary_structure(3,1) + image_expected = ndimage.white_tophat(image,footprint=footprint) + testing.assert_array_equal(new_image, image_expected) + +def test_3d_fallback_black_tophat(): + image = np.ones((7, 7, 7), dtype=bool) + image[2, 2:4, 2:4] = 0 + image[3, 2:5, 2:5] = 0 + image[4, 3:5, 3:5] = 0 + new_image = grey.black_tophat(image) + footprint = ndimage.generate_binary_structure(3,1) + image_expected = ndimage.black_tophat(image,footprint=footprint) + testing.assert_array_equal(new_image, image_expected) class TestDTypes():