Toolbox ia870 | List of Figures | Fig. 1.4 | Fig. 1.6

Figure 1.5 - Erosion as a robot path planning


Erosion can also be used in robot path planning. The structuring element is the robot shape. The input image is the region where the robot can move (the robot cannot rotate). The erosion consists of the loci of all robot coordinates where the robot can fit. These coordinates are related to the robot (structuring element) origin. This is illustrated in Fig. 1.5, where the structuring element is a half-rounded square [Fig. 1.5(b)]. Geometrically, the robot has been moved around inside the input image (shown in light gray in Fig. 1.5(a); the posi- tions of the origin have been marked in black so as to produce the eroded image, i.e., places where the robot can be translated to.

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
 6 A = adreadgray('MVBook/blob_1.png')>0
 7 r = adreadgray('MVBook/r_robot.png')>0
 9 r1 = r[::2,::2]
10 B  = MT.iaimg2se(r1)
11 C  = MT.iaero(A,B)
12 H,W = C.shape
13 rnd = np.random.rand(H,W) > 0.996
14 Ba  = MT.iaintersec(MT.iagradm(C), rnd)
15 x   = MT.iapad(MT.iaseshow(B),MT.iasebox(2))
16 Bg  = MT.iadil(Ba,MT.iaimg2se(MT.iagradm(x)))
17 Bg  = MT.iaunion(MT.iadil(Ba,MT.iasecross(2)),Bg)
18 AC  = MT.iasymdif(MT.iaunion(MT.iagray(A, 'uint16',1),
19                              MT.iagray(C, 'uint16',2)),
20                              MT.iagray(Bg,'uint16',1))
21 adshow(ia.ianormalize(MT.ianeg(AC)),'(a) input image in gray and erosion in black')
23 r1 = r[::2,::2]
24 r1 = draw_se_axis(r1)
25 adshow(MT.ianeg(r1), '(b) structuring element (the robot)')

(a) input image in gray and erosion in black

(b) structuring element (the robot)