Filtering in the Frequency Domain PDF
Document Details
Uploaded by WarmerAgate3259
NIT Hamirpur
Dr. Ram Prakash Sharma
Tags
Summary
This document discusses filtering in the frequency domain, a fundamental concept in digital image processing. It covers the basics of filtering, including computing the DFT (Discrete Fourier Transform) of an image, multiplying by a filter function, and computing the inverse DFT. The document also introduces some basic frequency domain filters, such as low-pass and high-pass filters. It highlights the filtering operation in the Fourier domain and emphasizes the importance of zero padding.
Full Transcript
21-02-2024 Filtering in the Frequency Domain Basics of filtering in the frequency domain (Fundamentals) To filter a...
21-02-2024 Filtering in the Frequency Domain Basics of filtering in the frequency domain (Fundamentals) To filter an image in the frequency domain: – Compute F(u,v) the DFT of the image – Multiply F(u,v) by a filter function H(u,v) – Compute the inverse DFT of the result Dr. Ram Prakash Sharma NIT Hamirpur Reference: R. Gonzalez and R. Woods. Digital Image Processing, Prentice Hall, 2008. February 24 RPS 1 February 24 RPS 2 1 2 Some Basic Frequency Domain Filters Filtering in Fourier Low Pass Filter (smoothing) H(u,v) is the filter transfer function, which is the DFT of the filter impulse response The implementation consists in multiplying point-wise the filter H(u,v) with the function F(u,v) High Pass Filter (edge detection) February 24 RPS 3 February 24 RPS 4 3 4 21-02-2024 Filtered image Frequency Domain Filters The filtered image is obtained by taking the inverse DFT of the The basic model for filtering is: resulting image 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 It can happen that the filtered image has spurious imaginary Filtered image components even though the original image f(x,y) and the filter f x, y 1 F u,v h(x,y) are real. These are due to numerical errors and are neglected Smoothing is achieved in the frequency domain by dropping out the The final result is thus the real part of the filtered image high frequency components – Low pass (LP) filters – only pass the low frequencies, drop the high ones – High-pass (HP) filters – olny pass the frequencies above a minimum value February 24 RPS February 24 RPS 6 5 5 6 Filtering in spatial and frequency domains The filtering operations in spatial and frequency domains are linked by the convolution theorem Modulation theorem (reminder) February 24 RPS February 24 RPS 8 7 7 8 21-02-2024 DFT & Images The DFT of a two dimensional image can be visualised by showing the spectrum of the image component frequencies DFT February 24 RPS 9 February 24 RPS 10 9 10 DFT & Images (cont…) Periodicity of the DFT The range of frequencies of the signal is between [-M/2, M/2]. The DFT covers two back- to-back half periods of the DFT signal as it covers [0, M-1]. Scanning electron microscope Fourier spectrum of the image image of an integrated circuit magnified ~2500 times February 24 RPS 11 February 24 RPS 12 11 12 21-02-2024 Periodicity of the DFT (cont...) DFT & Images (cont…) In two dimensions: f [ m, n](1)m n F (k M / 2, l N / 2) and F(0,0) is now located at (M/2, N/2). February 24 RPS 13 February 24 RPS 14 13 14 DFT & Images (cont…) 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 February 24 RPS 15 February 24 RPS 16 15 16 21-02-2024 The importance of zero padding Fourier Spectrum February 24 RPS 17 February 24 RPS 18 17 18 Some Basic Frequency Domain Filters Smoothing Frequency Domain Filters Low Pass Filter 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. High Pass Filter February 24 RPS 19 February 24 RPS 20 19 20 21-02-2024 Ideal Low Pass Filter Ideal Low Pass Filter (cont…) Simply cut off all high frequency components that are a specified distance D0 from the origin of the transform. The transfer function for the ideal low pass filter can be given as: 1 if D(u, v) D0 H (u, v) 0 if D(u, v) D0 where D(u,v) is given as: Changing the distance changes the behaviour of the filter. D(u, v) [(u M / 2) 2 (v N / 2) 2 ]1/ 2 February 24 RPS 21 February 24 RPS 22 21 22 Ideal Low Pass Filter (cont…) 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. 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. February 24 RPS 23 February 24 RPS 24 23 24 21-02-2024 Ideal Low Pass Filter (cont…) Butterworth Lowpass Filters The transfer function of a Butterworth lowpass filter Original ILPF of radius 5 of order n with cutoff frequency at distance D0 from image the origin is defined as: ILPF of radius 15 1 ILPF of radius 30 H (u , v) 1 [ D(u, v) / D0 ]2 n ILPF of radius 80 ILPF of radius 230 February 24 RPS 25 February 24 RPS 26 25 26 Butterworth Lowpass Filters (cont...) Butterworth Lowpass Filter (cont…) Original image BLPF n=2, D0=5 BLPF n=2, D0=15 BLPF n=2, D0=30 BLPF n=2, D0=80 BLPF n=2, D0=230 Less ringing than ILPF due to smoother transition February 24 RPS 27 February 24 RPS 28 27 28 21-02-2024 Gaussian Lowpass Filters Gaussian Lowpass Filters (cont…) Original image Gaussian D0=5 The transfer function of a Gaussian lowpass filter is defined as: 2 ( u ,v ) / 2 D0 2 H (u , v) e D Gaussian D0=30 Gaussian D0=15 Gaussian D0=85 Gaussian D0=230 Less ringing than BLPF but also less smoothing February 24 RPS 29 February 24 RPS 30 29 30 Lowpass Filters Compared Lowpass Filtering Examples ILPF D0=15 BLPF n=2, D0=15 A low pass Gaussian filter is used to connect broken text Gaussian D0=15 February 24 RPS 31 February 24 RPS 32 31 32 21-02-2024 Lowpass Filtering Examples Lowpass Filtering Examples (cont…) Different lowpass Gaussian filters used to remove blemishes in a photograph. February 24 RPS 33 February 24 RPS 34 33 34 Lowpass Filtering Examples (cont…) 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) February 24 RPS 35 February 24 RPS 36 35 36 21-02-2024 Ideal High Pass Filters Ideal High Pass Filters (cont…) The ideal high pass filter is given by: 0 if D(u, v) D0 H (u, v ) 1 if D(u , v) D0 D0 is the cut off distance as before. IHPF D0 = 15 IHPF D0 = 30 IHPF D0 = 80 February 24 RPS 37 February 24 RPS 38 37 38 Butterworth High Pass Filters Butterworth High Pass Filters (cont…) The Butterworth high pass filter is given as: 1 H (u, v ) 1 [ D0 / D (u, v )]2 n n is the order and D0 is the cut off distance as before. BHPF n=2, D0 =15 BHPF n=2, D0 =30 BHPF n=2, D0 =80 February 24 RPS 39 February 24 RPS 40 39 40 21-02-2024 Gaussian High Pass Filters Gaussian High Pass Filters (cont…) The Gaussian high pass filter is given as: 2 ( u ,v ) / 2 D0 2 H (u , v) 1 e D D0 is the cut off distance as before. Gaussian HPF Gaussian HPF Gaussian HPF n=2, D0 =15 n=2, D0 =30 n=2, D0 =80 February 24 RPS 41 February 24 RPS 42 41 42 High-Frequency Emphasis Filtering Highpass Filter Comparison Sometimes it is advantageous to accentuate the contribution to enhancement made by the high-frequency component of an image. We multiply a high pass filter function by a constant and add an offset so that the zero frequency term is not eliminated by the filter. Hhfe(u,v) = a+bHhp(u,v), where a>=0 and b>a. [ Typical a = [0.25,0.5] and b = [1.5,2.0] ] IHPF D0 = 15 BHPF n=2, D0 =15 Gaussian HPF n=2, D0 =15 February 24 RPS 43 43 44 21-02-2024 Highpass Filtering Example Highpass filtering result Original image emphasis result High frequency After histogram equalisation February 24 RPS 45 February 24 RPS 46 45 46 Laplacian in the Frequency Domain Laplacian in the Frequency Domain It can be shown that: The laplacian-filtered image in the spatial domain is obtain by computing 2 f (x, y) (u 2 v 2 )F(u,v) the inverse Fourier Transform of H(u,v)F(u,v) The Laplacian can be implemented in the frequency domain by using the filter 2 f (x, y) 1{[(u M / 2)2 (v N / 2)2 ]F (u, v)}. (Shift to center) H (u, v) (u 2 v 2 ) [(u M / 2)2 (v N / 2)2 )]. 47 48 21-02-2024 Frequency Domain Laplacian Example Fast Fourier Transform The reason that Fourier based techniques have become so popular is the development of the Fast Original Laplacian Fourier Transform (FFT) algorithm. image filtered image It allows the Fourier transform to be carried out in a reasonable amount of time. Reduces the complexity from O(N4) to O(N2logN2). Laplacian Enhanced image image scaled February 24 RPS 49 February 24 RPS 50 49 50 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. February 24 RPS 51 February 24 RPS 52 51 52 21-02-2024 February 24 RPS 53 February 24 RPS 54 53 54 February 24 RPS 55 February 24 RPS 56 55 56 21-02-2024 February 24 RPS 57 February 24 RPS 58 57 58 February 24 RPS 59 February 24 RPS 60 59 60 21-02-2024 February 24 RPS 61 February 24 RPS 62 61 62 February 24 RPS 63 February 24 RPS 64 63 64 21-02-2024 February 24 RPS 65 February 24 RPS 66 65 66 February 24 RPS 67 February 24 RPS 68 67 68