Openholo  v2.0
Open Source Digital Holographic Library
asm_reconstruction.m
Go to the documentation of this file.
2 fclose('all');
3 
4 % unit
5 mm = 1e-3;
6 um = mm*mm;
7 nm = um*mm;
8 
9 % inline command
10 %asm_kernel = @(f, wvl, x, y, res, pp) exp(-2j*pi*f .* sqrt( wvl^-2 - ((x/pp - 0.5)./pp/res).^2 - ((y/pp - 0.5)./pp/res).^2)); % angular spectrum method kernel
11 norm2int = @(img) uint8(255.*img./max(max(img)));
12 
13 % parameters
14 h = 2160; v = 3840;
15 wvl = 525 * nm; % green
16 pp = 3.6*um; % pixel pitch
17 res = v/2;
19 
20 % input file name
21 
22 fim_py = 'File name_IM.bmp';
23 fre_py = 'File name_RE.bmp';
24 
25 %% Convert to complex image
26 % phase part
27 im_py = imread(fim_py);
28 im_py = double(im_py) ./ 255;
29 im_py = im_py(:, (v-h)/2+1:(v+h)/2, 2); % crop
30 phase = (im_py - 0.5) .* (2*pi);
31 
32 % amplitude part
33 re_py = imread(fre_py);
34 re_py = double(re_py) ./ 255;
35 re_py = re_py(:,(v-h)/2+1:(v+h)/2, 2);
36 
37 % adapt ASM
38 r = (-pp*h/2 + pp/2):pp:(pp*h/2 - pp/2);
39 c = r;
40 [C, R] = meshgrid(c, r);
41 
42 % Complex image
43 %ch = real + 1j*imag;
44 ch = re_py .* exp(1j.*phase);
45 A = fftshift(fft2(fftshift(ch)));
46 
47 p = asm_kernel(zz, wvl, C, R, h, pp);
48 %% Reconstruction part
49 
51 for zz = (400:10:980)*mm
52 %for zz = ReconstLength * mm
53  p = asm_kernel(zz, wvl, C, R, h, pp);
54  Az1 = A .* p;
55  EI = fftshift(ifft2(fftshift(Az1)));
56  I_rec = EI .* conj(EI);
57  I_rec = I_rec / max(max(I_rec)); %normalize term
58  I_rec = 255 .* I_rec;
59  I_rec = uint8(I_rec);
60  %imwrite(I_rec, sprintf('OPH_point_3_%.2fmm.jpg', zz/mm+20));
61  fig = imagesc(I_rec);
62  title(sprintf('ASM 3 point Reconst %.2f mm', zz/mm));
63  %saveas(fig, sprintf('ASM 3 point Reconst %.2f mm.jpg', zz/mm));
64  pause(0.2);
65 end
saveas(fig, sprintf('ASM 3 point Reconst %.2f mm.jpg', zz/mm))
amplitude part re_py
Convert to complex image phase part im_py
ReconstLength
green pp
command asm_kernel
adapt ASM r
name
Definition: setup.py:14
for zz
crop phase
void normalize(const Complex< T > *src, Complex< T > *dst, const int &size)
Normalize all elements of Complex<T>* src from 0 to 1.
Definition: function.h:176
pause(0.2)
title(sprintf('ASM 3 point Reconst %.2f mm', zz/mm))
pixel pitch res
Complex image ch
angular spectrum method kernel norm2int
fclose('all')
__managed__ float amplitude
Definition: ophPAS_GPU.cpp:28
parameters h
input file name fim_py
imwrite(I_rec, sprintf('OPH_point_3_%.2fmm.jpg', zz/mm+20))
Reconstruction part figure
unit mm
auto end
Definition: ImgControl.cpp:241
vec2 unit(const vec2 &a)
Definition: vec.h:426