Fast Fourier Transform (FFT) function won't work for more than 1x1 array of circular apertures

7 views (last 30 days)
Below is a program that generates an NxN array of circular apertures and uses fast fourier transform (FFT) function to produce a diffraction pattern.
n_circles=4 % Define the number of circles to be plotted
n0 = (2^10)/n_circles; % Define the size of the basic mask
M0 = zeros(n0); % Initialize the basic mask
I = 1:n0; % Define the x and y coordinates of the basic mask
x = I - n0/2;
y = n0/2 - I;
[X,Y] = meshgrid(x,y); % Create the mask
R = n0/2; % Define the radius of the basic circle
A = (X.^2 + Y.^2 <= R^2); % Get the indices of the points inside the basic circle
M0(A) = 1; % Set basic mask
figure
M=repmat(M0,n_circles,n_circles); % Replicate basic mask according to the number of circles to be plotted
imagesc(M)
daspect([1 1 1])
%Fast fourier transform (FFT)
DP = fftshift(fft2(M));
imagesc(abs(DP))
axis image
imagesc(abs(log2(DP)))
axis image
When the number of circles (n_circles) is 1, the output looks right, as shown in figure 1. But when the n_circles is raised to a number higher than 1, the program produces bad results. As an example, figure 2 shows the result for a 2 by 2 array of circles.
figure 1. result for 1 circular aperture.
figure 2. result for 2 by 2 array of circular apertures.
Can anyone help me fix the problem? Thanks.

Accepted Answer

David Goodmanson
David Goodmanson on 20 Feb 2018
Hi Viron,
While there is a diffraction pattern of a kind, it is not what is usually associated with diffraction by a circular aperture. The issue is aperture size, which is so large that almost everything goes through unaffected. Basically it’s a ray model. If you go to n = 1 (I am going to use n for n_circles), plot DP with
imagesc(abs(DP)), colorbar
and zoom in on the center of the plot, you will see a yellow dot at k = 0. That is the diffraction 'pattern'. There is a small amount of diffraction from the edge of the aperture as seen in the third image.
The smaller the aperture, the wider the diffraction pattern. If you put n = 1 and make the aperture a lot smaller, say R = 20, then DP shows a nice pattern.
For multiple apertures, the code below makes even R smaller so that the diffraction pattern is wider, and zooms in. It keeps R at a constant size. That way as n increases, two things are not happening at once. (The method used to zerofill M is not exactly recommended, but it works).
Multiple equally spaced apertures give [the single aperture pattern] x [the diffraction pattern for multiple narrow slits]. The visuals are not crystal clear, but for increasing n, the spacing between the apertures decreases and the width of the slit pattern increases.
It turns out that if the aperture spacing exactly divides the size of the array, the fft can't reproduce the slit diffraction pattern very well at all, and you get some funky stuff going on. As with what you saw for n = 2. Here I made a deliberate attempt to have a spacing that does not divide 2^10.
n_circles = 2 % Define the number of circles to be plotted
n0 = round(1023/n_circles); % Define the size of the basic mask
M0 = zeros(n0); % Initialize the basic mask
I = 1:n0; % Define the x and y coordinates of the basic mask
x = I - n0/2;
y = n0/2 - I;
[X,Y] = meshgrid(x,y); % Create the mask
R = 4; % Define the radius of the basic circle
A = (X.^2 + Y.^2 <= R^2); % Get the indices of the points inside the basic circle
M0(A) = 1; % Set basic mask
M=repmat(M0,n_circles,n_circles); % Replicate basic mask according to the number of circles to be plotted
M(2^10,2^10) = 0; % zerofill the rest of the matrix
figure(1)
imagesc(M)
daspect([1 1 1])
%Fast fourier transform (FFT)
DP = fftshift(fft2(M));
figure(2)
imagesc(abs(DP(300:700,300:700))), colorbar
axis image
figure(3)
imagesc(abs(log2(DP)))
axis image
  3 Comments
David Goodmanson
David Goodmanson on 22 Feb 2018
Hi Viron,
You can certainly make sets of circles that touch each other. Suppose you do that for, say, a 5x5 array if circles of size R = 4, so matrix M1 has size 40x40 all together. Then you can insert that into the middle of the larger array with
M = zeros(1024,1024);
M(492:531,492:531) = M1;
Viron Gil Estrada
Viron Gil Estrada on 26 Feb 2018
Hi David, I tried to incorporate that to your code but it still doesn't work. Maybe I did it wrong, so can you check where I made a mistake? Great thanks!
n_circles = 4 % Define the number of circles to be plotted
n0 = round(16/n_circles); % Define the size of the basic mask
M0 = zeros(n0); % Initialize the basic mask
I = 1:n0; % Define the x and y coordinates of the basic mask
x = I - n0/2;
y = n0/2 - I;
[X,Y] = meshgrid(x,y); % Create the mask
R = 2; % Define the radius of the basic circle
A = (X.^2 + Y.^2 <= R^2); % Get the indices of the points inside the basic circle
M0(A) = 1; % Set basic mask
M2=repmat(M0,n_circles,n_circles); % Replicate basic mask according to the number of circles to be plotted
M2(2^4,2^4) = 0; % zerofill the rest of the matrix
M = zeros(1024,1024);
M(492:531,492:531) = M2;
figure(1)
imagesc(M)
daspect([1 1 1])
%Fast fourier transform (FFT)
DP =fftshift(fft2(M));
DM = abs(DP).^2;
figure(2)
imagesc(abs(DM(300:700,300:700))), colorbar
axis image
figure(3)
imagesc(abs(log2(DP)))
axis image

Sign in to comment.

More Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!