Toolbox ia870 | List of Figures | Fig. 1.9 | Fig. 1.11

Figure 1.10 Dilation as the dual of erosion (dilation as expansion)

Description

To dilate by , is rotated around the origin to obtain , , is eroded by , and then the complement of the erosion is taken. As indicated by Fig. 1.10 where is a disk, if contains the origin, then dilation of by results in an expansion of .

Demo Script

 1 import numpy as np
 2 import ia870 as MT
 3 import ia636 as ia
 4 from handson.lib import draw_se_axis
 5 
 6 A = adreadgray('MVBook/blob_1.png') > 0
 7 A = MT.iapad(A, MT.iasebox(30))
 8 
 9 B = MT.iasedisk(30)
10 
11 C = MT.iadil(A,B)
12 
13 H,W = C.shape
14 rnd = np.random.rand(H,W) > 0.997
15 Ba = MT.iaintersec(MT.iagradm(C), rnd)
16 Bg = MT.iadil(Ba,MT.iaimg2se(MT.iagradm(MT.iapad(MT.iaseshow(B), MT.iasebox()))))
17 Bg = MT.iaunion(MT.iadil(Ba,MT.iasecross(2)),Bg)
18 
19 AC = MT.iasymdif(MT.iaunion(MT.iagray(A,'uint16',2),MT.iagray(C,'uint16',1)),MT.iagray(Bg,'uint16',1))
20 adshow(ia.ianormalize(MT.ianeg(AC)), '(a) input image in black, dilation in gray')
21 
22 B = draw_se_axis(B)
23 adshow(MT.ianeg(B), '(b) structuring element')

(a) input image in black, dilation in gray

(b) structuring element