You are on page 1of 1
164 Gopter 5 Image Restoration 165 >> fp = spfilt(gp, ‘chmean', 3, 3, 1.5); Similarly, salt noise can be filtered using a contraharmonie filter with ane tive value of Q: >> fs = spfilt(gs, ‘chmean’, 3, 3, ~1.5); Figs.5.5(a) and (b), respectively, with the following commands: EP GURE 5.6 (2) Image corrupted by saltand-pepper noise with density 0.25. (b) Result obtained using a >> fpnax = spfilt(gp, ‘nex’, 3, 8); Ipedian filter of size 7 = 7. (c) Result obtained using adaptive median filtering With Sym, = 7. >> femin = spfilt(gs, ‘min’, 3, 3); i : Other solutions using spfi2t are implemented in a similar manner, 5.3.2 Adaptive Spatial Filters ‘The filters discussed in the previous section are applied to an image withog regard for how image characteristics vary from one location to another: i some applications, results can be improved by using filters capable of adapt their behavior depending on the characteristics of the image in the area beig filtered. As an illustration of how to implement adaptive spatial filter MATLAB, we consider in this section an adaptive media filter. As before, denotes a subimage centered at location (x, y) in the image being proces The algorithm, which is explained in detail in Gonzalez and Woods (2002) is follows: Let ‘An M-function that implements this algorithm, which we call adpnegian, is luded in Appendix C. The syntax is + = adpmedian(g, Snax) EXAMPLE 546: Adaptive median fering. nin = minimum intensity value in S,, Zea = Maximum intensity value in Sy ‘Enea “ median of the intensity values in Sy Zy = intensity value at coordinates (x, y) salt & pepper’, .25); std Fig. 5.6(b) shows the result obtained using the command (see Section 35.2 ‘The adaptive median filtering algorithm works in two Teves denoted level eg enTaE te use of near2e2): and level B: fle meatiita(g, (7 7], ‘symmetric’ ); Level A: I zpiy < Enos < touts £0 0 level B : Else increase the window size Tis image is reasonably free of noise, but it is quite blurred and distorted If window size = Spay repeat level A {ee, see the connector fingers in the top middle ofthe image). On the other Else output 2nes fend, the command Level BIE min < Zxy < mans OULPUL Zyy : Else output Snug 2 » acpaedian(g, 7); Where Sa denotes the maximum allowed size of the adaptive Miter wind ‘Another tion inthe lst step in Level Ais to output sc, inecad ofthe meSMMMEKLd the image in Fig, 56(c), which is also reasonably fre of noise, but is ‘This produces a slightly less blurred result but can fail to detect salt (pePp siderably less blurred and distorted than Fig. 5.6(b. .

You might also like