谢谢,找到了HAPPY教授的。但现了以下错误
??? Input argument 'I' is undefined.
Error in ==> d:\MATLAB6p5\work\SNR.m
On line 8 ==> [row,col,nchannel]=size(I);
我是新手,有很多都还不懂,还请各位大虾指教下。。。
原程序:
function snr=SNR(I,In)
% 计算信号噪声比函数
% by Qulei
% I :original signal
% In:noisy signal(ie. Original signal + noise signal)
% snr=10*log10(sigma2(I2)/sigma2(I2-I1))
[row,col,nchannel]=size(I);
snr=0;
if nchannel==1%gray image
Ps=sum(sum((I-mean(mean(I))).^2));%signal power
Pn=sum(sum((I-In).^2));%noise power
snr=10*log10(Ps/Pn);
elseif nchannel==3%color image
for i=1:3
Ps=sum(sum((I(:,:,i)-mean(mean(I(:,:,i)))).^2));%signal power
Pn=sum(sum((I(:,:,i)-In(:,:,i)).^2));%noise power
snr=snr+10*log10(Ps/Pn);
end
snr=snr/3;
end
[ 本帖最后由 ldr130 于 2007-5-7 13:42 编辑 ] |