-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfresnel.m
More file actions
43 lines (29 loc) · 804 Bytes
/
fresnel.m
File metadata and controls
43 lines (29 loc) · 804 Bytes
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
36
37
38
39
40
41
42
43
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Fresnel propagation in vacuum %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Written by Marc Guillon (marc.guillon@u-paris.fr)
%
% function B = fresnel(A,lambda,z,px)
%
% INPUTs:
% A: ( N x N matrix) wavefield at z=0
% lambda: wavelength
% z: axial shift
% px: pixel size
%
% Nota Bene: lambda, z and px should be in the same unit.
%
% OUTPUTs:
% B: ( N x N matrix) wavefield at z
%
function B=fresnel(A,lambda,z,px)
NA=1;
OS=lambda/(2*NA*px);
N=size(A,1);
[x,y]=meshgrid([-N/2:N/2-1]);
x=x/N;
y=y/N;
r2=x.^2+y.^2;
defocus=exp( 2*i*pi* z*NA^2/(2*lambda) *4* r2 * OS^2);
B=ifftshift(ifft2( ifftshift( defocus ) .* fft2(fftshift(A)) ));
return