||
几种光栅。正弦光栅,矩形光栅,正弦光栅的强度衍射分布。
NO1
%正弦振幅型光栅
clear all;clc
close all
I=zeros(768,1024);
for i=1:768
for j=1:1024
I(i,j)=128+127*cos(i/32*2*pi+pi/4);%频率为1/32
%或者I(i,j)=0.5+0.5*cos(2*pi/32+pi/4)
%if I(i,j)<128
% I(i,j)=0; %二值化处理
%else
% I(i,j)=1;
%end
end
end
I1=mat2gray(I); %实现图像矩阵的归一化操作
% '归一化'是使矩阵的每个元素的值都在0和1之间
imshow(I1,[])
N02.矩形光栅
%矩形光栅
clear all;clc
%close all
I1=zeros(96,1024);
I2=ones(96,1024);%768/4/2=96
I=zeros(192,1024);
I(1:96,:)=I1;
I(97:192,:)=I2;
Iout=repmat(I,4,1);%横向条纹
I01=zeros(768,128);
I02=ones(768,128);%1024/4/2=128
I0=zeros(768,256);
I0(:,1:128)=I01;
I0(:,129:256)=I02;
I0t=repmat(I0,1,4);%纵向
Itot=Iout+I0t;
%Itot=mod(Itot,2);
Itot=im2bw(Itot,1);% 二值化,1为阈值,小于等于1化为0,大于1化为1
%此句为横向,纵向条纹‘黑’‘黑’相加
figure(5)
imshow(Itot)
NO.3
%一维正弦相位光栅的强度衍射分布
%傅里叶光学P110,(3-138)
clear all;clc
close all
lambda=650e-9;%波长m;
f0=8e6;%光栅频率;
z=0.01;%入射距离m;
L=1e-3;%光栅长度m
m=8;%相位变化幅度
N=10;%贝塞尔函数的阶数,取有限的阶数
d=0.4;%观察屏的观察范围m
x=-d:0.002:d;
I0=(L^2/lambda/z).^2;
I1=zeros(2*N+1,length(x));
for q=-N:N
for i=1:length(x)
I1(q+N+1,i)=besselj(q,m/2).*sinc(L/lambda/z*(x(i)-q*f0*lambda*z));
end
end
I2=I0.*sum(I1.^2);
%plot(x,I2)
I3=(I2-min(I2))./(max(I2)-min(I2));
figure;
plot(x,I3);%归一化
I4=zeros(length(x));
for j=1:length(x)
I4(:,j)=I3(j);
end
figure
imshow(I4)
imwrite(I4,'intensity.jpg')
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-11-25 18:45
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社