Add default structuring element to morphology

This commit is contained in:
Nelson Brown
2014-07-11 13:50:55 -07:00
parent 1c27a97d26
commit bb732c9225
5 changed files with 124 additions and 13 deletions
+25
View File
@@ -64,5 +64,30 @@ def test_out_argument():
testing.assert_(np.any(out != out_saved))
testing.assert_array_equal(out, func(img, strel))
def test_default_selem():
functions = [binary.binary_erosion, binary.binary_dilation,
binary.binary_opening, binary.binary_closing]
strel = selem.diamond(radius=1)
image = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 1, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 1, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 1, 0, 0],
[0, 0, 1, 1, 1, 0, 0, 1, 0, 0],
[0, 0, 1, 1, 1, 0, 0, 1, 0, 0],
[0, 0, 1, 1, 1, 0, 0, 1, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 1, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 1, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], np.uint8)
for function in functions:
im_expected = function(image, strel)
im_test = function(image)
yield testing.assert_array_equal, im_expected, im_test
if __name__ == '__main__':
testing.run_module_suite()