Files
slm/hamamatsu.m
wxchen ba13a3f053 Initial commit
new file:   Copy_of_Exz_with_hamamatsu.m
	new file:   Exz_mod.m
	new file:   Exz_with_hamamatsu.m
	new file:   GS.m
	new file:   MRAF.m
	new file:   MRAF_8bit.bmp
	new file:   PSF of spherical aberration/Exz.m
	new file:   PSF of spherical aberration/Thumbs.db
	new file:   PSF of spherical aberration/josaa-12-10-2136.pdf
	new file:   PSF of spherical aberration/josaa-12-2-325.pdf
	new file:   PSF of spherical aberration/main.m
	new file:   "PSF of spherical aberration/\351\207\215\350\246\201psf\346\226\207\347\214\256.pdf"
	new file:   Spherical_aberration_SiminCao.m
	new file:   gen_m.m
	new file:   gen_rectangle.m
	new file:   hamamatsu.m
	new file:   m.tif
	new file:   m2.tif
	new file:   photo/50-30.BMP
	new file:   photo/8bit_50-30.BMP
	new file:   photo/8bit_ellipse.BMP
	new file:   photo/convert_8bit.exe
	new file:   photo/ellipse.BMP
	new file:   rect_MRAF_SiminCao.m
	new file:   rectangle.tif
	new file:   size/.vscode/settings.json
	new file:   size/black_c_20THSize_4f_1.064lamda.bmp
	new file:   size/black_c_30THSize_4f_61.064lamda.bmp
	new file:   size/black_output.bmp
	new file:   size/black_rect_30THSize_4f_1.064lamda.bmp
	new file:   size/black_rect_30THSize_4f_6_1.064lamda.bmp
	new file:   size/c_20THSize_4f_1.064lamda.bmp
	new file:   size/c_20THSize_4f_1.064lamda_resize.bmp
	new file:   size/c_30THSize_4f_61.064lamda.bmp
	new file:   size/c_30THSize_4f_61.064lamda_resize.bmp
	new file:   size/noisy_output.bmp
	new file:   size/output.bmp
	new file:   size/rect_30THSize_4f_1.064lamda.bmp
	new file:   size/rect_30THSize_4f_1.064lamda_resize.bmp
	new file:   size/rect_30THSize_4f_6_1.064lamda.bmp
	new file:   size/rect_30THSize_4f_6_1.064lamda_resize.bmp
	new file:   size/resize_4.7z
	new file:   size/resize_black.7z
	new file:   size/size copy.py
	new file:   size/size.py
	new file:   size/wave.7z
	new file:   sp.m
	new file:   to8bit.m
	new file:   trans_8bit.zip
	new file:   wavef/A.bmp
	new file:   wavef/B_linear.bmp
	new file:   wavef/PHA SID230828-2003.csv
	new file:   wavef/PHA_bilinear_1280_1024.csv
	new file:   wavef/PHA_bilinear_reversal.csv
	new file:   wavef/PHA_output_1280_1024.csv
	new file:   wavef/Untitled-1.py
	new file:   wavef/filled.bmp
	new file:   wavef/from PIL import Image.py
	new file:   wavef/matrix_filled.csv
	new file:   wavef/output.bmp
	new file:   wavef/output.csv
	new file:   wavef/output2.bmp
	new file:   wavef/pha_wavef copy.py
	new file:   wavef/pha_wavef.py
	new file:   wavef/pha_wavef_step.py
	new file:   wavef/wavef.zip
	new file:   wavef/xy_values.csv
	new file:   "wavef/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/matrix.csv"
	new file:   "wavef/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/matrix_filled.csv"
2023-08-29 23:06:40 +08:00

79 lines
2.3 KiB
Matlab
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

clc
clear
lambda=1.064;
NA=0.55;
alpha=asin(NA);
f=4e3;
n1=1;
n2=2.585;
d_p=590;
d=204;
thetax=linspace(0,alpha,100);
rho=sin(thetax)/sin(alpha);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%设定参数
for i=1:length(thetax)
theta=thetax(i);
syms theta1
A=d_p*n1*sin(theta1)./sqrt(n2^2-n1^2*sin(theta1).^2)-d*tan(theta1);
eq=theta1+asin(cos(theta1)/f.*A)-theta==0;
theta1_ans(i)=double(vpasolve(eq,theta1));
end
%%%%%%%%%%%解方程计算theta1和Theta关系
%
% AA=d_p*n1*sin(theta1_ans)./sqrt(n2^2-n1^2*sin(theta1_ans).^2)-d*tan(theta1_ans);
% deta=theta1_ans+asin(cos(theta1_ans)/f.*AA)-thetax;
% plot(thetax,deta)
% %%%%%%%%%%%%%%%%%%%%%%%%%%检验方程的解
theta2=asin(n1*sin(theta1_ans)/n2);
phi_sita=n1*(f*cos(thetax)-d)./cos(theta1_ans)+n2*d_p./cos(theta2);
phi_0=n1*(f-d)+n2*d_p;
optical_dif=phi_sita-phi_0; %光程差
phi_dif=-2*pi*optical_dif/lambda; %相位差,需要补偿的相位差取相反数
phi_dif=phi_dif-min(phi_dif);
phi_dif_mod=mod(phi_dif,2*pi);
plot(rho,phi_dif,rho,phi_dif_mod)
p=polyfit(rho,phi_dif,8);
%
% rho0=linspace(0,1,100);
% phi_dif0=polyval(p,rho0);
% plot(rho,phi_dif,'-',rho0,phi_dif0,'--')
% % % %%%%%%%%%%%%%%%对rho--phi_dif关系用5阶多项式拟合并检验拟合效果
% % %
pixelx=1280;
pixely=1024;
F=1.2;
pixel=F*pixely;
%%%%%%%%%%%%%%%%%%%%%%%设置相位图像素数目设置调制区域线性占比F(填充因子)
[x,y]=meshgrid(1:pixelx,1:pixely);
x=x-(pixelx+1)/2;
y=y-(pixely+1)/2;
D=(pixel-1)/2;
Aperture=(x.^2+y.^2)./D.^2;
Aperture(Aperture<=1)=1;
Aperture(Aperture>1)=0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 设置约束孔径Aperture
rho1=(sqrt(x.^2+y.^2)/D).*Aperture;
phi_dif1=polyval(p,rho1); %计算xy坐标对应的相位
Phase=mod(phi_dif1,2*pi).*Aperture;
PhaseHolo=round(Phase*255/(2*pi));
ApertureN=(x.^2+y.^2)./D.^2;
ApertureN(ApertureN<=1)=0;
ApertureN(ApertureN>1)=1;
Noise=round(255*rand(pixely,pixelx)).*ApertureN;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%生成0-255间随机噪声并设置相反约束孔径ApertureN
PhaseHolo=PhaseHolo+Noise;%添加随机噪声后的相位图
figure(1)
imshow(PhaseHolo,[])
figure(2)
plot(linspace(-1,1,pixelx),PhaseHolo(512,:)*2*pi/255,'r')
axis([-1,1,0,2*pi])
filename=['C:\Users\simin\Desktop\球差校正\','F=',num2str(F),'.bmp'];
imwrite(uint8(PhaseHolo),filename); %%%%%%%%%%%%%%%%%%%%%%%%%%导出8位相位图存储