sanghyun-son / EDSR-PyTorch

PyTorch version of the paper 'Enhanced Deep Residual Networks for Single Image Super-Resolution' (CVPRW 2017)
MIT License
2.42k stars 668 forks source link

PSNR calculation for RGB wrong, always 0.66 dB high #301

Closed slingyropert closed 3 years ago

slingyropert commented 3 years ago

The sum of the grey coefficients on line 172 in utility.py is 219.86.

The normalization value applied on line 173 is 256.

This means the true peak value of the variable diff is (219.86 / 256) * rgb_range, not just rgb_range

The error in produced PSNR is therefore -10 * Log10( 219.86/256 ) = +0.66 dB

This error makes it hard to compare the algorithm with other algorithms applied to common datasets like DIVX.

sanghyun-son commented 3 years ago

Hi @slingyropert,

Grey colors are used only when test your model on some widely-used benchmark datasets (Set5, Set14, B100, and Urban100).

Please note that the PSNR value on grey channel is actually PSNR for luminance intensity, which are ranged in between 16 and 235.

Therefore, line 172 and 173 are intended, and they are not used when you apply the algorithm on the DIV2K dataset.

Thanks, Sanghyun