Toolbox ia870 | List of Figures | Fig. 1.14 | Fig. 1.16

Figure 1.15 - Structuring element decomposition

Description

Consider eroding by the disk of radius 2, of radius 2,being the disk of radius 1. Since , we can perform the operation in the following manner:

The key is not that is a disk, but that , the latter representing a decomposition of .

Demo Script

 1 import numpy as np
 2 import ia870 as MT
 3 from handson.lib import draw_se_axis
 4 
 5 A = adreadgray('MVBook/leaf_bin.png') > 0
 6 adshow(MT.ianeg(A),'(a) input image A')
 7 
 8 B1 = MT.iasedisk(7)
 9 x = draw_se_axis(B1.copy())
10 adshow(MT.ianeg(x), '(b) structuring element B')
11 
12 C1 = MT.iaero(A,B1)
13 C2 = MT.iaero(C1,B1)
14 
15 B1_2 = MT.iasesum(B1,2)
16 
17 C1s = MT.iaunion(MT.iagradm(A),C1)
18 adshow(MT.ianeg(C1s), '(c) Erosion between A and B')
19 
20 adshow(MT.ianeg(A), '(d) input image A')
21 
22 x2 = draw_se_axis(B1_2.copy())
23 adshow(MT.ianeg(x2), '(e) structuring element B')
24 
25 C2s = MT.iaunion(MT.iagradm(A),MT.iagradm(C1),C2)
26 adshow(MT.ianeg(C2s), '(f) Erosion between A and 2B')

(a) input image A

(b) structuring element B

(c) Erosion between A and B

(d) input image A

(e) structuring element B

(f) Erosion between A and 2B