
Mathematical Morphology 281
Then the internal boundary is obtained with:
MATLAB/Octave
>> pe = imerode(p,sq);
>> p
_
int = p & ~re;
>> imshow(p),figure,imshow(p
_
int)
The result is shown in Figure 10.10. The above commands can b e implemented i n Python
FIGURE 10.10: “Internal boundary” of a binary image
as
Python
In : n = io.imread(’pinenuts.png’)
In : p = ~((n>130) & (n<165))
In : pe = bwerode(p,sq)
In : p
_
int = p-pe
In : io.imshow(p)
In : f = plt.figure(); f.show(io.imshow(p-pe))
The external boundary and morphological gradients can be obtained similarly:
MATLAB/Octave
>> pd = imdilate(p,sq);
>> p
_
ext = pd & ~p;
>> p
_
grad = pd & ~pe;
>> imshow(p
_
ext), figure,imshow(p ...