pytorch-msssim icon indicating copy to clipboard operation
pytorch-msssim copied to clipboard

Conversion of Image's Colorspace?

Open akashsara opened this issue 4 years ago • 3 comments

Hi, I came across this while looking for a PyTorch implementation of SSIM. On the Tensorflow page for SSIM it's mentioned that "Note: The true SSIM is only defined on grayscale. This function does not perform any colorspace transform. (If the input is already YUV, then it will compute YUV SSIM average.)"

I was wondering if there are any conversions (either to YUV or to grayscale) that I would have to do to use this. My images are all RGB images.

akashsara avatar Mar 26 '21 14:03 akashsara

Hi @akashsara , the repo is consistent with tensorflow's ssim. So, it does not requires any conversions if RGB ssim is what you want.

VainF avatar Mar 26 '21 15:03 VainF

BTW, the benckmark in readme was based on RGB ssim/ms-ssim.

VainF avatar Mar 26 '21 15:03 VainF

Hi @VainF, thank you for the response! Please correct me if I'm mistaken but my understanding of SSIM is that we should calculate it based on luminance. In the case of a YUV image we consider only the Y (luminance) channel and in the case of a grayscale image, we only have luminance to work with. If you are calculating SSIM separately for each channel and then taking the mean, then I think the results are slightly off since converting RGB to luminance follows a different formula (Ref: https://en.wikipedia.org/wiki/Relative_luminance)

akashsara avatar Mar 26 '21 21:03 akashsara