作者在 2008-06-05 09:48:58 发布以下内容
Matlab中计算信噪比方式:
%===========================Happy===================================%
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
%===================================================================%
自:http://www.chinavib.com/forum/viewthread.php?tid=31086&extra=page%3D1%26amp%3Bfilter%3Ddigest
%===========================Happy===================================%
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
%===================================================================%
自:http://www.chinavib.com/forum/viewthread.php?tid=31086&extra=page%3D1%26amp%3Bfilter%3Ddigest