clear all,
%%Reading input bitmap file
I=imread('a.bmp','bmp'); %导入图片
I=I(:,:,1);
figure(1)%displaying input
colormap(gray(255));
image(I)
title('Original image')
axis off
pause
%%Creating OTFosh with SIGMA=z/2k0(Eq.(3.5-1a))
ROWS=256;
COLS=256;
sigma=2.0; %not necessary to scale
%kx,ky are spatial frequencies
ky=-12.8;
for r=1:COLS
kx=-12.8;
for c=1:ROWS
OTFosh(r,c)=exp(-1isigmakxkx-1isigmakyky);
kx=kx+.1;
end
ky=ky+.1;
end
OTFosh(r,c)=exp(-1isigmakxkx-1isigmaky*ky);
max1=max(OTFosh);
max2=max(max1);
scale=1.0/max2;
OTFosh=OTFosh.*scale;
%Recording hologram
%Taking Fourier transform of I
FI=fft2(I);
FI=fitshift(FI);
max1=max(Fl);
max2=max(max1);
scale=1.0/max2;
FI=FI.*scale;
%FH is the recorded hologram in Fourier domain.
FH=FI.OTFosh;
H=ifft2(FH);
max1=max(H);
max2=max(max1);
scale=1.0/max2;
H=H.scale;
figure(1)
colormap(gray(255));
%Displaying the real part becomes sine-FZP hologram
%Eq.(3.5-8a)
image(2.5real(256H));
title('Sine-FZP hologram')
axis off