-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfresnelImpulseResponse.m
More file actions
36 lines (34 loc) · 1.21 KB
/
fresnelImpulseResponse.m
File metadata and controls
36 lines (34 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function diffraction_image = fresnelImpulseResponse(object_image, plane_side_length,wavelength,propagation_distance)
%%performs fresnel impulse response of 2D image and returns irradiance
%%image
%Inputs:
% object_image: the image of the object to be diffracted
% plane_side_length: the length of the object plane (assumed square)
% wavelength: the wavelength of the simluated monochromatic light
% propagation distance: the distance between the object plane and the
% observation plane
%
%Outputs:
% diffraction_image: the irradiance image of the diffraction pattern
%get the pixel size of the object
[M,~] = size(object_image);
%get the sample size
dx = plane_side_length/M;
%wavenumber
k = 2*pi/wavelength;
%create coordinates in spatial space
x = -plane_side_length/2:dx:plane_side_length/2-dx;
[X,Y] = meshgrid(x,x);
%impulse response function
h = 1/(1i*wavelength*propagation_distance)*exp(1i*k/(2*propagation_distance)*(X.^2+Y.^2));
%create transfer function
H=fft2((h))*dx^2;
%shift, fft object image
U1 = fft2((object_image));
%convolution in fourier space
U2 = H.*U1;
%ifft, shift
diffraction_image = (ifft2(U2));
%get irradiance image of diffraction pattern
diffraction_image = abs(diffraction_image).^2;
end