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

Figure 1.7 - Erosion as intersection of translations

Description

Erosion can be formulated in other ways besides the fitting characterization of Eq. (1.4). Of particular importance is its representation by an intersection of image translations:

Here, the erosion is found by intersecting all translations of the input image by negatives of points in the structuring element. The method is illustrated in Fig. 1.7. While the fitting definition of erosion is paramount for image-processing insight, the formulation of Eq. (1.5) can be useful for both computation and theory.

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/club.png') > 0
 7 adshow(MT.ianeg(A), '(a) input image')
 8 
 9 B = MT.iasedil(MT.iaseline(20,45),MT.iaseline(20,45+180))
10 B = MT.iaseshow(B)
11 
12 adshow(MT.ianeg(draw_se_axis(B)), '(b) structuring element')
13 
14 C = MT.iaero(A,B)
15 
16 Bimg=MT.iaseshow(B)
17 Ba=MT.ianeg(Bimg)
18 Ba[:,::8]=1
19 Ba=MT.iaintersec(Ba,Bimg)
20 
21 Bg=MT.iadil(MT.iagradm(A),MT.iaimg2se(Ba))
22 
23 AC=MT.iasymdif(MT.iaunion(MT.iagray(A,'uint16',2),MT.iagray(C,'uint16',6)),MT.iagray(Bg,'uint16',5))
24 adshow(ia.ianormalize(MT.ianeg(AC)), '(c) erosion in black')

(a) input image

(b) structuring element

(c) erosion in black