Toolbox ia870 | List of Figures | Fig. 1.13 | Fig. 1.15

Figure 1.14 - Pixel geometry for dilation and erosion of digital images

Description

The effects on pixel geometry of both dilation and erosion are depicted in Fig. 1.14, where the image is both dilated and eroded by the structuring element consisting of four pixels, the center pixel being situated at the origin.

Dilation has the expected expanding effect, filling in small intrusions into the image. Note that a one-pixel hole and the small intrusions in the middle of the character 'g' have disappeared. Erosion has a shrinking effect, eliminating small extrusions. Two side effects of erosion are to fully eliminate the horizontal line at the bottom of the image.

Demo Script

 1 import numpy as np
 2 import ia870 as MT
 3 
 4 A = adreadgray('MVBook/g.png') > 0
 5 
 6 frame= MT.iaunion(A,1)
 7 
 8 adshow(MT.ianeg(MT.iabshow(frame,A)), '(a) input image')
 9 
10 E = MT.iaimg2se(MT.iabinary([
11   [0, 0, 1],
12   [0, 1, 0],
13   [1, 1, 0]]))
14 
15 adshow(MT.ianeg(MT.iaseshow(E,'EXPAND')), '(b) structuring element')
16 
17 T = MT.iadil(A,E)
18 adshow(MT.ianeg(MT.iabshow(frame,A,T)), '(c) dilation')
19 
20 U = MT.iaero(A,E)
21 adshow(MT.ianeg(MT.iabshow(frame,A,U)), '(d) erosion')

(a) input image

(b) structuring element

(c) dilation

(d) erosion