[XviD-devel] PSNR question/bug

Christoph Lampert xvid-devel@xvid.org
Sat, 25 Jan 2003 15:50:58 +0100 (CET)


On Sat, 25 Jan 2003, Marco "elcabesa" Belli wrote:

> looking inside image.c i found psnr fouction, after calc of sum of  (diff)^2  
> you make  psnr_y=255*255/result
> andthen SNR = 10 log10(psnr_y)
> 
> is this right??
> 
> isn't better do
> 
> psnr_y =sum (diff)^2
> s= sum (original pixel) ^2
> 
> snr= s/psnr;
> SNR =10 log10(snr);
 ^^^^^^^^^^
That's indeed "SNR". 

PSNR (if you translate it as "Peak Signal-to-Noise-Ratio", not "Picture
Signal-to-Noise-Ratio") is with 255, because that's the maximal=peak 
value. 

SNR might fail misably, because an error of 64 in a medium grey area (128) 
would get the same error value as an error of 1 in an almost black area(2). 

It's the usual difference, whether you want to consider "absolute" error,
or "relative error".

gruel