4.8 Image Smoothing Using Frequency Domain...

25
GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 216 4.8 Image Smoothing Using Frequency Domain Filters Smoothing (blurring) is achieved in the frequency domain by lowpass filtering. Ideal Lowpass Filters A 2-D lowpass filter that passes all frequencies within a circle of radius 0 D from the origin and “cuts off” all frequencies outside this circle is called an ideal lowpass filter (ILPF). It is specified by the function 0 0 1 if (,) (,) 0 if (,) Duv D Huv Duv D ì £ ï ï = í ï > ï î (4.8-1) where 0 D is a positive constant, and (,) Duv is the distance between a point (,) uv in the frequency domain and the center of the frequency rectangle 2 2 (,) ( / 2) ( / 2) Duv u P v Q = - + - , (4.8-2) where P and Q are the padded sized from 2 1 P M ³ - (4.6-31) and 2 1 Q N ³ - . (4.6-32)

Transcript of 4.8 Image Smoothing Using Frequency Domain...

Page 1: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

216

4.8 Image Smoothing Using Frequency Domain Filters Smoothing (blurring) is achieved in the frequency domain by lowpass filtering. Ideal Lowpass Filters A 2-D lowpass filter that passes all frequencies within a circle of radius 0D from the origin and “cuts off” all frequencies outside this circle is called an ideal lowpass filter (ILPF). It is specified by the function

0

0

1 if ( , )( , )

0 if ( , )

D u v DH u v

D u v D

ì £ïï= íï >ïî (4.8-1)

where 0D is a positive constant, and ( , )D u v is the distance between a point ( , )u v in the frequency domain and the center of the frequency rectangle

2 2( , ) ( /2) ( /2)D u v u P v Q= - + - , (4.8-2)

where P and Q are the padded sized from

2 1P M³ - (4.6-31) and

2 1Q N³ - . (4.6-32)

Page 2: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

217

For an ILPF cross section, the point of transition between ( , ) 1H u v = and ( , ) 0H u v = is called the cutoff frequency. For

example, the cutoff frequency is 0D in Figure 4.40 (c). One way to establish a set of standard cutoff frequency loci is to compute circles that enclose specified amounts of total image power TP . It can be obtained by summing the components of the power spectrum of the padded images at each point ( , )u v ,

1 1

0 0

( , )P Q

Tu v

P P u v- -

= == åå , (4.8-3)

where ( , )P u v is given in

2 2 2( , ) ( , ) ( , ) ( , )P u v F u v R u v I u v= = + . (4.6-18)

If the DFT has been centered, a circle of radius 0D within the frequency rectangle encloses a a percent of the power, where

100 ( , )/ Tu v

P u v Paé ùê ú=ê úë ûåå . (4.8-4)

Figure 4.41 shows a test pattern image and its spectrum.

Page 3: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

218

Example 4.16: Image smoothing using an ILPF

Page 4: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

219

The blurring and ringing properties of ILPFs can be explained using the convolution theorem.

Since a cross section of the LIPF in the frequency domain looks like a box filter, the corresponding spatial filter has the shape of a sinc function. The center lobe of the sinc is the principal cause of blurring, while the outer, smaller lobes are mainly responsible for ringing.

Page 5: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

220

Butterworth Lowpass Filters The transfer function of a Butterworth lowpass filter (BLPF) of order n , and with cutoff frequency at a distance 0D from the origin, is defined as

[ ]20

1( , )

1 ( , )/ nH u vD u v D

=+ , (4.8-5)

where ( , )D u v is given by

2 2( , ) ( /2) ( /2)D u v u P v Q= - + - . (4.8-2) Figure 4.44 shows a perspective plot, image display, and radial cross sections of the BLPF function.

Unlike the ILPF, the BLPF transfer function does not have a sharp discontinuity.

Page 6: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

221

Example 4.17: Image smoothing with a Butterworth lowpass filter

Page 7: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

222

A BLPF of order 1 has no ringing in the spatial domain. Ringing can become significant in filters of higher order.

Page 8: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

223

Gaussian Lowpass Filters The form of Gaussian lowpass filters (GLPFs) in two dimensions is given by

2 2( , )/2( , ) D u vH u v e s-= , (4.8-6)

where ( , )D u v is the distance from the center of the frequency rectangle. As mentioned previously, s is a measure of spread about the center. Let 0Ds = , we can express the filter using the notation of other filters

2 20( , )/2( , ) D u v DH u v e-= , (4.8-7)

where 0D is the cutoff frequency. When 0( , )D u v D= , the GLPF is down to 0.607 of its maximum value.

As shown in Table 4.3, the inverse Fourier transform of the GLPF is Gaussian as well. So a spatial Gaussian filter, obtained by the IDFT of (4.8-6) and (4.8-7), will have no ringing.

Table 4.4 summarizes the lowpass filters we have discussed.

Page 9: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

224

Example 4.18: Image smoothing with a Gaussian lowpass filter

Page 10: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

225

Additional Examples of Lowpass Filtering Figure 4.49 (a) shows a sample of text of poor resolution.

