24小时热门版块排行榜    

CyRhmU.jpeg
查看: 1407  |  回复: 3

草_小草

铜虫 (小有名气)

[求助] 大神们,求帮我看下我这个数字菲涅尔全息图的代码有什么事问题已有1人参与

我这个主要思路是,用点云算法,myfresnel函数做菲涅尔变化。参考光为平面波,源图片的各个点模拟成点光源。算出来的结果不太对。原图片和结果图片在附件里
大家帮我看看,如果觉得太费眼,给我指点一些用matlab编写全息的书或者论文资料,也感激不尽。信息光学的书我看过了,不过那上面大多是大段原理公式,想找些有实例的书和资料。谢谢
% -------------------------------------------------------------------------
% 功能:读入物光光波振幅分布
[fname,pname] = uigetfile('*.*','读入物光光波振幅分布图象');

if pname   
    name = strcat(pname,fname);
    Picture =im2bw( imread(name));
    figure,imshow(Picture);title('物光光波振幅分布图像');
    picture = Picture(:,;
    O = picture;  
end
clear fname pname name picture Picture;
% 物光光波传播至全息面上的复振幅分布 (菲涅耳衍射)
wl = 632.8e-9;          % 单色光波长(m)
z = 0.5;                     % 全息记录距离(m)
k = 2*pi/wl;                %%波数
detaO = 2.65e-4;           % 物光波场像素间隔(m)
detaH = 1.325e-4;  % 衍射场光波像素间隔
y=repmat((512:-1:1)',1,512)-256.5;
R=10*exp(j*k*(z*cos(pi*10/180)+y*detaH*sin(pi*10/180)));%%平面参考光复振幅
tic;
uo=myfresnel(O,detaO,detaH,z,wl);% 物光光波传播至全息面上的复振幅分布(菲涅耳衍射)
toc
u=uo+R;          %%在全息图上,物光波和参考光的复振幅相加
I=abs(u).^2;
figure,imshow(I,[]);
% -------------------------------------------------------------------------
function [ U ] = myfresnel(Object,DETA_O,DETA_H,Z,WL )
%%菲涅尔全息
%坐标轴和矩阵索引的转换:U(256.5-y,x+256.5)等于求xy坐标系中(n-256.5,256.5-m)

k = 2*pi/WL;
U=zeros(512,512);
Uo=0;
for x=-255.5:255.5
    for y=-255.5:255.5
        for x0=-127.5:127.5
            for y0=-127.5:127.5
        r=((DETA_H*x-DETA_O*x0)^2+(DETA_H*y-DETA_O*y0)^2+Z^2)^(1/2);
        Uo=Uo+(Object(128.5-y0,128.5+x0)/r)*exp(j*k*r);
            end
        end
U(256.5-y,x+256.5)=Uo;
    end
end大神们,求帮我看下我这个数字菲涅尔全息图的代码有什么事问题
ABCDEF.jpg
回复此楼

» 本帖附件资源列表

  • 欢迎监督和反馈:小木虫仅提供交流平台,不对该内容负责。
    本内容由用户自主发布,如果其内容涉及到知识产权问题,其责任在于用户本人,如对版权有异议,请联系邮箱:xiaomuchong@tal.com
  • 附件 1 : 结果.fig
  • 2014-05-22 10:15:50, 1.61 M

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

smy1982

木虫 (正式写手)

myfresnel
是个啥函数?
如果你曾歌颂黎明,那么也请你拥抱黑夜。
2楼2014-05-23 10:16:37
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

smy1982

木虫 (正式写手)

【答案】应助回帖

感谢参与,应助指数 +1
clear
clc
Obj=imread('Obj.bmp');
Obj=double(Obj);
[M,N]=size(Obj);   % M,N are the pixel number of the object.
Lamda=0.6328; % um, Wavelength of the input light
DDist=150.0e+3; % um, Diffraction distance to the output plane
% M=512; N=512; % Number of the sample array
dx=10.0; dy=10.0; % um, Sampling space
figure(1);
colormap(gray);
imshow(Obj);%物体

    % Set coordinate of the sample array
[x,y]=meshgrid(-M*dx/2:dxM-1)*dx/2,-N*dy/2:dyN-1)*dy/2);

SphFunct=exp(i*pi*(x.^2+y.^2)/(Lamda*DDist)); % The spherical wave function
    % Simulate the Fresnel diffraction
