# Figure 1.5 - Erosion as a robot path planning

## Description

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
5
8
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
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')
22
23 r1 = r[::2,::2]
24 r1 = draw_se_axis(r1)
25 adshow(MT.ianeg(r1), '(b) structuring element (the robot)')
```