Toolbox ia870 | List of Figures | Fig. 1.10 | Fig. 1.12

Figure 1.11 - Dilation as structuring element stamping

Description

Geometrically this formulation resembles stamping the structuring element on each activated pixel of the input image. Figure 1.11 illustrates this. The input image is a line and the stamp is a circle. This is also similar to a painting process where the structuring element is the brush shape and the pixels of the input image indicate the places to apply the brush.

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/linha.png') > 0
 7 A= MT.iapad(A,MT.iasebox(10))
 8 adshow(MT.ianeg(A), '(a) input image')
 9 
10 B = MT.iasedisk(10)
11 
12 C = MT.iadil(A,B)
13 
14 H,W = C.shape
15 rnd = np.random.rand(H,W) > 0.99
16 Ba = MT.iaintersec(A, rnd)
17 Bg = MT.iadil(Ba,MT.iaimg2se(MT.iagradm(MT.iapad(MT.iaseshow(B), MT.iasebox()))))
18 Bg = MT.iaunion(MT.iadil(Ba,MT.iasecross(2)),Bg)
19 
20 B = draw_se_axis(B)
21 adshow(MT.ianeg(B),'(b) structuring element')
22 
23 AC = MT.iasymdif(MT.iaunion(MT.iagray(A,'uint8',2),MT.iagray(C,'uint8',1)),MT.iagray(Bg,'uint8',1))
24 adshow(ia.ianormalize(MT.ianeg(AC)),'(c) dilation as union of translations [Eq. (1.12)]')

(a) input image

(b) structuring element

(c) dilation as union of translations [Eq. (1.12)]