Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
phase of fft of gaussian

Subject: phase of fft of gaussian

From: Amy Wang

Date: 25 Jan, 2010 13:00:20

Message: 1 of 3

Dear all,

I'm a bit confused when I look at the phase part of the FFT of a gaussian function.
As in the code below, I applied fft2 on the gaussian function. The abs(ftrealgauss) is ok, centered at the center. However, when I image the phase of the function imagesc(angle(ftrealgauss)), I get the oscillating circular rings with additional strips at the center. This strip only occurs at pixels close to the center of x and y axis, and it somehow seems like a repeating boundary. Does anyone know how to fix this or the reason to this?

% my code
dx = 0.15;
K = 256; L = 256;
[X,Y] = meshgrid((-(4*K-1)/2*dx/4:dx/4:(4*K-1)/2*dx/4)-dx/8,(-(4*L-1)/2*dx/4:dx/4:(4*L-1)/2*dx/4)-dx/8);
R = sqrt(X.^2+Y.^2);
realgauss = 1+ (1/(2*sqrt(2*pi)))*exp(-R.^2/(4*2^2)); %column width = 2
ftrealgauss = fftshift(fft2(realgauss));
% end my code

Many thanks in advance!!!

Amy

Subject: phase of fft of gaussian

From: Jomar Bueyes

Date: 25 Jan, 2010 13:29:37

Message: 2 of 3

On Jan 25, 8:00 am, "Amy Wang" <amy.w...@ua.ac.be> wrote:
> Dear all,
>
> I'm a bit confused when I look at the phase part of the FFT of a gaussian function.
> As in the code below, I applied fft2 on the gaussian function. The abs(ftrealgauss) is ok, centered at the center. However, when I image the phase of the function imagesc(angle(ftrealgauss)), I get the oscillating circular rings with additional strips at the center. This strip only occurs at pixels close to the center of x and y axis, and it somehow seems like a repeating boundary. Does anyone know how to fix this or the reason to this?
>
> % my code
> dx = 0.15;
> K = 256; L = 256;
> [X,Y] = meshgrid((-(4*K-1)/2*dx/4:dx/4:(4*K-1)/2*dx/4)-dx/8,(-(4*L-1)/2*dx/4:dx/4:(4*L-1)/2*dx/4)-dx/8);
> R = sqrt(X.^2+Y.^2);
> realgauss = 1+ (1/(2*sqrt(2*pi)))*exp(-R.^2/(4*2^2)); %column width = 2
> ftrealgauss = fftshift(fft2(realgauss));
> % end my code
>
> Many thanks in advance!!!
>
> Amy

Hi Amy,

The phase you observe is due to the fact that the peak of the Gaussian
is located at the center of the array. For discrete Fourier transform
(DFT) purposes the origin is at the upper-left corner of the array,
the (1,1) element. That is, what you are seeing is a result of the
shift property of the DFT. That is, shifting in space is modulating in
frequency. To avoid that modulation you need to move the peak of the
Gaussian to the origin and wrap around the samples. This is easily
done with Matlab's circshift function.

HTH

Jomar

Subject: phase of fft of gaussian

From: Amy Wang

Date: 25 Jan, 2010 14:13:05

Message: 3 of 3

Thanks for the suggestion! However, I tried to add the circshift function like below, I still get those strips.
With the (1) ftrealgauss, the angle of complexgauss_column, I get
http://picasaweb.google.com/lh/photo/u10dGrh5W0P-BKx0V9emaA?feat=directlink
So it was the rings + strips
But then with (2) ftrealgauss, the angle of complexgauss_column became like
http://picasaweb.google.com/lh/photo/Mq9oQrHYkrpwplr1QS0n-A?feat=directlink
Or what I've done wrong there?

Thanks in advance!!!
Amy
% my code
dx = 0.15;
K = 256; L = 256;
[X,Y] = meshgrid((-(4*K-1)/2*dx/4:dx/4:(4*K-1)/2*dx/4)-dx/8,(-(4*L-1)/2*dx/4:dx/4:(4*L-1)/2*dx/4)-dx/8);
R = sqrt(X.^2+Y.^2);
realgauss = 1+ (1/(2*sqrt(2*pi)))*exp(-R.^2/(4*2^2)); %column width = 2
% from here it's a bit different
% re-select a smaller region (the center region)
realgauss_column = realgauss((513-256):(513+255),(513-256):(513+255));
% fourier transform (2) is with the circshift
(1) ftrealgauss_column = fftshift(fft2(realgauss_column));
(2) ftrealgauss = circshift(fftshift(fft2(circshift(realgauss_column,[-256 -256]))),[256 256]);
% the real gauss multiply with another function in fourier space
dg1 = 1/((dx/4)*(4*K+1));
[GX1,GY1] = meshgrid((-(4*K-1)/2*dg1:dg1:(4*K-1)/2*dg1)-dg1/2,(-(4*L-1)/2*dg1:dg1:(4*L-1)/2*dg1)-dg1/2);
G1 = sqrt(GX1.^2+GY1.^2);

G1_c = G1((513-256):(513+255),(513-256):(513+255));
complexgauss_column = ftrealgauss_column.*exp(-i*(pi*10*0.02*G1_c.^2+0.5*pi*0.6*0.02^3*G1_c.^4));
%****************************************************


Jomar Bueyes <jomarbueyes@hotmail.com> wrote in message <5ad17594-2745-49e8-884e-d30e527b5279@h34g2000yqm.googlegroups.com>...
> On Jan 25, 8:00 am, "Amy Wang" <amy.w...@ua.ac.be> wrote:
> > Dear all,
> >
> > I'm a bit confused when I look at the phase part of the FFT of a gaussian function.
> > As in the code below, I applied fft2 on the gaussian function. The abs(ftrealgauss) is ok, centered at the center. However, when I image the phase of the function imagesc(angle(ftrealgauss)), I get the oscillating circular rings with additional strips at the center. This strip only occurs at pixels close to the center of x and y axis, and it somehow seems like a repeating boundary. Does anyone know how to fix this or the reason to this?
> >
> > % my code
> > dx = 0.15;
> > K = 256; L = 256;
> > [X,Y] = meshgrid((-(4*K-1)/2*dx/4:dx/4:(4*K-1)/2*dx/4)-dx/8,(-(4*L-1)/2*dx/4:dx/4:(4*L-1)/2*dx/4)-dx/8);
> > R = sqrt(X.^2+Y.^2);
> > realgauss = 1+ (1/(2*sqrt(2*pi)))*exp(-R.^2/(4*2^2)); %column width = 2
> > ftrealgauss = fftshift(fft2(realgauss));
> > % end my code
> >
> > Many thanks in advance!!!
> >
> > Amy
>
> Hi Amy,
>
> The phase you observe is due to the fact that the peak of the Gaussian
> is located at the center of the array. For discrete Fourier transform
> (DFT) purposes the origin is at the upper-left corner of the array,
> the (1,1) element. That is, what you are seeing is a result of the
> shift property of the DFT. That is, shifting in space is modulating in
> frequency. To avoid that modulation you need to move the peak of the
> Gaussian to the origin and wrap around the samples. This is easily
> done with Matlab's circshift function.
>
> HTH
>
> Jomar

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us