|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
我想选取滤波效果最好的参数,但不知道该怎么选取好,
所以想把滤波后的图象计算完信噪比,然后根据信噪比和参数,画出变化曲线,再选择
但下面的程序有错误,想请教一下大家怎么改才好:'( 先谢谢了
I=imread('1134.JPG');%原图象
R=imread('1133.JPG');%噪声图象
r=R(:,:,1);
g=R(:,:,2);
b=R(:,:,3);
for i=3;i=i+2;
while i<=99
r1=Medfilt2(r,[i i]);
g1=Medfilt2(g,[i i]);
b1=Medfilt2(b,[i i]);
In=cat(3,r1,g1,b1);
R1=SNR(I,In);
end
end
s=(99-3)/2;
l1=length(s);
stem(l1, abs(R1));
SNR的计算是按eight发的精华帖改的
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((In-mean(mean(In))).^2));%noise power
snr=10*log10(Ps/(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((In(:,:,i)-mean(mean(In(:,:,i)))).^2));%noise power
snr=snr+10*log10(Ps/(Ps-Pn));
end
snr=snr/3;
end
先谢谢大家了:loveliness:
[ 本帖最后由 eight 于 2007-4-23 19:09 编辑 ] |
|