请教:请问为何在求SNR时将xd3改为与其大小一样的矩阵时图像就会发生较大畸变
clearx=0:1:1600;
n=1:length(x);
a=50*exp(-(n-420).^2/144);
d=70*exp(-(n-1200).^2/324);
g=a+d;
h=40*exp(-(n-800).^2/2);
i1=g+h;
r=randn(1,1601);
r=r-mean(r);
r=sqrt(2.56)*r./sqrt(var(r));
ii=i1+r;
y=fft(ii,1600)
pyy=y.*conj(y)
y1=y;y1(20:890)=0
y2=y;y2(30:760)=0
y3=y;y3(40:1040)=0
xd1=real(ifft(y1,1600))
xd2=real(ifft(y2,1600))
xd3=real(ifft(y3,1600))
subplot(411);plot(ii);axis();title('0');grid on;
subplot(412);plot(xd1);axis();title('1');grid on;
subplot(413);plot(xd2);axis();title('2');grid on;
subplot(414);plot(xd3);axis();title('3');grid on;
=size(i1);
snr=0;
if nchannel==1%gray image
Ps=sum(sum((i1-mean(mean(i1))).^2));%signal power
Pn=sum(sum((i1-xd3).^2));%noise power
snr=10*log10(Ps/Pn);
elseif nchannel==3%color image
for i=1:3
Ps=sum(sum((i1(:,:,i)-mean(mean(i1(:,:,i)))).^2));%signal power
Pn=sum(sum((i1(:,:,i)-xd3(:,:,i)).^2));%noise power
snr=snr+10*log10(Ps/Pn);
end
snr=snr/3;
end
disp(snr);
回复
没太明白你的意思.xd3是一向量.
你后面的程序好象有点问题,建议将公式用word先传上来看看.
页:
[1]