資源簡介
這是經典的G-S算法matlab程序源代碼
代碼片段和文件信息
%%%GS算法
close?all;
clear?all;
clc
Image=double(imread(‘lena.jpg‘));
PSIZE=size(Image);
P=size(PSIZE);
global?Gimage;
if?(P(2)==2)
????Gimage=Image;
else
????Gimage=round((Image(::1)+Image(::2)+Image(::3))/3);
end
figureimshow(Gimage[]);
%%?initialization
Phase0=rand(PSIZE(1)PSIZE(2))*255;
G0=Gimage/255;
RMS=255;
best_phase=zeros(PSIZE(1)PSIZE(2));
%%?IFT??FT
for?k=1:50
????h0=ifft2(G0.*exp(i*Phase0));
????H0=angle(h0);
????g0=fft2(exp(i*H0));
????Phase0=angle(g0);
end
%%?best?phase
RImage=round(255*abs(g0)/max(max(abs(g0))));
Error=sqrt(sum(sum((RImage-Gimage).^2))/(PSIZE(1)*PSIZE(2)));
if(Error ????best_phase=H0;
????RMS=Error;
end
if(RMS<1)?
????break;
end
%%?phase-only?Hologram
Phase_Hologram=best_phase;
g=fft2(exp(i*Phase_Hologram));
RImage=round(255*abs(g/max(max(abs(g)))));
figureimshow(RImage[])
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????888??2020-11-29?21:59??gs.m
- 上一篇:21__430_436
- 下一篇:發動機懸置系統解耦率、固有頻率以及參數優化
評論
共有 條評論