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

SSIM output range

Open ksmdnl opened this issue 2 years ago • 2 comments

Quick question on the output range. Does the SSIM implementation output number of range [0;1] or [-1;1] instead as described in the original SSIM paper http://www.cns.nyu.edu/pub/lcv/wang03-reprint.pdf ?

ksmdnl avatar Mar 18 '22 12:03 ksmdnl

I have the same question in mind. Can you please clarify this?

beyzacevik avatar May 13 '22 11:05 beyzacevik

@beyzacevik @ksmdnl

There is an additional parameter $L$ involved in the original paper, which defaults to 1 in this implementation.

In fact, this parameter needs to be set separately for different data types. In the implementation provided in skimage (https://scikit-image.org/docs/dev/api/skimage.metrics.html#structural-similarity), it will perform the corresponding conversion according to the data type.

I have implemented a new pytorch version of ssim here, and provided this interface to the user. You can set it manually.

        self.C1 = (K1 * L) ** 2  # equ 7 in ref1
        self.C2 = (K2 * L) ** 2  # equ 7 in ref1

https://github.com/lartpang/MSSIM.pytorch/blob/1584aad5a05e403041fb9c6d27bbb991182c6bfe/ssim.py#L84-L85

lartpang avatar Jun 21 '22 13:06 lartpang