Figure 1.12 - Dilation as reflected robot path planing from outside

Description

Another formulation of dilation involves translations of the rotated structuring element that “hit” (intersect) the input image:

This approach is illustrated in Fig. 1.12.

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