Toolbox ia870 | List of Figures | Fig. 1.17 | Fig. 1.19

Figure 1.18 - Bounded dilation

Description

For image and structuring element the bounded dilation is defined as

Like bounded erosion, the translated structuring element is restricted to the view of the input image. In this case, there is a difference in the treatment of the image and the structuring element making bounded dilation not commutative.

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 adshow(MT.iapad(MT.ianeg(A)), '(a) input image')
 8 
 9 r = adreadgray('MVBook/r_robot.png')>0
10 
11 B = MT.iaimg2se(r)
12 
13 Br = MT.iasereflect(B)
14 adshow(MT.ianeg(draw_se_axis(Br)), '(b) structuring element')
15 
16 C = MT.iadil(A,B)
17 
18 H,W = C.shape
19 rnd = np.random.rand(H,W) > 0.99
20 Ba  = MT.iaintersec(MT.iagradm(C), rnd)
21 Bg = MT.iadil(Ba,MT.iaimg2se(MT.iagradm(MT.iapad(MT.iaseshow(Br),MT.iasebox()))))
22 Bg = MT.iaunion(MT.iadil(Ba,MT.iasecross(2)),Bg)
23 
24 
25 AC  = MT.iasymdif(MT.iaunion(MT.iagray(A, 'uint16',2),
26                              MT.iagray(C, 'uint16',1)),
27                              MT.iagray(Bg,'uint16',1))
28 
29 adshow(MT.iapad(ia.ianormalize(MT.ianeg(AC))),'(c) bounded dilation.')

(a) input image

(b) structuring element

(c) bounded dilation.