pyiqa.archs.psnr_arch

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

pyiqa.archs.psnr_arch.psnr(x, y, test_y_channel=False, data_range=1.0, eps=1e-08, color_space='yiq')[source]

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 \((N, C, H, W)\). :param - y: A target tensor. Shape \((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.

class pyiqa.archs.psnr_arch.PSNR(test_y_channel=False, crop_border=0, **kwargs)[source]

Bases: torch.nn.Module

Parameters:
  • X (-) – distorted image and reference image tensor with shape (B, 3, H, W)

  • Y (torch.Tensor) – distorted image and reference image tensor with shape (B, 3, H, W)

  • test_y_channel (-) – Convert RGB image to YCbCr format and computes PSNR only on luminance channel if True. Compute on all 3 channels otherwise.

  • kwargs (-) – other parameters, including - data_range: maximum numeric value - eps: small constant for numeric stability

Returns:

(B, 1)

Return type:

score (torch.Tensor)

forward(X, Y)[source]