Obj_F=fftshift(fft2(fftshift(Obj))); %Fourier transform of the slit function.
SphFunct_F=fftshift(fft2(fftshift(SphFunct))); %Fourier transform of the spherical function.
FrDiffract=fftshift(ifft2(fftshift(Obj_F.*SphFunct_F))); % Inverse Fourier transform
figure(2);
FrDiffract_I=abs(FrDiffract).^2;
FrDiffract_I=FrDiffract_I/max(max(FrDiffract_I));
imshow(FrDiffract_I,[0 0.5]);%物光波
    % Display the diffraction pattern
a=40*pi/180;b=90*pi/180;
R=1000*exp(i*2*pi/Lamda*DDist*sqrt(1-cos(a).^2-cos(b).^2)).*exp(i*2*pi/Lamda*(x*cos(a)+y*cos(b)));%%平面参考光复振幅
Hol=abs(R+FrDiffract).^2;   
% FrDiffract_I=FrDiffract.*conj(FrDiffract); % Intensity distribution
Hol=Hol./max(max(Hol));
figure(3);
imshow(Hol,[0 0.5]); %全息图
%%
大神们,求帮我看下我这个数字菲涅尔全息图的代码有什么事问题-1
全息图.jpg


大神们,求帮我看下我这个数字菲涅尔全息图的代码有什么事问题-2
物体.jpg


大神们,求帮我看下我这个数字菲涅尔全息图的代码有什么事问题-3
物体150毫米的衍射图像.jpg

如果你曾歌颂黎明,那么也请你拥抱黑夜。
3楼2014-05-23 11:14:13
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

smy1982

木虫 (正式写手)

引用回帖:
3楼: Originally posted by smy1982 at 2014-05-23 11:14:13
clear
clc
Obj=imread('Obj.bmp');
Obj=double(Obj);
=size(Obj);   % M,N are the pixel number of the object.
Lamda=0.6328; % um, Wavelength of the input light
DDist=150.0e+3; % um, Diffraction dis ...

clear
clc
Obj=imread('Obj.jpg');
Obj=double(Obj(:,:,1));
[M,N]=size(Obj);   % M,N are the pixel number of the object.
Lamda=0.6328; % um, Wavelength of the input light
DDist=100.0e+3; % um, Diffraction distance to the output plane
% M=512; N=512; % Number of the sample array
dx=10.0; dy=10.0; % um, Sampling space
figure(1);
colormap(gray);
imshow(Obj);%物体

    % Set coordinate of the sample array
[x,y]=meshgrid(-M*dx/2:dxM-1)*dx/2,-N*dy/2:dyN-1)*dy/2);

SphFunct=exp(i*pi*(x.^2+y.^2)/(Lamda*DDist)); % The spherical wave function
    % Simulate the Fresnel diffraction
Obj_F=fftshift(fft2(fftshift(Obj))); %Fourier transform of the slit function.
SphFunct_F=fftshift(fft2(fftshift(SphFunct))); %Fourier transform of the spherical function.
FrDiffract=fftshift(ifft2(fftshift(Obj_F.*SphFunct_F))); % Inverse Fourier transform
figure(2);
FrDiffract_I=abs(FrDiffract).^2;
FrDiffract_I=FrDiffract_I/max(max(FrDiffract_I));
imshow(FrDiffract_I,[0 0.5]);%物光波
    % Display the diffraction pattern
a=40*pi/180;b=90*pi/180;
R=100000*exp(i*2*pi/Lamda*DDist*sqrt(1-cos(a).^2-cos(b).^2)).*exp(i*2*pi/Lamda*(x*cos(a)+y*cos(b)));%%平面参考光复振幅
Hol=abs(R+FrDiffract).^2;   
% FrDiffract_I=FrDiffract.*conj(FrDiffract); % Intensity distribution
Hol=Hol./max(max(Hol));
figure(3);
imshow(Hol,[0 0.5]); %全息图
%%%

你的物体最好保存为灰度的图像》
大神们,求帮我看下我这个数字菲涅尔全息图的代码有什么事问题-4
obj.jpg


大神们,求帮我看下我这个数字菲涅尔全息图的代码有什么事问题-5
全息图1.jpg

如果你曾歌颂黎明,那么也请你拥抱黑夜。
4楼2014-05-23 11:25:39
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 草_小草 的主题更新
信息提示
请填处理意见