?? snr.m
字號(hào):
%SNR.m
function S=SNR(I,J)
% SNR(I,J) returns the signal to noise ratio between I and J (dB).
% I is the original image and J is a modified version of I.
% The SNR value is useful to calculate the distortions on an image.
if (size(I)~=size(J))
error('Las imagenes deben tener el mismo tama駉')
end
if (isrgb(I))
aux=RGBtoYIQ(I);
A=double(aux(:,:,1));
size(A);
aux=RGBtoYIQ(J);
B=double(aux(:,:,1));
else
A=double(I);
B=double(J);
end
[m n] = size(A);
sumaI=0;
sumaDif=0;
for u=1:m
for v=1:n
sumaI = sumaI + A(u,v)^2;
sumaDif = sumaDif + (A(u,v)-B(u,v))^2;
end
end
if (sumaDif==0)
sumaDif=1;
end
S=sumaI/sumaDif;
S=10*log10(S);
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -