We know that f(x, y) and F (u, v) form a Fourier Transform pair, i.e. f(ax, by)e j2π(ux+vy) dx dy. x x. a 0 J = y y. = 0 b

Similar documents
Digital Image Processing

Contents. Signals as functions (1D, 2D)

Contents. Signals as functions (1D, 2D)

Solutions For Homework #5

Contents. Signals as functions (1D, 2D)

2D Discrete Fourier Transform (DFT)

Image Enhancement in the frequency domain. GZ Chapter 4

Fourier series: Any periodic signals can be viewed as weighted sum. different frequencies. view frequency as an

Fourier Transform 2D

MIT 2.71/2.710 Optics 10/31/05 wk9-a-1. The spatial frequency domain

2. Image Transforms. f (x)exp[ 2 jπ ux]dx (1) F(u)exp[2 jπ ux]du (2)

Appendix C: Recapitulation of Numerical schemes

Introduction to the Fourier transform. Computer Vision & Digital Image Processing. The Fourier transform (continued) The Fourier transform (continued)

G52IVG, School of Computer Science, University of Nottingham

3. Lecture. Fourier Transformation Sampling

Math 56 Homework 5 Michael Downs

Convolution Spatial Aliasing Frequency domain filtering fundamentals Applications Image smoothing Image sharpening

SIMG-782 Digital Image Processing Homework 6

28. Fourier transforms in optics, part 3

Chapter 4 Discrete Fourier Transform (DFT) And Signal Spectrum

&& && F( u)! "{ f (x)} = f (x)e # j 2$ u x. f (x)! " #1. F(u,v) = f (x, y) e. f (x, y) = 2D Fourier Transform. Fourier Transform - review.

EE 355 / GP 265 Homework 5 Solutions

Homework #1 Solution

Fast Multipole Methods: Fundamentals & Applications. Ramani Duraiswami Nail A. Gumerov

DISCRETE FOURIER TRANSFORM

1 Introduction to MATLAB

Module 3. Convolution. Aim

Why does a lower resolution image still make sense to us? What do we lose? Image:

ACM106a - Homework 2 Solutions

Lecture 4 Filtering in the Frequency Domain. Lin ZHANG, PhD School of Software Engineering Tongji University Spring 2016

Projections and Least Square Solutions. Recall that given an inner product space V with subspace W and orthogonal basis for

Fall 2011, EE123 Digital Signal Processing

LAB 6: FIR Filter Design Summer 2011

ECG782: Multidimensional Digital Signal Processing

Frequency Filtering CSC 767

EE 261 The Fourier Transform and its Applications Fall 2007 Problem Set Nine Solutions

Overview. Signals as functions (1D, 2D) 1D Fourier Transform. 2D Fourier Transforms. Discrete Fourier Transform (DFT) Discrete Cosine Transform (DCT)

Slide 1. Slide 2. Slide 3 Remark is a new function derived from called derivative. 2.2 The derivative as a Function

Fourier analysis of discrete-time signals. (Lathi Chapt. 10 and these slides)

Discrete Fourier Transform

A VERY BRIEF LINEAR ALGEBRA REVIEW for MAP 5485 Introduction to Mathematical Biophysics Fall 2010

L. Vandenberghe EE133A (Spring 2017) 3. Matrices. notation and terminology. matrix operations. linear and affine functions.

Problem Set 8 - Solution

Discrete Fourier transform

Distortion Analysis T

Introduction to Fourier Analysis Part 2. CS 510 Lecture #7 January 31, 2018

MATH 205 HOMEWORK #3 OFFICIAL SOLUTION. Problem 1: Find all eigenvalues and eigenvectors of the following linear transformations. (a) F = R, V = R 3,

DISCRETE FOURIER TRANSFORM

DOING PHYSICS WITH MATLAB FOURIER ANALYSIS FOURIER TRANSFORMS

FILTERING IN THE FREQUENCY DOMAIN

Advanced Computational Methods for VLSI Systems. Lecture 4 RF Circuit Simulation Methods. Zhuo Feng

Chapter 2 Formulas and Definitions:

Tutorial 9 The Discrete Fourier Transform (DFT) SIPC , Spring 2017 Technion, CS Department

SEISMIC WAVE PROPAGATION. Lecture 2: Fourier Analysis

