pado.math.calculate_psnr

calculate_psnr(img1, img2, data_range=1.0)[source]

Calculate Peak Signal-to-Noise Ratio between multi-channel tensors.

Parameters:
  • img1 (torch.Tensor) – First tensor [B, Channel, R, C]

  • img2 (torch.Tensor) – Second tensor [B, Channel, R, C]

  • data_range (float, optional) – The data range of the input image (e.g., 1.0 for normalized images, 255 for uint8 images). If None, uses the maximum value from images.

Returns:

PSNR value in dB, infinity if images are identical

Return type:

float

Examples

>>> intensity1 = light1.get_intensity()  # [B, Channel, R, C]
>>> intensity2 = light2.get_intensity()  # [B, Channel, R, C]
>>> psnr = calculate_psnr(intensity1, intensity2)