
Mathematical Morphology 301
MATLAB/Octave
>> str2 = strel(’arbitrary’,ones(3,3),[9 8 7;6 5 4;3 2 1])
str2 =
Nonflat STREL object containing 9 neighbors.
Neighborhood:
1 1 1
1 1 1
1 1 1
Height:
9 8 7
6 5 4
3 2 1
>> imdilate(A,str2)
ans =
39 39 49 59 58
39 39 59 69 68
49 59 59 69 68
59 69 69 79 78
56 66 66 76 75
In Python the same result is obtained with gray
_
dilation:
Python
In : struct2 = np.array([[9,8,7],[6,5,4],[3,2,1]])
In : print ndi.gray
_
dilation(A,footprint=mo.square(3),\
...: structure=struct,mode=’constant’)
[[39 39 49 59 59]
[39 39 59 69 69]
[49 59 59 69 69]
[59 69 69 79 79]
[59 69 69 79 79]]
Now we can experiment with an image. We would expect that dilation