-
Notifications
You must be signed in to change notification settings - Fork 0
/
a_simulation_hologram_plane_wave.m
52 lines (44 loc) · 1.87 KB
/
a_simulation_hologram_plane_wave.m
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SIMULATION OF HOLOGRAM OF AN OBJECT RECORDED WITH PLANE WAVES
% Author: Tatiana Latychevskaia
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Citation for this code/algorithm or any of its parts:
% Tatiana Latychevskaia and Hans-Werner Fink
% "Practical algorithms for simulation and reconstruction of digital in-line holograms",
% Appl. Optics 54, 2424 - 2434 (2015)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The code is written by Tatiana Latychevskaia, 2002
% tatiana(at)physik.uzh.ch
% The version of Matlab for this code is R2010b
clear all
close all
% addpath('C:/Program Files/MATLAB/R2010b/myfiles');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PARAMETERS
N = 500; % number of pixels
lambda = 500*10^(-9); % wavelength in meter
area = 0.002; % area sidelength in meter
z = 0.08; % z in meter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% CREATING OBJECT
object = zeros(N,N);
object0 = imread('psi500.jpg');
object(:,:) = object0(:,:,1);
object = (object - min(min(object)))/(max(max(object)) - min(min(object)));
figure, imshow(object, []);
object = double(1 - object);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SIMULATING HOLOGRAM
prop = Propagator(N, lambda, area, z);
U = IFT2Dc(FT2Dc(object).*prop);
hologram = abs(U).^2;
figure, imshow(hologram, []);
colormap(gray)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SAVING HOLOGRAM
fid = fopen(strcat('a_hologram.bin'), 'w');
fwrite(fid, hologram, 'real*4');
fclose(fid);
p = hologram;
p = 255*(p - min(min(p)))/(max(max(p)) - min(min(p)));
imwrite (p, gray, 'a_hologram.jpg');