Presentation is loading. Please wait.

Presentation is loading. Please wait.

ENGI 4559 Signal Processing for Software Engineers Dr. Richard Khoury Fall 2009.

Similar presentations


Presentation on theme: "ENGI 4559 Signal Processing for Software Engineers Dr. Richard Khoury Fall 2009."— Presentation transcript:

1 ENGI 4559 Signal Processing for Software Engineers Dr. Richard Khoury Fall 2009

2 Fourier Analysis in 2D: Overview 2D Extensions of Fourier Transform Aliasing and Moiré Patterns Fourier Transform of Images Matlab 2ENGI 4559 © Dr. Richard Khoury, 2009

3 2D Extensions: CTFT ENGI 4559 © Dr. Richard Khoury, 20093

4 2D Extensions: DTFT ENGI 4559 © Dr. Richard Khoury, 20094

5 2D Extensions: DFT ENGI 4559 © Dr. Richard Khoury, 20095

6 2D Extensions: Sampling Theorem 1D sampling theorem: If the maximum frequency contained in an analog signal is Ω max = B, then it can be perfectly reconstructed from samples taken at the sampling frequency Ω s = 2B (or more). 2D sampling theorem: If the maximum frequency contained in an analog signal is Ω 1 = B 1 in one direction and Ω 2 = B 2 in the other, then it can be perfectly reconstructed from samples taken at the sampling frequencies Ω s1 = 2B 1 in the first direction and Ω s2 = 2B 2 in the other. ENGI 4559 © Dr. Richard Khoury, 20096

7 2D Extensions: Aliasing ENGI 4559 © Dr. Richard Khoury, 20097

8 Aliasing in Images Imagine a perfect digital camera taking a picture of a checkerboard where each square is one pixel in size If we sample it (i.e. take the picture) at a resolution of several pixels per square, it works 16 pixels per square: 6 pixels per square: ENGI 4559 © Dr. Richard Khoury, 20098

9 Aliasing in Images At resolutions less than one pixel per square, severe aliasing occurs 0.9 pixels per square: ENGI 4559 © Dr. Richard Khoury, 20099

10 Aliasing in Images In DIP, modifying the sampling rate is not always possible Downsampling (shrinking) a picture would require access to the original scene to resample it Aliasing is unavoidable Often covered up by blurring the image slightly before resizing ENGI 4559 © Dr. Richard Khoury, 200910

11 Aliasing in Images Aliasing is very visible in diagonal edges ENGI 4559 © Dr. Richard Khoury, 200911

12 Moiré Patterns ENGI 4559 © Dr. Richard Khoury, 200912 Another common type of artefact Result of sampling an image that already has a sampled periodic element Typically visible in Two overlapping insect window screens Striped material on TV Digital scan of newspaper pictures

13 Moiré Patterns Take two patterns that are individually Clean and devoid of interference Periodic or nearly periodic At different angles from each other Superimposing one on the other creates a new pattern with frequencies that do not exist in the originals ENGI 4559 © Dr. Richard Khoury, 200913

14 Fourier Transform of Images The Fourier transform of an image is generally a complex number where ENGI 4559 © Dr. Richard Khoury, 200914

15 Fourier Transform of Images The magnitude r 12 is the Fourier spectrum or frequency spectrum r 12 ² is the power spectrum The exponent ω 12 is the phase angle We can display the resulting matrices as images! ENGI 4559 © Dr. Richard Khoury, 200915

16 Fourier Transform of Images Let’s run an experiment! We’ll use this image We compute the DFT and display the spectrum All the highest values are in the corners They correspond to the zero frequencies It’s more convenient (and conventional) to shift the graphic to display them in the middle Still too dark to make out the details So we normalize and display ENGI 4559 © Dr. Richard Khoury, 200916

17 Fourier Transform of Images The phase angle can be displayed directly What does it mean? The spectrum represents the amplitude of the sinusoids that form the signal The phase is the displacement of each sinusoid to the origin ENGI 4559 © Dr. Richard Khoury, 200917

18 ENGI 4559 © Dr. Richard Khoury, 200918

19 Fourier Transform of Images ENGI 4559 © Dr. Richard Khoury, 200919

20 Fourier Transform of Images The Fourier Spectrum represents intensities Their positions in the spectrum has meaning too ENGI 4559 © Dr. Richard Khoury, 200920 Center value (origin, since we shifted the graph) is the average intensity value of the image Low frequency values (near the origin) are slow- varying intensity regions High frequency values (far from the origin) are regions with fast variations in intensity

21 Matlab Matlab already implements the 1D and 2D DFT F = fft2(M) computes the 2D DFT of a matrix M M = ifft2(F) computes the 2D inverse DFT of a Fourier matrix, recovering the original matrix M F = fftshift(M) performs a quadrant shift of the matrix, which is convenient to display the Fourier spectrum ENGI 4559 © Dr. Richard Khoury, 200921

22 Matlab >> z = 4 + 3i; >> r = abs(z) r = 5 >> r = sqrt(real(z)^2 + imag(z)^2) r = 5 >> theta = atan2(imag(z),real(z)) theta = 0.6435 >> z = r *exp(i *theta) z = 4.0000 + 3.0000i ENGI 4559 © Dr. Richard Khoury, 200922

23 Matlab Computing the Fourier spectrum and phase angle %Read the image using the method we know imagereal = imread('lenna.png'); %Convert from uint8 to double for math imagereal = double(imagereal); %Fourier transform F = fft2(imagereal); %Fourier spectrum Spectrum = sqrt( real(F).^2 + imag(F).^2 ); %Shift the spectrum, as per convention SpectrumS = fftshift(Spectrum); %Phase angle Phase = atan2( imag(F), real(F) ); ENGI 4559 © Dr. Richard Khoury, 200923

24 Matlab Displaying the spectrum and phase figure; colormap(gray) imagesc(1+log10(SpectrumS)) title('Fourier Spectrum') figure; colormap(gray) imagesc(Phase) title('Phase angle') ENGI 4559 © Dr. Richard Khoury, 200924 Don’t forget to normalize the spectrum display!

25 Matlab Reconstructing the image %Shift the spectrum back SpectrumSS = fftshift(SpectrumS); %Compute the values of Fourier Transform F2 = SpectrumSS.* exp(sqrt(-1)* Phase ); %Perform the inverse DFT %Note that rounding errors can leave a small % imaginary part (  10 -14 ) which we must discard reconstructed = real(ifft2(F2)); %Display the image figure; colormap(gray) imagesc(reconstructed) title('Reconstructed image') ENGI 4559 © Dr. Richard Khoury, 200925

26 Summary We learned the 2D equations of the continuous-time, discrete-time, and discrete Fourier transform, and of the sampling theorem We considered the effect of aliasing and Moiré patterns, and the difference between these two phenomena We applied our knowledge by computing the Fourier transform of images, and splitting the result into the frequency spectrum and phase angle components And we learned the meaning of these two components ENGI 4559 © Dr. Richard Khoury, 200926


Download ppt "ENGI 4559 Signal Processing for Software Engineers Dr. Richard Khoury Fall 2009."

Similar presentations


Ads by Google