To deal with the characters that have distorted shapes due to lack of resolution, one approach is to bridge small gaps in the input image by blurring them. Figure 4.49 (b) shows a result of using a Gaussian lowpass filter with 0 80D = . The images are of size 444 508´ .

Page 11: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

226

Figure 4.50 shows an application of lowpass filtering for producing a smoother, softer-looking result from a sharp original.

Figure 4.51 shows two applications of lowpass filtering on the same image with 0 50D = and 0 20D = .

Page 12: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

227

4.9 Image Sharpening Using Frequency Domain Filters A highpass filter is obtained from a given lowpass filter using the equation

( , ) 1 ( , )HP LPH u v H u v= - , (4.9-1)

where ( , )LPH u v is the transfer function of the lowpass filter. As in the previous section, we will also discuss ideal, Butterworth, and Gaussian highpass filters, which are shown in Figure 4.52.

Page 13: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

228

Figure 4.53 shows what these filters look like in the spatial domain.

Page 14: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

229

Ideal Highpass Filters A 2-D ideal highpass filter (IHPF) is defined as

0

0

0 if ( , )( , )

1 if ( , )

D u v DH u v

D u v D

ì £ïï= íï >ïî (4.9-2)

Because of the way they are related, we can expect IHPFs to have the same ringing properties as ILPFs. Figure 4.54 shows the various IHPF results of using the original image in Figure 4.41 (a) with 0D equal to 30, 60, and 160 pixels.

Page 15: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

230

Butterworth Highpass Filters A 2-D Butterworth highpass filter (BHPF) of order n and cutoff frequency 0D is defined as

[ ]20

1( , )

1 / ( , ) nH u vD D u v

=+ , (4.9-3)

where ( , )D u v is given by

2 2( , ) ( /2) ( /2)D u v u P v Q= - + - . (4.8-2) Figure 4.55 shows the performance of a BHPF.

Page 16: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

231

Gaussian Highpass Filters The transfer function of the Gaussian highpass filter (GHPF) with cutoff frequency locus at a distance 0D from the center of the frequency rectangle is defined as

2 20( , )/2( , ) 1 D u v DH u v e-= - . (4.9-4)

Figure 4.56 shows some comparable results from using GHPF s.

As expected, the results are more gradual than with the IHPFs and BHPFs. Table 4.5 contains a summary of the highpass filters we have discussed.

where the expression for Ideal should read as

( )

( )

0

0

0 if ,( , )

1 if ,

D u v DH u v

D u v D

£ìïï= íï >ïî

Page 17: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

232

Example 4.19: Using highpass filtering and thresholding for image enhancement

Page 18: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

233

The Laplacian in the Frequency Domain The Laplacian was used for image enhancement in the spatial domain. Now, we show that the Laplacian can yield equivalent results using frequency domain techniques. The Laplacian can be implemented in the frequency domain using the filter

2 2 2( , ) 4 ( )H u v u vp= - + , (4.9-5)

or, with respect to the center of the frequency rectangle, using the filter

[ ]2 2 2

2 2

( , ) 4 ( /2) ( /2)

4 ( , )

H u v u P v Q

D u v

p

p

= - - + -

= - (4.9-6) Then, the Laplacian image is obtained as

{ }2 1( , ) ( , ) ( , )f x y H u v F u v-Ñ = -F , (4.9-7)

where ( , )F u v is the DFT of ( , )f x y . As explained in Chapter 3, the enhancement is achieved using the question

2( , ) ( , ) ( , )g x y f x y c f x y= + Ñ , (4.9-8)

where 1c = - because ( , )H u v is negative. In the frequency domain, (4.9-8) is written as

{ }

[ ]{ }

[ ]{ }

1

1

1 2 2

( , ) ( , ) ( , ) ( , )

1 ( , ) ( , )

1 4 ( , ) ( , )

g x y F u v H u v F u v

H u v F u v

D u v F u vp

-

-

-

= -

= -

= +

F

F

F (4.9-9)

Page 19: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

234

Although (4.9-9) is an elegant result, there are the scaling issues that would make the computation more difficult. Therefore, equation (4.9-8) is the preferred implementation in the frequency domain. Example 4.20: Image sharpening in the frequency domain using the Laplacian

Figure 4.58 (a) is the same image as Figure 3.38 (a), and Figure 4.58 (b) shows the result of using

2( , ) ( , ) ( , )g x y f x y c f x y= + Ñ , (4.9-8)

in which the Laplacian was computed in the frequency domain using

{ }2 1( , ) ( , ) ( , )f x y H u v F u v-Ñ = -F . (4.9-7) By comparing Figure 4.58 (a) and Figure 3.38 (a), we see that the frequency domain and spatial results are identical visually.

Page 20: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

235

Unsharp Masking, Highboost Filtering, and High-Frequency-Emphasis Filtering Using frequency domain methods, the mask defined in

gmask( , ) ( , ) ( , )x y f x y f x y= - (3.6-8)

is given by

