Toolbox ia870 | List of Figures | Fig. 2.3 | Fig. 2.5

Figure 2.4 - Duality between open and close

Description

Figure 2.4 illustrates the duality between open and close with a nonsymmetrical structuring element

Demo Script

 1 import numpy as np
 2 import ia870 as MT
 3 from handson.lib import draw_se_axis
 4 
 5 B_img = adreadgray('blob1.tif')
 6 B = MT.iaimg2se(B_img)
 7 
 8 y,x=indices((140,100))
 9 F = MT.iabinary((2*x) < (y))
10 F = MT.iaunion(F,np.fliplr(F))
11 F = MT.iapad(F,B)
12 adshow(MT.iapad(MT.ianeg(F)), '(A)')
13 
14 adshow(MT.ianeg(draw_se_axis(MT.iaseshow(B))), '(B)')
15 
16 C = MT.iaero(F,B)
17 adshow(MT.iapad(MT.ianeg(C)), 'Erosion between A and B')
18 
19 D = MT.iaopen(F,B)
20 adshow(MT.iapad(MT.ianeg(D)), 'Open between A and B')
21 
22 Fc = MT.ianeg(F)
23 adshow(MT.iapad(MT.ianeg(Fc)), '(A)')
24 
25 Bc = MT.iasereflect(B)
26 adshow(MT.ianeg(draw_se_axis(MT.iaseshow(Bc))), '(B) reflected')
27 
28 Cc = MT.iadil(Fc,Bc)
29 adshow(MT.ianeg(Cc), 'Dilation between A and B')
30 
31 Dc = MT.iaclose(Fc,Bc)
32 adshow(MT.ianeg(Dc), 'Close between A and B')

(A)

(B)

Erosion between A and B

Open between A and B

(A)

(B) reflected

Dilation between A and B

Close between A and B