From 644ab324ddf3e2bcc5ed07c400fdd4d3161b214c Mon Sep 17 00:00:00 2001 From: Almar Date: Thu, 28 Mar 2013 10:03:02 +0100 Subject: [PATCH] Added test for ball and octahedton selems. Note that only the center slice (in each dimension is tested) since there is no reference data available for these selems. I did visualize the 3D shapes to see whether they look right. --- skimage/morphology/tests/test_selem.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/skimage/morphology/tests/test_selem.py b/skimage/morphology/tests/test_selem.py index eec6cd5b..ccaf43a0 100644 --- a/skimage/morphology/tests/test_selem.py +++ b/skimage/morphology/tests/test_selem.py @@ -36,9 +36,32 @@ class TestSElem(): expected_mask = expected_mask[:, np.newaxis] assert_equal(expected_mask, actual_mask) k = k + 1 - + + def strel_worker_3d(self, fn, func): + matlab_masks = np.load(os.path.join(data_dir, fn)) + k = 0 + for arrname in sorted(matlab_masks): + expected_mask = matlab_masks[arrname] + actual_mask = func(k) + if (expected_mask.shape == (1,)): + expected_mask = expected_mask[:, np.newaxis] + # Test center slice for each dimension. This gives a good + # indication of validity without the need for a 3D reference + # mask. + c = int(expected_mask.shape[0]/2) + assert_equal(expected_mask, actual_mask[c,:,:]) + assert_equal(expected_mask, actual_mask[:,c,:]) + assert_equal(expected_mask, actual_mask[:,:,c]) + k = k + 1 + def test_selem_disk(self): self.strel_worker("disk-matlab-output.npz", selem.disk) def test_selem_diamond(self): self.strel_worker("diamond-matlab-output.npz", selem.diamond) + + def test_selem_ball(self): + self.strel_worker_3d("disk-matlab-output.npz", selem.ball) + + def test_selem_octahedron(self): + self.strel_worker_3d("diamond-matlab-output.npz", selem.octahedron)