clear ;clc;close all; %清除数据
ima=double(imread('a.bmp'));
imb=double(imread('b.bmp')); %读入物体图像
N1=600;N2=800; %设置采样点数
lamda=532e-9; %设置波长
b=10.1/512;
a=3.9/512;
for m=1:N1
for p=1:N2
ck(m,p)=exp(-i2pi*(a*(m-N1/2)+b*(p-N2/2))/(lamda));
end
end
d1=0.25;
d2=0.45;
dx=3.45e-6;
dx1=lamdad1/(N1dx);
dy1=lamdad1/(N2dx);
dx2=lamdad2/(N1dx);
dy2=lamdad2/(N2dx); %计算采样面像元尺寸
rsita=rand(N1,N2)2pi; %随机相位平滑
rph=exp(irsita);
ua=ima.rph;
ub=imb.rph;
fua=fresnela(ua,d1);
fub=fresnelb(ub,d2);
u=fua+fub;
h=conj(ck). u+ck .conj(u);
%菲涅耳全息图
mh=min(min(h));
oh=ones(N1,N2);
moh=mhoh;
nh=h-moh;
maxnh=max(max(nh));
gnh=nh/maxnh;
fnh=uint8(gnh255);
figure(1)
imshow(fnh,[]) %8位全息图生成
imwrite(fnh, ‘hologramab. bmp') %写出图像
ud=fresnellg(double(fnh),d1);
aud=(ud).conj(ud);
figure(2)
imshow(0.1aud)
imwrite(0.1aud,’holidayramabrecon1. bmp')
%全息图像在d1处再现
ud2=fresnel(double(fnh),d2);
aud2=(ud2). conj(ud2);
figure(3)
imshow(0.1aud2)
imwrite(0.1*aud2,’holidayramabrecon2. bmp')
%全息图像在d2处再现