summaryrefslogtreecommitdiff
path: root/demo_diffraction_on_a_disk.m
blob: 13f1ebec27dd4aaea35791e0d0f9559edd7f7acc (plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
% light wavelength
lambda=795e-9; % Rb D1 line

% set up mask (source image)
Nx_s=301;
Ny_s=301;
img_source=zeros(Ny_s,Nx_s); 

src_size = 1.0*12.5e-3;
xpos_s=linspace( -src_size, src_size, Nx_s);
ypos_s=linspace( -src_size, src_size, Ny_s);

[xmesh,ymesh]=meshgrid(xpos_s,ypos_s);
w=0.0014*3/2;
R=.3; % positive R is focusing along propagation
z_before_mask=LaguerreGaussianE([0,0,q_(w,R,lambda),lambda],xmesh,ymesh,'cart');

% disk mask
mask_R = (w*0.33);
mask = mask_transparency(xmesh,ymesh, mask_R);

% resulting field after mask
img_source= z_before_mask .* mask;
%img_source= z_before_mask;


%% set up target image
% square image
Nx_t=101;
Ny_t=101;
img_t=zeros(Ny_t,Nx_t); 
tgt_size_x = 12.5e-3;
tgt_size_y = tgt_size_x;
xpos_t=linspace( -tgt_size_x, tgt_size_x, Nx_t);
ypos_t=linspace( -tgt_size_y, tgt_size_y, Ny_t);

% one quadrant, suitable for symmetrical images
%xpos_t=linspace( 0, tgt_size, Nx_t);
%ypos_t=linspace( 0, tgt_size, Ny_t);

% slice along x axis for radial simmetry
%ypos_t=linspace( 0, 0, Ny_t);

%% full image which mimics camera
Nx_t=101; % use Nx_t = 680 to mimic camera
Ny_t=int32(Nx_t*(480/640));
img_t=zeros(Ny_t,Nx_t); 
tgt_size_x = (640*7e-6)/2; % each pixel is 7 um
tgt_size_y = (480*7e-6)/2;
xpos_t=linspace( -tgt_size_x, tgt_size_x, Nx_t);
ypos_t=linspace( -tgt_size_y, tgt_size_y, Ny_t);

z_t=.50;


% generating image of the mask accounting the diffraction
tic; % start timer
img_t=diffracted_image_at_target(img_source, xpos_s, ypos_s, img_t, xpos_t, ypos_t, z_t, lambda);
toc % show evaluation time

dstr = datestr(now,'yyyymmdd-HH:MM:SS');
fname = strcat('diffracted_image', '_', dstr, '.png');
img_t_intensiry = abs(img_t/max(img_t(:))).^2;
imwrite(img_t_intensiry, fname);

% plot source and target images
show_diffraction(img_source, xpos_s, ypos_s, img_t, xpos_t, ypos_t);

% radial slice of the target image
figure(3); plot( xpos_t, abs( img_t(Ny_t/2,:) ) )