Toolbox ia870 | List of Figures | Fig. 2.10 | Fig. 2.12

Figure 2.11 - Open-close and close-open filters

Description

A potential pitfall of the open-close strategy occurs when large noise components need to be eliminated but a direct attempt to do so will destroy too much of the original image. This is illustrated in Figs. 2.11. Both filters fail to restore the uncorrupted image satisfactorily. If the radius of the structuring element is small compared to the noise grains, the salt-and-pepper noise is not removed; and if the radius is large, the filter will destroy too much of the original image.

Figure 2.11 - Open-close and close-open filters:

  • (Fig. a) - image corrupted with salt-and-pepper noise
  • (Fig. b) -
  • (Fig. c) -
  • (Fig. d) -
  • (Fig. e) -

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 n_salt = iabggmodel(shape(f),MT.iasedisk(2),4,0.001)
 8 n_pepper = iabggmodel(shape(f),MT.iasedisk(2),4,0.001)
 9 fbin = MT.iaintersec(mmunion(f,n_salt),MT.ianeg(n_pepper))
10 B = MT.iasedisk(7)
11 go  = MT.iaopen(fbin,B)
12 goc = MT.iaclose(go,B)
13 gc  = MT.iaclose(fbin,B)
14 gco = MT.iaopen(gc,B)
15 
16 adshow(MT.iapad(MT.ianeg(fbin)),'(a)')
17 adshow(MT.iapad(MT.ianeg(go)), '(b)')
18 adshow(MT.iapad(MT.ianeg(goc)), '(c)')
19 adshow(MT.iapad(MT.ianeg(gc)), '(d)')
20 adshow(MT.iapad(MT.ianeg(gco)),'(e)')

(a)

(b)

(c)

(d)

(e)