You are on page 1of 1

close all;

I=imread('lena.png'); % 256_256 pixels, 8bit image


I = imresize(I,[256 256]);
I=double(I); % parameter setup
M=256;
deltax=0.001; % pixel pitch 0.001 cm (10 um)
w=633*10^-8; % wavelength 633 nm
z=25; % 25 cm, propagation distance

%Step 1: simulation of propagation using the ASM


r=1:M;
c=1:M;
[C,R]=meshgrid(c, r);
A0=fftshift(ifft2(fftshift(I)));
deltaf=1/M/deltax;% sampling period in the spectrum domain
%forward propgation
p=exp(-2i*pi*z.*((1/w)^2-((R-M/2- 1).*deltaf).^2-((C-M/2-1).*deltaf).^2).^0.5);
Az=A0.*p;
EO=fftshift(fft2(fftshift(Az)));

%Step 2: interference at the hologram plane


AV=4*(min(min(abs(EO)))+max(max(abs(EO)))); % amplitude of reference light % the
visibility can be controlled by modifying the amplitude
IH=(EO+AV).*conj(EO+AV);
subplot(2,2,1)
imshow(mat2gray(I));
title('Original Image')
axis off
subplot(2,2,2)
imshow(mat2gray(IH));
title('Hologram' )
axis off
SP=abs(fftshift(ifft2(fftshift(IH))));
subplot(2,2,3)
imshow(500.*mat2gray(SP));
title('Hologram spectrum' )
axis off

%Step 3: reconstruction
A1=fftshift(ifft2(fftshift(IH)));
Az1=A1.*conj(p);
EI=fftshift(fft2(fftshift(Az1)));
EI=mat2gray(EI.*conj(EI));
subplot(2,2,4)
imshow(EI);
title('Reconstructed image')
axis off

You might also like