18.085: Summer 2016 Due: 3 August 2016 (in class) Problem Set 8

ENGR-1100 Introduction to Engineering Analysis. Lecture 13

Math 365 Homework 5 Due April 6, 2018 Grady Wright

Filtering and Edge Detection

Anouncements. Assignment 3 has been posted!

Assignment 2 Solutions

sinc function T=1 sec T=2 sec angle(f(w)) angle(f(w))

Math 416, Spring 2010 More on Algebraic and Geometric Properties January 21, 2010 MORE ON ALGEBRAIC AND GEOMETRIC PROPERTIES

Fourier Matching. CS 510 Lecture #7 February 8 th, 2013

Lecture # 06. Image Processing in Frequency Domain

Digital Image Processing. Image Enhancement: Filtering in the Frequency Domain

V(t) = Total Power = Calculating the Power Spectral Density (PSD) in IDL. Thomas Ferree, Ph.D. August 23, 1999

Frequency2: Sampling and Aliasing

Math 304 (Spring 2010) - Lecture 2

USA Mathematical Talent Search Round 1 Solutions Year 24 Academic Year

Properties of Matrices

Image Processing in Numpy

Image Enhancement in the frequency domain. Inel 5046 Prof. Vidya Manian

Space-Frequency Atoms

000=0 001=1 010=2 011=3 100=4 101=5 110=6 111=7 000=0 100=4 010=2 110=6 001=1 101=5 011=3 111=7

IYGB Mathematical Methods 1

Thinking in Frequency

A = 3 B = A 1 1 matrix is the same as a number or scalar, 3 = [3].

MAT 343 Laboratory 3 The LU factorization

CS 322 Homework 4 Solutions

FFTs in Graphics and Vision. Homogenous Polynomials and Irreducible Representations

Math 515 Fall, 2008 Homework 2, due Friday, September 26.

4.3 The Discrete Fourier Transform (DFT) and the Fast Fourier Transform (FFT)

Space-Frequency Atoms

Linear Algebra Massoud Malek

Image Acquisition and Sampling Theory

Exploring the energy landscape

Frequency-domain representation of discrete-time signals

Vector Spaces, Orthogonality, and Linear Least Squares

EE 435. Lecture 32. Spectral Performance Windowing

CS137 Introduction to Scientific Computing Winter Quarter 2004 Solutions to Homework #3

Lecture 14: Convolution and Frequency Domain Filtering

Empirical Mean and Variance!

Tom Penick EE 325K Homework 10, November 30, 2000

(b) 7-fold symmetry. Figure 1: GroEL. Figure 2: Noisy and clean cryo-em Images of GroEL

Finite Math - J-term Section Systems of Linear Equations in Two Variables Example 1. Solve the system

IMAGE ENHANCEMENT: FILTERING IN THE FREQUENCY DOMAIN. Francesca Pizzorni Ferrarese

Reference Text: The evolution of Applied harmonics analysis by Elena Prestini

CEE598 - Visual Sensing for Civil Infrastructure Eng. & Mgmt.

Math 307 Learning Goals

BioE Exam 1 10/9/2018 Answer Sheet - Correct answer is A for all questions. 1. The sagittal plane

Transcription:

2 2

Problem 2:[10 pts] We know that f(x, y) and F (u, v) form a Fourier Transform pair, i.e. F (u, v) = Now, consider the integral G(u, v) = We make a change of variables [ x x ỹ x f(x, y)e j2π(ux+vy) dx dy f(ax, by)e j2π(ux+vy) dx dy x = ax (2) ỹ = by The Jacobian matrix of this linear transformation is ] [ a 0 J = = 0 b x y ỹ y and the new area element d xdỹ = J dxdy = ab dxdy. Thus, with thischange of variables introduced, Equation becomes G(u, v) = 1 [ ] f( x, ỹ)e j2π( u a x+ v b ỹ) d x dỹ a b But, the integral in square brackets can be recognized as the Fourier transform of f(x, y) evaluated at u a and v b. So, f(ax, by) G(u, v) = 1 a b F (u a, v b ) ] Problem 3:[10 pts] In this problem, the column direction is assigned the x axis, while the row direction is called y. The same designation applies to the frequency axes, i.e. the 2

