piq: Compute error for `PSNR` and `SSIM`
Convert RGB image to YCbCr and take luminance should be Y = 0.256789 R + 0.504129 G +0.097906 B, not
https://github.com/photosynthesis-team/piq/blob/e8f6513afa8f9138bcd19c0928763cc18bf7e060/piq/psnr.py#L39
As for SSIM, to make sure the results can be same with Matlab Code, it must use DoubleTensor, and these three lines should change:
https://github.com/photosynthesis-team/piq/blob/e8f6513afa8f9138bcd19c0928763cc18bf7e060/piq/ssim.py#L55
https://github.com/photosynthesis-team/piq/blob/e8f6513afa8f9138bcd19c0928763cc18bf7e060/piq/ssim.py#L56
https://github.com/photosynthesis-team/piq/blob/e8f6513afa8f9138bcd19c0928763cc18bf7e060/piq/functional/filters.py#L35
Please refer to my implement of SSIM and PSNR.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (1 by maintainers)
@leftthomas, Indeed,
RGB2YCrCbuses different fromRGB2YIQ(orrgb2ntsc) weights. However, we are not usingrgb2ycbcrcolour conversion. Our approach uses more commonYIQcolour map.@leftthomas thank you for your feedback regarding PSNR and SSIM performance. PSNR compares grayscale images. In order to get a grayscale image, we use conversion proposed in PIL (docs) and OpenCV (docs). This conversion is identical to Y channel of RGB2YIQ transformation. Sadly, previous comment in code was misleading. It will be fixed to avoid misunderstanding in future.
Following your quote, PSNR implementation proposed in IQA-PyTorch uses RBG2YIQ as a default colour conversion, which matches our approach. Any additional colour conversions other than standard grayscale could be added as preprocessing step to your pipeline.
UPD: In addition, MATLAB version rgb2gray conversion function matches our approach as well.