Fourier Transform Examples 1 Colorado School of Mines Department of Electrical Engineering and Computer Science Example – Fourier transform properties • Read in an image • Look at Fourier transform • Verify some properties in Table 4.1 clear all close all % Clear workspace of any old variables % Close all open figures % Read in a normal (real) image I = imread('cameraman.tif'); F = fft2(I); % Shift F so that zero frequency component is in the middle Fshift = fftshift(F); imshow(log(abs(Fshift)), []), impixelinfo 2 Colorado School of Mines Department of Electrical Engineering and Computer Science Example – linearity of Fourier transform • Read in two images • Verify that Fourier transform is a linear operation af1 ( x, y) bf 2 ( x, y) aF1 (u, v) bF2 (u, v) clear all close all % Clear workspace of any old variables % Close all open figures f1 = double(imread('cameraman.tif')); F1 = fft2(f1); f2 = double(imread('rice.png')); F2 = fft2(f2); a = 2; b = 3; Fsum1 = a*F1 + b*F2; Fsum2 = fft2(a*f1 + b*f2); figure, imshow(log(abs(fftshift(Fsum1))), []), impixelinfo figure, imshow(log(abs(fftshift(Fsum2))), []), impixelinfo 3 Colorado School of Mines Department of Electrical Engineering and Computer Science Example - differentiation property • The differentiation property of the continuous 2D Fourier transform is: n m n f ( x , y ) j 2 u j 2 v F (u, v) x y m • Show this for the case of the first derivative in the x direction (i.e., m=1, n=0); i.e., show f ( x, y) j 2 u F (u, v) x 4 Colorado School of Mines Department of Electrical Engineering and Computer Science Differentiation property (continued) • The inverse Fourier transform of F(u,v) is f ( x, y) F 1 F (u, v) F (u, v) e j 2 uxvydu dv • Taking the derivative with respect to x 5 Colorado School of Mines Department of Electrical Engineering and Computer Science Differentiation property (continued) • The inverse Fourier transform of F(u,v) is f ( x, y) F 1 F (u, v) F (u, v) e j 2 uxvydu dv • Taking the derivative with respect to x f ( x, y ) j 2 ux vy F ( u , v ) e du dv x x F (u, v) j 2 ux vy e du dv x F (u, v) j 2 u e j 2 ux vy du dv j 2 u F (u , v) e j 2 ux vy du dv • So f ( x, y) j 2 u F (u, v) x F 1 j 2 u F (u , v) Colorado School of Mines Department of Electrical Engineering and Computer Science 6 Differentiation property (continued) • Think of the derivative as a filter that we can convolve the image with. • The Fourier pair of this is f ( x, y ) H (u , v) F (u , v) x • So in the frequency domain, we can perform the derivative by multiplying by the H(u,v). • From before, we saw that H(u,v) = j2u. 7 Colorado School of Mines Department of Electrical Engineering and Computer Science Differentiation property (continued) • Plot the spectrum (magnitude) of the filter |H(u,v)| clear all close all 400 M = 100; N = 100; 300 [u,v] = meshgrid(-M/2:M/2, -N/2:N/2); 200 Hx = j*2*pi*u; Habs = abs(Hx); figure, imshow(Habs, []), impixelinfo 100 0 150 150 100 figure, surf(Habs), colormap jet; 100 50 50 0 0 8 Colorado School of Mines Department of Electrical Engineering and Computer Science