Digital Image Processing Filtering in the Frequency Domain

  • Slides: 54
Download presentation
Digital Image Processing Filtering in the Frequency Domain (Application) Christophoros Nikou cnikou@cs. uoi. gr

Digital Image Processing Filtering in the Frequency Domain (Application) Christophoros Nikou cnikou@cs. uoi. gr University of Ioannina - Department of Computer Science

DFT & Images taken from Gonzalez & Woods, Digital Image Processing (2002) 2 The

DFT & Images taken from Gonzalez & Woods, Digital Image Processing (2002) 2 The DFT of a two dimensional image can be visualised by showing the spectrum of the image component frequencies DFT C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 3 DFT & Images

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 3 DFT & Images C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 4 DFT & Images

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 4 DFT & Images C. Nikou – Digital Image Processing (E 12)

DFT & Images (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002)

DFT & Images (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 5 DFT Scanning electron microscope image of an integrated circuit magnified ~2500 times Fourier spectrum of the image C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 6 DFT & Images

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 6 DFT & Images (cont…) C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 7 DFT & Images

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 7 DFT & Images (cont…) C. Nikou – Digital Image Processing (E 12)

Periodicity of the DFT 8 • The range of frequencies of the signal is

Periodicity of the DFT 8 • The range of frequencies of the signal is between • [-M/2, M/2]. • The DFT covers two back-to-back half periods of the signal as it covers [0, M-1]. C. Nikou – Digital Image Processing (E 12)

9 Periodicity of the DFT (cont. . . ) • For display and computation

9 Periodicity of the DFT (cont. . . ) • For display and computation purposes it is convenient to shift the DFT and have a complete period in [0, M-1]. • From DFT properties: Letting N 0=M/2: And F(0) is now located at M/2. C. Nikou – Digital Image Processing (E 12)

10 Periodicity of the DFT (cont. . . ) • In two dimensions: and

10 Periodicity of the DFT (cont. . . ) • In two dimensions: and F(0, 0) is now located at (M/2, N/2). C. Nikou – Digital Image Processing (E 12)

11 Periodicity of the DFT (cont. . . ) C. Nikou – Digital Image

11 Periodicity of the DFT (cont. . . ) C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 12 DFT & Images

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 12 DFT & Images (cont…) C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 13 DFT & Images

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 13 DFT & Images (cont…) C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 14 DFT & Images

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 14 DFT & Images (cont…) Although the images differ by a simple geometric transformation no intuitive information may be extracted from their phases regarding their relation. C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 15 DFT & Images

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 15 DFT & Images (cont…) C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 16 The DFT and

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 16 The DFT and Image Processing To filter an image in the frequency domain: 1. Compute F(u, v) the DFT of the image 2. Multiply F(u, v) by a filter function H(u, v) 3. Compute the inverse DFT of the result C. Nikou – Digital Image Processing (E 12)

The importance of zero padding Images taken from Gonzalez & Woods, Digital Image Processing

The importance of zero padding Images taken from Gonzalez & Woods, Digital Image Processing (2002) 17 C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 18 The importance of

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 18 The importance of zero padding (cont. . . ) C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 19 The importance of

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 19 The importance of zero padding (cont. . . ) C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 20 Some Basic Frequency

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 20 Some Basic Frequency Domain Filters Low Pass Filter High Pass Filter C. Nikou – Digital Image Processing (E 12)

Some Basic Frequency Domain Filters Images taken from Gonzalez & Woods, Digital Image Processing

Some Basic Frequency Domain Filters Images taken from Gonzalez & Woods, Digital Image Processing (2002) 21 C. Nikou – Digital Image Processing (E 12)

Some Basic Frequency Domain Filters Images taken from Gonzalez & Woods, Digital Image Processing

Some Basic Frequency Domain Filters Images taken from Gonzalez & Woods, Digital Image Processing (2002) 22 C. Nikou – Digital Image Processing (E 12)

23 Smoothing Frequency Domain Filters • Smoothing is achieved in the frequency domain by

23 Smoothing Frequency Domain Filters • Smoothing is achieved in the frequency domain by dropping out the high frequency components • The basic model for filtering is: G(u, v) = H(u, v)F(u, v) • where F(u, v) is the Fourier transform of the image being filtered and H(u, v) is the filter transform function • Low pass filters – only pass the low frequencies, drop the high ones. C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 24 Ideal Low Pass

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 24 Ideal Low Pass Filter Simply cut off all high frequency components that are a specified distance D 0 from the origin of the transform. Changing the distance changes the behaviour of the filter. C. Nikou – Digital Image Processing (E 12)

25 Ideal Low Pass Filter (cont…) The transfer function for the ideal low pass

25 Ideal Low Pass Filter (cont…) The transfer function for the ideal low pass filter can be given as: where D(u, v) is given as: C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 26 Ideal Low Pass

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 26 Ideal Low Pass Filter (cont…) An image, its Fourier spectrum and a series of ideal low pass filters of radius 5, 15, 30, 80 and 230 superimposed on top of it. C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 27 Ideal Lowpass Filters

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 27 Ideal Lowpass Filters (cont. . . ) • ILPF in the spatial domain is a sinc function that has to be truncated and produces ringing effects. • The main lobe is responsible for blurring and the side lobes are responsible for ringing. C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 28 Ideal Low Pass

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 28 Ideal Low Pass Filter (cont…) ILPF of radius 5 Original image ILPF of radius 15 ILPF of radius 30 ILPF of radius 80 ILPF of radius 230 C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 29 Butterworth Lowpass Filters

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 29 Butterworth Lowpass Filters • The transfer function of a Butterworth lowpass filter of order n with cutoff frequency at distance D 0 from the origin is defined as: C. Nikou – Digital Image Processing (E 12)

Butterworth Lowpass Filters (cont. . . ) Images taken from Gonzalez & Woods, Digital

Butterworth Lowpass Filters (cont. . . ) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 30 C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 31 Butterworth Lowpass Filter

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 31 Butterworth Lowpass Filter (cont…) BLPF n=2, D 0=5 Original image BLPF n=2, D 0=15 BLPF n=2, D 0=30 BLPF n=2, D 0=80 BLPF n=2, D 0=230 Less ringing than ILPF due to smoother transition C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 32 Gaussian Lowpass Filters

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 32 Gaussian Lowpass Filters • The transfer function of a Gaussian lowpass filter is defined as: C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 33 Gaussian Lowpass Filters

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 33 Gaussian Lowpass Filters (cont…) Original image Gaussian D 0=5 Gaussian D 0=15 Gaussian D 0=30 Gaussian D 0=85 Gaussian D 0=230 Less ringing than BLPF but also less smoothing C. Nikou – Digital Image Processing (E 12)

Lowpass Filters Compared Images taken from Gonzalez & Woods, Digital Image Processing (2002) 34

Lowpass Filters Compared Images taken from Gonzalez & Woods, Digital Image Processing (2002) 34 BLPF n=2, D 0=15 ILPF D 0=15 Gaussian D 0=15 C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 35 Lowpass Filtering Examples

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 35 Lowpass Filtering Examples A low pass Gaussian filter is used to connect broken text C. Nikou – Digital Image Processing (E 12)

Lowpass Filtering Examples Images taken from Gonzalez & Woods, Digital Image Processing (2002) 36

Lowpass Filtering Examples Images taken from Gonzalez & Woods, Digital Image Processing (2002) 36 C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 37 Lowpass Filtering Examples

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 37 Lowpass Filtering Examples (cont…) • Different lowpass Gaussian filters used to remove blemishes in a photograph. C. Nikou – Digital Image Processing (E 12)

Lowpass Filtering Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Lowpass Filtering Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 38 C. Nikou – Digital Image Processing (E 12)

39 Sharpening in the Frequency Domain • Edges and fine detail in images are

39 Sharpening in the Frequency Domain • Edges and fine detail in images are associated with high frequency components • High pass filters – only pass the high frequencies, drop the low ones • High pass frequencies are precisely the reverse of low pass filters, so: Hhp(u, v) = 1 – Hlp(u, v) C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 40 Ideal High Pass

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 40 Ideal High Pass Filters • The ideal high pass filter is given by: • D 0 is the cut off distance as before. C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 41 Ideal High Pass

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 41 Ideal High Pass Filters (cont…) IHPF D 0 = 15 IHPF D 0 = 30 IHPF D 0 = 80 C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 42 Butterworth High Pass

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 42 Butterworth High Pass Filters • The Butterworth high pass filter is given as: • n is the order and D 0 is the cut off distance as before. C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 43 Butterworth High Pass

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 43 Butterworth High Pass Filters (cont…) BHPF n=2, D 0 =15 BHPF n=2, D 0 =30 BHPF n=2, D 0 =80 C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 44 Gaussian High Pass

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 44 Gaussian High Pass Filters • The Gaussian high pass filter is given as: • D 0 is the cut off distance as before. C. Nikou – Digital Image Processing (E 12)

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 45 Gaussian High Pass

Images taken from Gonzalez & Woods, Digital Image Processing (2002) 45 Gaussian High Pass Filters (cont…) Gaussian HPF n=2, D 0 =15 Gaussian HPF n=2, D 0 =30 Gaussian HPF n=2, D 0 =80 C. Nikou – Digital Image Processing (E 12)

Highpass Filter Comparison Images taken from Gonzalez & Woods, Digital Image Processing (2002) 46

Highpass Filter Comparison Images taken from Gonzalez & Woods, Digital Image Processing (2002) 46 IHPF D 0 = 15 BHPF n=2, D 0 =15 C. Nikou – Digital Image Processing (E 12) Gaussian HPF n=2, D 0 =15

Original image Highpass filtering result After histogram equalisation High frequency emphasis result Images taken

Original image Highpass filtering result After histogram equalisation High frequency emphasis result Images taken from Gonzalez & Woods, Digital Image Processing (2002) 47 Highpass Filtering Example C. Nikou – Digital Image Processing (E 12)

Laplacian in the frequency domain (not centered) 2 -D image of Laplacian in the

Laplacian in the frequency domain (not centered) 2 -D image of Laplacian in the frequency domain (not centered) Inverse DFT of Laplacian in the frequency domain Images taken from Gonzalez & Woods, Digital Image Processing (2002) 48 Laplacian In The Frequency Domain C. Nikou – Digital Image Processing (E 12) Zoomed section of the image on the left compared to spatial filter

49 Frequency Domain Laplacian Example Original image Laplacian filtered image Laplacian image scaled Enhanced

49 Frequency Domain Laplacian Example Original image Laplacian filtered image Laplacian image scaled Enhanced image C. Nikou – Digital Image Processing (E 12)

50 Band-pass and Band-stop Filters C. Nikou – Digital Image Processing (E 12)

50 Band-pass and Band-stop Filters C. Nikou – Digital Image Processing (E 12)

51 Band-Pass Filters (cont. . . ) C. Nikou – Digital Image Processing (E

51 Band-Pass Filters (cont. . . ) C. Nikou – Digital Image Processing (E 12)

52 Band-Pass Filters (cont. . . ) C. Nikou – Digital Image Processing (E

52 Band-Pass Filters (cont. . . ) C. Nikou – Digital Image Processing (E 12)

53 Fast Fourier Transform • The reason that Fourier based techniques have become so

53 Fast Fourier Transform • The reason that Fourier based techniques have become so popular is the development of the Fast Fourier Transform (FFT) algorithm. • It allows the Fourier transform to be carried out in a reasonable amount of time. • Reduces the complexity from O(N 4) to O(N 2 log. N 2). C. Nikou – Digital Image Processing (E 12)

54 Frequency Domain Filtering & Spatial Domain Filtering • Similar jobs can be done

54 Frequency Domain Filtering & Spatial Domain Filtering • Similar jobs can be done in the spatial and frequency domains. • Filtering in the spatial domain can be easier to understand. • Filtering in the frequency domain can be much faster – especially for large images. C. Nikou – Digital Image Processing (E 12)