gmask( , ) ( , ) ( , )LPx y f x y f x y= - (4.9-10)

where

( ) ( )[ ]1( , ) , ,LP LPf x y H u v F u v-= F (4.9-11)

is a smoothed image analogous to ( , )f x y in (3.6-8), ( , )LPH u v is a lowpass filter, and ( , )F u v is the Fourier transform of ( , )f x y . Then, as in (3.6-9)

g gmask( , ) ( , ) ( , )x y f x y k x y= + * , (4.9-12)

which defines unsharp masking when 1k = and highboost filtering when 1k > . Equation (4.9-12) can be expressed in terms of frequency domain computations involving a lowpass filter

( )[ ][ ] ( ){ }g 1( , ) 1 1 , ,LPx y k H u v F u v-= + * -F (4.9-13)

We also can express this result in terms of a highpass filter

( )[ ] ( ){ }g 1( , ) 1 , ,HPx y k H u v F u v-= + *F (4.9-14) In (4.9-14), the term ( )[ ]1 ,HPk H u v+ * is called a high-frequency-emphasis filter. A slightly more general formulation of high-frequency-emphasis filtering is given in the expression:

Page 21: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

236

( )[ ] ( ){ }g 11 2( , ) , ,HPx y k k H u v F u v-= + *F (4.9-15)

where 1 0k ³ gives controls of the offset from the origin and 2 0k ³ controls the contribution of high frequencies. Example 4.21: Image enhancement using high-frequency-emphasis filtering.

Figure 4.59 (a) shows a 416 596´ chest X-ray with a narrow range of intensity levels. Figure 4.59 (b) shows the result of highpass filtering using a Gaussian filter with 0 40D = . Figure 4.59 (c) shows the advantage of high-emphasis filtering with 1 0.5k = and 2 0.75k = . Figure 4.59 (d) shows the result of applying the histogram equalization on Figure 4.59 (c).

Page 22: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

237

4.10 Selective Filtering All filters we have discussed in the previous two sections operate over the entire frequency rectangle. There are filters to process specific bands of frequencies or small regions of the rectangle, which are called bandreject or bandpass filters. Bandreject and Bandpass Filters Table 4.6 shows expressions for ideal, Butterworth, and Gaussian bandreject filters.

Figure 4.63 (a) shows a Gaussian bandreject filter in image form.

A bandpass filter is obtained from a bandreject filter

( , ) 1 ( , )BP BRH u v H u v= - . (4.10-1)

Figure 4.63 (b) shows a Gaussian bandpass filter in image form.

Page 23: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

238

Notch Filters A notch filter will reject (or pass) frequencies in a predefined neighbourhood. Since zero-phase-shift filters must be symmetric about the origin, a notch with center at 0 0( , )u v must have a corresponding notch at location 0 0( , )u v- - . Notch reject filters are constructed as products of highpass filters whose centers have been translated to the centers of the notches:

1

( , ) ( , ) ( , )Q

NR k kk

H u v H u v H u v-=

= Õ , (4.10-2)

where ( , )kH u v and ( , )kH u v- are highpass filters whose centers are at ( , )k ku v and ( , )k ku v- - . These “centers” are specified to the center of the frequency rectangle, ( /2, /2)M N . The distance computations for each filter are

( ) ( )2 2( , ) /2 /2k k kD u v u M u v N v= - - + - - (4.10-3)

and

( ) ( )2 2( , ) /2 /2k k kD u v u M u v N v- = - + + - + (4.10-3)

For example, the following is a Butterworth notch reject filter of order n, containing three notch pairs

[ ] [ ]

3

2 21 0 0

1 1( , )

1 / ( , ) 1 / ( , )NR n n

k k k k k

H u vD D u v D D u v= -

é ù é ùê ú ê ú= ê ú ê ú+ +ë û ë û

Õ (4.10-5) The constant 0kD is the same for each pair of notches, but can be different for different pairs.

Page 24: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

239

Other notch reject filters are constructed in the same manner, depending on the highpass filter chosen. A notch pass filter is obtained from a notch reject filter by

( , ) 1 ( , )NP NRH u v H u v= - . (4.10-6) Example 4.24: Enhancement of corrupted Cassini Saturn image by notch filtering

Figure 4.65 (a) shows an image of part of the rings surrounding the planet Saturn. Figure 4.65 (b) shows the DFT spectrum.

Figure 4.65 (c) shows a narrow notch rectangle filter (white represents 1 and black 0). Figure 4.65 (d) shows the result of filtering the corrupted image with this filter with a significant improvement over the original image.

Page 25: 4.8 Image Smoothing Using Frequency Domain Filtersion.uwinnipeg.ca/~sliao/Courses/7205/Week06A.pdf · G ACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19) 217 For an

GACS-7205-001 Digital Image Processing Page (Fall Term, 2018-19)

240

Figure 4.66 (a) shows the result of using a notch pass version of the same filter to the DFT of Figure 4.65 (a). Figure 4.66 (b) shows the spatial pattern obtained by computing the IDFT of Figure 4.66 (a).