Toolbox ia870 | List of Figures | Fig. 2.11 | Fig. 2.13

Figure 2.12 - Alternating sequential open-close filters

Description

The strategy is to eliminate small salt-and-pepper components, thereby allowing the larger structuring elements to more likely fit when they are eventually applied in the process. Figure 2.12 shows the image corrupted by both union and subtractive noise; and the results of single-stage, three-stage, and seven-stage alternatingsequential filters.

Figure 2.12 Alternating sequential open-close filters: (a) image corrupted with salt-and-pepper noise, (b) single-stage ASF open-close, (c) threestage ASF open-close, (d) seven-stage ASF open-close.

Demo Script

 1 import numpy as np
 2 import ia870 as MT
 3 from handson.lib import iabggmodel
 4 
 5 f = MT.iabinary(np.ones((200,100)))
 6 f = MT.iapad(f,MT.iasebox(25))
 7 
 8 n_salt = iabggmodel(shape(f),MT.iasedisk(2),4,0.001)
 9 n_pepper = iabggmodel(shape(f),MT.iasedisk(2),4,0.001)
10 
11 fbin = MT.iaintersec(MT.iaunion(f,n_salt),MT.ianeg(n_pepper))
12 
13 f1 = MT.iaasf(fbin,'co',MT.iasedisk(2),1)
14 f3 = MT.iaasf(fbin,'co',MT.iasedisk(2),3)
15 f7 = MT.iaasf(fbin,'co',MT.iasedisk(2),7)
16 
17 adshow(MT.iapad(MT.ianeg(fbin)),'(a)')
18 adshow(MT.iapad(MT.ianeg(f1)), '(b)')
19 adshow(MT.iapad(MT.ianeg(f3)), '(c)')
20 adshow(MT.iapad(MT.ianeg(f7)), '(d)')

(a)

(b)

(c)

(d)