16 views (last 30 days)

Show older comments

Hello All,

Please help me on the following- I need to construct an Fourier Transormed image such an Fig.1, But so far I have got my result like Fig.2 with expected pattern but low resulation. How could I edit my cod to get the expected high resultaion result? Please help me. I am adding my code here.

L=10*pi;

M=1000;

x = linspace(-L,L,M);

[X, Y] = meshgrid(x, x);

%pentagonal

N=5;

Quasi = zeros(size(X));

phi = linspace(2*pi/N,2*pi,N);

for i =1:N

for i=1:N

Quasi = Quasi + exp((1j*(sin(phi(i))*X +cos(phi(i))*Y)));

end

end

figure(1)

colormap jet

pcolor(X, Y, real(Quasi));shading interp

%% 2d Fourier transform

F = fft2(abs(Quasi));

imagesc(abs(fftshift(F))); colormap gray;

David Goodmanson
on 25 Apr 2021

Edited: David Goodmanson
on 27 Apr 2021

The nested for loops use the same variable i, meaning that the outer one doesn't do anything except run through the inner one five times, spending time at it. You can reduce the for loops to just one, with the same result only faster.

There are a couple of ways to see something. If you drop the abs and use

F = fft2(Quasi);

then zoom in to the center of the image, you can see points in a nice pentagon pattern, representing the five wave components. If abs is part of the problem specification (because a density is being modeled or something similar), then there is a large nonzero average for all the elements of abs(Quasi). That leads to a very large DC component in the fft, right at the very center of the image. Hard to see anything else. You can remove the DC component and see a good pattern (after zooming in) with

aQ = abs(Quasi);

F = fft2(aQ-mean(mean(aQ)));

Incidentally, although it did not matter in this case, it is best to use

F = fft2(ifftshift(aQ-mean(mean(aQ))));

That's because you constructed the spacial array with x=0, y=0 at the center of the array, and ifftshift puts (0,0) at the corner of the array where fft2 expects it to be.

David Goodmanson
on 30 Apr 2021

There are approximately 10 cycles over the width of the window, also over the height of the window. This means that for the frequency domain, the pattern has its strongest peaks approximateiy 10 array elements away from the origin. Since the image is 1000x100 points, zooming will be necessary in order to see them. That's just a feature of the fft.

Since the waves are at an angle to the x and y axes, there are not an exact integral number of cycles across the height or width. This means that in the frequency domain you do not see perfectly sharp peaks, but rather some blurring of them.

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!