from
PSNR- Peak Signal to Noise Ratio
by Aviad Dido
compute the Peak Signal to Noise Ratio of two images
|
| psnr(OriginalImage,BlurredImage)
|
function p = psnr(OriginalImage,BlurredImage)
x=OriginalImage;
y=BlurredImage;
%%% psnr - compute the Peak Signal to Noise Ratio of two images, defined by :
%%% PSNR(x,y) = 10*log10( max(max(x),max(y))^2 / |x-y|^2 ).
%%%
%%% p = psnr(OriginalImage,BlurredImage)
%%%
% %% Copyright (c) 2009 Aviad Didovsky
if x== y
error('Images are identical: PSNR has infinite value')
end
x=rgb2ycbcr(x);
y=rgb2ycbcr(y);
x=double(x(:,:,1));
y=double(y(:,:,1));
d = mean( mean( (x(:)-y(:)).^2 ) );
m1 = max( abs(x(:)) );
m2 = max( abs(y(:)) );
m = max(m1,m2)
p = 10*log10( m^2/d );
|
|
Contact us at files@mathworks.com