pyiqa.archs.ssim_arch ===================== .. py:module:: pyiqa.archs.ssim_arch .. autoapi-nested-parse:: SSIM, MS-SSIM, CW-SSIM Metric Created by: - https://github.com/dingkeyan93/IQA-optimization/blob/master/IQA_pytorch/SSIM.py - https://github.com/dingkeyan93/IQA-optimization/blob/master/IQA_pytorch/MS_SSIM.py - https://github.com/dingkeyan93/IQA-optimization/blob/master/IQA_pytorch/CW_SSIM.py Modified by: Jiadi Mo (https://github.com/JiadiMo) Refer to: - Official SSIM matlab code from https://www.cns.nyu.edu/~lcv/ssim/; - PIQ from https://github.com/photosynthesis-team/piq; - BasicSR from https://github.com/xinntao/BasicSR/blob/master/basicsr/metrics/psnr_ssim.py; - Official MS-SSIM matlab code from https://ece.uwaterloo.ca/~z70wang/research/iwssim/msssim.zip; - Official CW-SSIM matlab code from https://www.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/43017/versions/1/download/zip; Module Contents --------------- .. py:function:: ssim(X, Y, win=None, get_ssim_map=False, get_cs=False, get_weight=False, downsample=False, data_range=1.0) .. py:class:: SSIM(channels=3, downsample=False, test_y_channel=True, color_space='yiq', crop_border=0.0) Bases: :py:obj:`torch.nn.Module` Args: - channel: number of channel. - downsample: boolean, whether to downsample same as official matlab code. - test_y_channel: boolean, whether to use y channel on ycbcr same as official matlab code. .. py:method:: forward(X, Y) .. py:function:: ms_ssim(X, Y, win=None, data_range=1.0, downsample=False, test_y_channel=True, is_prod=True, color_space='yiq') Compute Multiscale structural similarity for a batch of images. :param x: An input tensor. Shape :math:`(N, C, H, W)`. :param y: A target tensor. Shape :math:`(N, C, H, W)`. :param win: Window setting. :param downsample: Boolean, whether to downsample which mimics official SSIM matlab code. :param test_y_channel: Boolean, whether to use y channel on ycbcr. :param is_prod: Boolean, calculate product or sum between mcs and weight. :returns: Index of similarity between two images. Usually in [0, 1] interval. .. py:class:: MS_SSIM(channels=3, downsample=False, test_y_channel=True, is_prod=True, color_space='yiq') Bases: :py:obj:`torch.nn.Module` Multiscale structure similarity .. rubric:: References Wang, Zhou, Eero P. Simoncelli, and Alan C. Bovik. "Multiscale structural similarity for image quality assessment." In The Thrity-Seventh Asilomar Conference on Signals, Systems & Computers, 2003, vol. 2, pp. 1398-1402. Ieee, 2003. :param channel: Number of channel. :param downsample: Boolean, whether to downsample which mimics official SSIM matlab code. :param test_y_channel: Boolean, whether to use y channel on ycbcr which mimics official matlab code. .. py:method:: forward(X, Y) Computation of MS-SSIM metric. :param x: An input tensor. Shape :math:`(N, C, H, W)`. :param y: A target tensor. Shape :math:`(N, C, H, W)`. :returns: Value of MS-SSIM metric in [0, 1] range. .. py:class:: CW_SSIM(channels=1, level=4, ori=8, guardb=0, K=0, test_y_channel=True, color_space='yiq') Bases: :py:obj:`torch.nn.Module` Complex-Wavelet Structural SIMilarity (CW-SSIM) index. .. rubric:: References M. P. Sampat, Z. Wang, S. Gupta, A. C. Bovik, M. K. Markey. "Complex Wavelet Structural Similarity: A New Image Similarity Index", IEEE Transactions on Image Processing, 18(11), 2385-401, 2009. :param - channel: Number of channel. :param - test_y_channel: Boolean, whether to use y channel on ycbcr. :param - level: The number of levels to used in the complex steerable pyramid decomposition :param - ori: The number of orientations to be used in the complex steerable pyramid decomposition :param - guardb: How much is discarded from the four image boundaries. :param - K: the constant in the CWSSIM index formula (see the above reference) default value: K=0 .. py:method:: conj(x, y) .. py:method:: conv2d_complex(x, win, groups=1) .. py:method:: cw_ssim(x, y, test_y_channel) Compute CW-SSIM for a batch of images. :param x: An input tensor. Shape :math:`(N, C, H, W)`. :param y: A target tensor. Shape :math:`(N, C, H, W)`. :param test_y_channel: Boolean, whether to use y channel on ycbcr. :returns: Index of similarity between two images. Usually in [0, 1] interval. .. py:method:: forward(X, Y) Computation of CW-SSIM metric. :param X: An input tensor. Shape :math:`(N, C, H, W)`. :param Y: A target tensor. Shape :math:`(N, C, H, W)`. :returns: Value of CW-SSIM metric in [0, 1] range.