pyiqa.archs.psnr_arch ===================== .. py:module:: pyiqa.archs.psnr_arch .. autoapi-nested-parse:: Peak signal-to-noise ratio (PSNR) Metric Created by: https://github.com/photosynthesis-team/piq Modified by: Jiadi Mo (https://github.com/JiadiMo) Refer to: Wikipedia from https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio QIQA from https://github.com/francois-rozet/piqa/blob/master/piqa/psnr.py Module Contents --------------- .. py:function:: psnr(x, y, test_y_channel=False, data_range=1.0, eps=1e-08, color_space='yiq') Compute Peak Signal-to-Noise Ratio for a batch of images. Supports both greyscale and color images with RGB channel order. :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: Convert RGB image to YCbCr format and computes PSNR :type - test_y_channel: Boolean :param only on luminance channel if `True`. Compute on all 3 channels otherwise.: :param - data_range: Maximum value range of images (default 1.0). :returns: PSNR Index of similarity between two images. .. py:class:: PSNR(test_y_channel=False, crop_border=0, **kwargs) Bases: :py:obj:`torch.nn.Module` :param - X: distorted image and reference image tensor with shape (B, 3, H, W) :type - X: torch.Tensor :param Y: distorted image and reference image tensor with shape (B, 3, H, W) :type Y: torch.Tensor :param - test_y_channel: Convert RGB image to YCbCr format and computes PSNR only on luminance channel if `True`. Compute on all 3 channels otherwise. :type - test_y_channel: Boolean :param - kwargs: other parameters, including - data_range: maximum numeric value - eps: small constant for numeric stability :returns: (B, 1) :rtype: score (torch.Tensor) .. py:method:: forward(X, Y)