Introduction to Digital Image Processing with MATLAB Asia
Introduction to Digital Image Processing with MATLAB® Asia Edition Mc. Andrew‧Wang‧Tseng Chapter 7: The Fourier Transform 1 © 2010 Cengage Learning Engineering. All Rights Reserved. 1
7. 1 Introduction • The Fourier transform allows us to perform tasks that would be impossible to perform any other way • It is more efficient to use the Fourier transform than a spatial filter for a large filter • The Fourier transform also allows us to isolate and process particular image frequencies 2 Ch 7 -p. 145 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 2 Background 3 Ch 7 -p. 145 © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 2 • A periodic function may be written as the sum of sines and cosines of varying amplitudes and frequencies 4 Ch 7 -p. 146 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 2 Background ü These are the equations for the Fourier series expansion of f (x), and they can be expressed in complex form 5 Ch 7 -p. 147 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 2 Background ü If the function is nonperiodic, we can obtain similar results by letting T → ∞, in which case 6 Ch 7 -p. 147 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 2 Background ü Fourier transform pair ü Further details can be found, for example, in James [18]. 7 Ch 7 -p. 148 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 3 The One-Dimensional Discrete Fourier Transform 8 Ch 7 -p. 148 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 3 The One-Dimensional Discrete Fourier Transform • Definition of the One-Dimensional DFT 9 Ch 7 -p. 148 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 3 The One-Dimensional Discrete Fourier Transform ü This definition can be expressed as a matrix multiplication ü where F is an N × N matrix defined by ü Given N, we shall define 10 Ch 7 -p. 149 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 3 The One-Dimensional Discrete Fourier Transform ü e. g. suppose f = [1, 2, 3, 4] so that N = 4. Then 11 Ch 7 -p. 150 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 3 The One-Dimensional Discrete Fourier Transform 12 Ch 7 -p. 150 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 3 The One-Dimensional Discrete Fourier Transform • THE INVERSE DFT ü If you compare Equation (7. 3) with Equation 7. 2 you will see that there are really only two differences: 1. There is no scaling factor 1/N 2. The sign inside the exponential function has been changed to positive. 3. The index of the sum is u, instead of x 13 Ch 7 -p. 150 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 3 The One-Dimensional Discrete Fourier Transform 14 Ch 7 -p. 151 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 3 The One-Dimensional Discrete Fourier Transform 15 Ch 7 -p. 151 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 4 Properties of the One-Dimensional DFT • LINEARITY ü This is a direct consequence of the definition of the DFT as a matrix product ü Suppose f and g are two vectors of equal length, and p and q are scalars, with h = pf + qg ü If F, G, and H are the DFT’s of f, g, and h, respectively, we have 16 Ch 7 -p. 152 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 4 Properties of the One-Dimensional DFT • SHIFTING ü Suppose we multiply each element xn of a vector x by (− 1)n. In other words, we change the sign of every second element ü Let the resulting vector be denoted x’. The DFT X’ of x’ is equal to the DFT X of x with the swapping of the left and right halves 17 Ch 7 -p. 152 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 4 Properties of the One-Dimensional DFT e. g. 18 Ch 7 -p. 152 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 4 Properties of the One-Dimensional DFT Notice that the first four elements of X are the last four elements of X 1 and vice versa 19 Ch 7 -p. 153 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 4 Properties of the One-Dimensional DFT • SCALING F ü where k is a scalar and F= f ü If you make the function wider in the x-direction, it's spectrum will become smaller in the x-direction, and vice versa ü Amplitude will also be changed 20 Ch 7 -p. 153 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 4 Properties of the One-Dimensional DFT • CONJUGATE SYMMETRY • CONVOLUTION 21 Ch 7 -p. 153 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 4 Properties of the One-Dimensional DFT • THE FAST FOURIER TRANSFORM 2 n 22 Ch 7 -p. 157 © 2010 Cengage Learning Engineering. All Rights Reserved. Appendix B
7. 5 The Two-Dimensional DFT • The 2 -D Fourier transform rewrites the original matrix in terms of sums of corrugations 23 Ch 7 -p. 157 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 5. 1 Some Properties of the Two. Dimensional Fourier Transform • SIMILARITY • THE DFT AS A SPATIAL FILTER • SEPARABILITY 24 Ch 7 -p. 159 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 5. 1 Some Properties of the Two. Dimensional Fourier Transform • LINEARITY • THE CONVOLUTION THEOREM ü Suppose we wish to convolve an image M with a spatial filter S 1. Pad S with zeroes so that it is the same size as M; denote this padded result by S’ 2. Form the DFTs of both M and S’ to obtain (M)and (S’) 25 Ch 7 -p. 160 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 5. 1 Some Properties of the Two. Dimensional Fourier Transform 3. Form the element-by-element product of these two transforms: 4. Take the inverse transform of the result: Put simply, the convolution theorem states or equivalently that 26 Ch 7 -p. 161 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 5. 1 Some Properties of the Two. Dimensional Fourier Transform • THE DC COEFFICIENT • SHIFTING DC coefficient 27 Ch 7 -p. 162 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 5. 1 Some Properties of the Two. Dimensional Fourier Transform • CONJUGATE SYMMETRY • DISPLAYING YRANSFORMS 28 Ch 7 -p. 163 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 6 Fourier Transforms in MATLAB ü fft, which takes the DFT of a vector, ü ifft, which takes the inverse DFT of a vector, ü fft 2, which takes the DFT of a matrix, ü ifft 2, which takes the inverse DFT of a matrix, and ü fftshift, which shifts a transform 29 Ch 7 -p. 164 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 6 Fourier Transforms in MATLAB e. g. Note that the DC coefficient is indeed the sum of all the matrix values 30 Ch 7 -p. 164 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 6 Fourier Transforms in MATLAB e. g. 31 Ch 7 -p. 165 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 6 Fourier Transforms in MATLAB e. g. 32 Ch 7 -p. 165 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 7 Fourier Transforms of Images 33 Ch 7 -p. 167 © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 10 34 Ch 7 -p. 168 © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 11 35 Ch 7 -p. 169 © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 12 36 Ch 7 -p. 169 © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 13 • EXAMPLE 7. 7. 2 37 Ch 7 -p. 170 © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 14 • EXAMPLE 7. 7. 3 38 Ch 7 -p. 170 © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 15 • EXAMPLE 7. 7. 4 39 Ch 7 -p. 171 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 7 Fourier Transforms of Images 40 Ch 7 -p. 172 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 8 Filtering in the Frequency Domain • Ideal Filtering ü LOW-PASS FILTERING 41 Ch 7 -p. 172 © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 16 42 Ch 7 -p. 173 © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 17 D = 15 43 Ch 7 -p. 174 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 8 Filtering in the Frequency Domain >> cfl = cf. *b >> cfli = ifft 2(cfl); >> figure, fftshow(cfli, ’abs’) 44 Ch 7 -p. 174 © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 18 D=5 45 Ch 7 -p. 175 D = 30 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 8 Filtering in the Frequency Domain ü HIGH-PASS FILTERING 46 Ch 7 -p. 174 © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 19 47 Ch 7 -p. 176 © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 20 48 Ch 7 -p. 176 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 8. 2 Butterworth Filtering ü Ideal filtering simply cuts off the Fourier transform at some distance from the center ü It has the disadvantage of introducing unwanted artifacts (ringing) into the result ü One way of avoiding these artifacts is to use as a filter matrix, a circle with a cutoff that is less sharp 49 Ch 7 -p. 177 © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 21 50 Ch 7 -p. 177 © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 22 & 7. 23 51 Ch 7 -p. 178 © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 24 52 Ch 7 -p. 179 © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 25 53 Ch 7 -p. 179 © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 26 >> bl = lbutter(c, 15, 1); >> cfbl = cf. *bl; >> figure, fftshow(cfbl, ’log’); 54 Ch 7 -p. 180 >> cfbli = ifft 2(cfbl); >> figure, fftshow(cfbli, ’abs’) © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 27 55 Ch 7 -p. 181 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 8. 3 Gaussian Filtering A wider function, with a large standard deviation, will have a low maximum 56 Ch 7 -p. 181 © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 28 57 Ch 7 -p. 182 © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 29 58 Ch 7 -p. 183 © 2010 Cengage Learning Engineering. All Rights Reserved.
7. 9 Homomorphic Filtering where f(x, y) is intensity, i(x, y) is the illumination and r(x, y) is the reflectance 59 Ch 7 -p. 184 © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 31 60 Ch 7 -p. 185 © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 32 61 Ch 7 -p. 185 © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 33 62 Ch 7 -p. 186 © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 34 63 Ch 7 -p. 186 © 2010 Cengage Learning Engineering. All Rights Reserved.
FIGURE 7. 35 64 Ch 7 -p. 187 © 2010 Cengage Learning Engineering. All Rights Reserved.
- Slides: 64