Is this code of Angular Spectrum Method correct?
30 ビュー (過去 30 日間)
古いコメントを表示
I constructed my code of the Angular Spectrum Method. However, as the distance between the object and the plane of interest increases, the diffraction pattern never disappears; there is still some sort of a diffraction pattern, and I am expecting that it disappears as distance increases.
Here is the code:
clear; clc;
layer = zeros(499, 499);
diameter = 100*10^(-6);
radius = diameter/2;
wavelength = 500*10^(-9);
altitude = 2*10^(-3);
img_width = 1*10^(-3);
img_length = 1*10^(-3);
lambda = wavelength; % wavelength (meters)
z = altitude; % altitude (meters)
k = 2*pi/lambda; % wavenumber
phy_x = img_width; % physical width (meters)
phy_y = img_length; % physical length (meters)
obj_size = size(layer);
% alpha and beta (wavenumber components)
dx = linspace(-phy_x/2, phy_x/2, obj_size(2));
dx = dx(1:length(dx));
dy = linspace(-phy_y/2, phy_y/2, obj_size(1));
dy = dy(1:length(dy));
for i = 1:obj_size(2);
for j = 1:obj_size(1)
if sqrt(dx(i)^2 + dy(j)^2) <= radius;
layer(j, i) = 1;
end;
end;
end;
U0 = fftshift(fft2(layer));
Fs_x = obj_size(2)/img_width; Fs_y = obj_size(1)/img_length;
dx2 = Fs_x^(-1); dy2 = Fs_y^(-1);
x2 = dx2*(0:(obj_size(2) - 1))'; y2 = dy2*(0:(obj_size(1) - 1))';
dFx = Fs_x/obj_size(2); dFy = Fs_y/obj_size(1);
Fx = (-Fs_x/2:dFx:(Fs_x/2 - dFx)); Fy = (-Fs_y/2:dFy:(Fs_y/2 - dFy));
alpha = lambda.*Fx; beta = lambda.*Fy;
% gamma
gamma = zeros(length(beta), length(alpha));
for j = 1:length(beta);
for i = 1:length(alpha);
if (alpha(i)^2 + beta(j)^2) > 1;
gamma(j, i) = 0;
else
gamma(j, i) = sqrt(1 - alpha(i)^2 - beta(j)^2);
end;
end;
end;
U1 = ifft2(fftshift(fft2(layer)).*exp(1i*k.*gamma.*z));
I1 = (1/(16*pi)).*(U1.*conj(U1));
I think my error came from the calculation of the alpha and beta components. I just don't know where...
Thank you in advance.
0 件のコメント
回答 (1 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!