f(x,y) = rect(x/31,y/15 0 F(u,v) = 31*15*sinc(31u)sinc(15v) y 50 100 150 200 v (normalized frequency) 0.2 0.4 0.6 0.8 250 50 100 150 200 250 x 1 0 0.2 0.4 0.6 0.8 1 u (normalized frequency) Figure 1: columns refer to the u spatial frequency axis while the rows denote the v axis. We display computed spectra with the DC value located in the upper left hand corner of the matrix. Thus, the spatial frequencies run from 0 to 1, in normalized frequency units, in both column and row directions. (a) The function f(x, y) = rect(x/31, y/15) 0 <= x, y <= 255 is shown in Figure 1. The magnitude spectrum, i.e. the absolute value of the Fourier Transform of f(x, y), is also shown in Figure 1. Analytically, we would expect the following Fourier relationship f(x, y) = rect(x/31, y/15) F (u, v) = 15 31 sinc(31u)sinc(15v) From this relationship, we would expect the width of the spectrum along the u (column) axis to be about 1 = 0.0667 and the width along the v row 15 axis approximately 1 = 0.14 in normalized frequency units. Indeed, as can 7 be seen on the left side in Figure 3, which is a zoomed-in version of the upper left-hand corner of Figure 1, we observe that the first null of the sinc function in the column (u) direction occurs at about 0.06 whole the first null in the row (v) occurs at about 0.15, consistent with what we expect. (b) The function f(x, y) = rect(r/15) 128 <= x, y <= 127 is shown in Figure 2. The magnitude spectrum, i.e. the absolute value of the Fourier Transform of f(x, y), is also shown in Figure 2. Analytically, we would 3

f(x,y) = rect(r/15 0 F(u,v) = 15*jinc(15q) y 100 50 0 50 100 100 50 0 50 100 x v (normalized frequency) 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1 u (normalized frequency) Figure 2: expect the following Fourier relationship f(x, y) = rect(r/15) F (u, v) = 15 2 jinc(15q) where, r = x 2 + y 2 and q = u 2 + v 2. From this relationship, we would expect a circularly symmetric spectra, as evidenced by Figure 2. Furthermore, we expect the width of the spectrum, in the radial direction, to be about 1 = 0.14. By inspection of the right side of Figure 3, which is a 7 zoomed-in version of the upper left hand corner of Figure 2, we see that the first null of the jinc function occurs when u 0.9 and v 0.9, giving a radial distance of about q 2 0.9 = 1.3, which is consistent with our expectations. Problem 4:[10 pts] Recall the Shift Theorem, which says f(x x 0, y y 0 ) F (u, v)e j2π(ux 0+vy 0 ) where f(x, y) and F (u, v) form a Fourier Transform pair. In words, this Theorem states that a translation of a 2D function in the spatial domain results in multiplication of the function s spectrum by a phase ramp in the frequency domain. In 4

F(u,v) = 31*15*sinc(31u)sinc(15v) v (normalized frequency) 0.05 0.1 0.15 0.2 0 0.05 0.1 u (normalized frequency) v (normalized frequency) F(u,v) = 15*jinc(15q) 0 0.02 0.04 0.06 0.08 0.1 0 0.02 0.04 0.06 0.08 0.1 u (normalized frequency) Figure 3: this problem, we will make use of the discrete version of the Shift Theorem for Fourier Transforms to implement the desired imageshift of 27.3 pixels to theright and 35.2 pixels in the downward direction. When the shifts (x 0, y 0 ) are integers, the phasor in Equation is easily constructed as follows e j2π( k N x 0+ l M y 0) k = 0,..., N 1, l = 0,..., M 1 where, for N horizontal frequency bins and M vertical frequency bins, the discrete frequencies are u = k and v = l. We note, in particular, that N M e j2π k N x N k 0 j2π = e N x 0 (3) e j2π l M y M l 0 j2π = e M y 0 when x 0 and y 0 are integers. Recall that, for a real-valued discrete time signal f(n) (let s take the 1D case for simplicity), f(n) F (k) and F (N k) = F (k) where denotes complex conjugation. The same applies for two dimensional signals. Thus, when x 0 and y 0 are integers, multiplying the 2D spectrum of an image 5

by a phasor, constructed above, and then taking the inverse Fourier Transform results in a real-valued image shifted by x 0 pixels across and y 0 pixels down. The problem arises when the fractional shifts, as is our case, are desired. In this case, we need construct the phasor to explicitly obey the constraint in (4) above. The MATLAB code for doing this is given at the back. The original image is shown in Figure 4 while the shifted image is given in Figure 5. Note how the shift, for image before shift 50 100 150 50 100 150 200 250 300 350 400 450 500 Figure 4: image after shift, 35.2 pixels down, 27.3 right 50 100 150 50 100 150 200 250 300 350 400 450 500 Figure 5: finite-length signals (or images in our case), actually wraps the image around the edges, i.e. the shift in both the column and row directions is circular. Problem 5:[10 pts] (a) The amplitude image from the data file hw4prob5data required a linear stretch before display. We applied the linear stretch equation from Homework 1 image stretched = 80 image µ + 128 (4) σ 6

where µ = 59 and σ = 81.5 refer to the mean and standard deviation of pixel values in the original image. The result after stretching is shown in Figure 6 We note that the width of the box in the center of the image is Figure 6: about 800 pixels, its height about 600 pixels. (b) We compute the 2D Fourier Transform of the image using the FFT2 routine in MATLAB. Displayed in Figure 7 is the magnitude of the spectrum, in DB, using the formula 20log 10 (spectrum). We note that the u and v frequency axes have been set such that DC is located in the center of the matrix. Furthermore, the u and v axes are in normalized frequency units. (c) Figure 7 shows that most of the energy is concentrated near the spatial frequencies u 0.23 and v 0.17. It is as if the entire frequency content has been shifted from DC to those coordinates. By the Shift Theorem, we know that F (u u 0, v v 0 ) f(x, y)e j2π(xu 0+yv 0 ) (5) 7

Figure 7: In other words, a translation of the origin in the frequency domain (in the case above, from (0, 0) to about ( 0.23, 0.17)) results in a phase modulation in the space domain. Indeed, by looking at the angle of the complex numbers comprising the image formed from hw4prob5data, we see the modulation pattern shown in Figure 8: Notice that the wave-like behavior of the modulation is a consequence of the phase of e j2π(xu 0+yv 0 ). The direction perpendicular to the phase fronts exactly equals to the translation direction of the spectrum in the Fourier domain. Figure 8 shows a zoomed in version of the translated spectrum. As mentioned previously, most of the energy seems to be concentrated near u 0.23 and v 0.17. Thus, neglecting the phase modulation, the image is generally smooth. Furthermore, we observe a certain symmetry in the 2D distributionof Fourier coefficients infigure 7. This isdue tothe real-valued nature of the image. It can be seen, from Figure 8, that most of the enery is located in a square of width about 0.08 normalized frequency units in length. This square can be considered the effective bandwidth of the im- 8

3 2 1 0 1 v 0.05 0.1 0.15 0.2 Power spectrum in DB 140 120 100 80 60 2 3 0.25 40 0.3 0.25 0.2 0.15 0.1 u Figure 8: age. From Figure 8, we also observe energy distributed in frequency bins on lines oriented at an angle to the u axis. This directed distribution of energy implies that 2D sinusoidal variations in the same direction are particularly pronounced in the image. Problem 6:[10 pts] (a) Figure 9 shows the spectrum magnitude computed using MATLAB s FFT subroutines. The reported elapsed computation time was 0.1869 seconds. (b) Our implementation of the DFT algorithm involves matrix-vector multiplication. Recall that the DFT for a N-point signal (i.e. sequence of numbers), f(n), is computed as follows F (k) = N 1 n=0 nk j2π f(n)e N k = 0,..., N 1 (6) Note that the result of the DFT is a new sequence, F (k), of length N representing the N Fourier coefficients. We also observe that the equation above 9

spectrum using FFT 50 100 150 200 250 300 350 400 450 500 50 100 150 200 250 300 350 400 450 500 Figure 9: can be implemented as a dot product between two vectors 1 e j2π k N. F (k) = [f(0) f(1)... f(n 1)].. (N 1)k j2π e N (7) The result of the dot product above is the k-th DFT coefficient. Hence, we can form the entire N-length sequence of DFT coefficients by multiplying the signal f(n) with a matrix A whose ij-th entry is A ij = e j2π ij N (8) This is how we implement our DFT algorithm. In particular, we loop down the rows of the image, computing a 1D DFT for each line and storing the 10

result. Subsequently, we loop across the columns and compute 1D DFTs down the rows. We find that the running time for our MATLAB implementation of the DFT is about 4.13 seconds. We see that our the FFT implementation of the DFT performs much faster than our implementation of the DFT. The way we have implemented our DFT algorithm, we would expect there to be MN 2 + NM 2 operations for an M N image. We get this by noting that a matrix-vector multiplication for a row of length N, for example, requires N 2 operations and there are M rows, giving a total of MN 2 operations. On the other hand, we know that a 1D FFT operation on a row of length N costs N log N operations. With M rows, the cost would be about MN log N, giving a total (FFTs across the rows and columns) of MN log MN. Thus, the theoretical savings achieved by using FFT routines as opposed to our DFT implementations would be of the order =. The resulting image is shown in Figure 10 MN log MN MN 2 +NM 2 log MN N+M spectrum using DFT 50 100 150 200 250 300 350 400 450 500 50 100 150 200 250 300 350 400 450 500 Figure 10: 11

MATLAB code for Problem 4 % EE 262 Spring 2005, Problem Set 4 %----------------------------------% % Problem 4 %-----------% % load in file fid = fopen( stanfordbw, rb ); data = fread(fid, inf, uint8 );fclose(fid) % reshape into image im = reshape(data, [540 173]);im = im ; % note: we define u along the columns, and v DOWN the rows % create a grid of (u,v) frequencies, of dimensions % 173 rows 560 columns, with u = 0, 1/540,...,539/540, % v = 0,1/173,...,172/173 [u,v] = meshgrid([0:540-1]/540,[0:173-1]/173); % create phase ramp in column direction (right) phase_rampu = zeros(size(im)); phase_rampu(:,1:540/2) = 2*pi*(u(:,1:540/2)*27.3); phase_rampu(:,540:-1:540/2+1) = -2*pi*(u(:,1:540/2)*27.3); % create phase ramp in row direction (down) phase_rampv = zeros(size(im)); phase_rampv(1:(173+1)/2,:) = 2*pi*(v(1:(173+1)/2,:)*35.2); phase_rampv(173:-1:(173+1)/2+1,:)=-2*pi*(v(1:(173+1)/2-1,:)*35.2); 12

% apply phase ramp to image spectrum and inverse transform exp_phase_ramp=exp(-sqrt(-1)*phase_rampu).*exp(-sqrt(-1)*phase_rampv); im_shifted = ifft2( fft2(im).*exp_phase_ramp); % display figure(1); imagesc(im);axis image; caxis([0 255]);colormap bone; h1=title( image before shift );set(h1, FontSize,20); figure(2); imagesc(real(im_shifted));axis image; caxis([0 255]);colormap bone; h1=title( image after shift, 35.2 pixels down, 27.3 right ); set(h1, FontSize,20); MATLAB code for Problem 6 % EE 262 Spring 2005, Problem Set 4 %----------------------------------% % Problem 6 %-----------% % part (a) % load in file fid = fopen( hw4prob6data, rb ); data = fread(fid, inf, float );fclose(fid) % reshape into image im = reshape(data, [512*2 512]);im = im ; im = im(:,1:2:end-1) + sqrt(-1)*im(:,2:2:end); % part (a) 13

% compute spectrum using FFT tic spec1 = fft2(im); toc % part (b) % compute spectrum using DFT % form DFT matrix, n increases along columns, % k down rows [n,k] = meshgrid([0:512-1],[0:512-1]); DFT = exp(sqrt(-1)*2*pi*(n).*(k)./512); spec2 = zeros(512,512); spec3 = zeros(512,512); tic % DFT in column direction for rows = 1:512 x = im(rows,:) ; spec2(rows,:) = ( (DFT*x) ); end % DFT in row direction for cols = 1:512 x = spec2(:,cols); spec3(:,cols) = ( (DFT *x) ); end toc % display figure(1); imagesc(abs(spec1));axis image;colormap bone; h1=title( spectrum using FFT ); set(h1, FontSize,20); figure(2); imagesc(abs(spec3));axis image;colormap bone; h1=title( spectrum using DFT ); set(h1, FontSize,20); 14