MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [MATLAB图像处理] 求助 这个程序运行的时候为什么每次结果不同啊 (https://www.labfans.com/bbs/showthread.php?t=7680)

liyp87 2009-04-14 09:25

求助 这个程序运行的时候为什么每次结果不同啊
 
function snr = SNR(I,In)
I = imread('pout.tif');
In = imnoise(I,'salt & pepper',0.5);


% 计算信号噪声比函数

% 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

liyp87 2009-04-14 09:26

回复: 求助 这个程序运行的时候为什么每次结果不同啊
 
大家帮我看看啊 谢谢啦


所有时间均为北京时间。现在的时间是 11:07

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.