Image Metrics

psnr(tensor1, tensor2, max_val=2.0)[source]

Calculates Peak signal-to-noise ratio (PSNR) between images.

Parameters
  • tensor1 – tensor containing images, can be either of rank 3 or rank 4

  • tensor2 – tensor with the same shape as tensor1

  • max_val – maximal possible pixel value in images, for 8-bit RGB this would be 255, if images are normalized to [0,1] the maximal value would be 1.0 For images in range [-1, 1], this value should be 2.0.

Returns

Tensor of rank 1 containing the resulting PSNR values.

psnr_on_y(tensor1, tensor2, max_val=2.0)[source]

Calculates Peak signal-to-noise ration (PSNR) between images on Y-channel.

Parameters
  • tensor1 – Tensor of rank 3 or rank 4.

  • tensor2 – Tensor with same shape as tensor1.

  • max_val – Maximal possible pixel value in images, for 8-bit RGB this would be 255, if images are normalized to [0,1] the maximal value would be 1.0. For images in range [-1, 1], this value should be 2.0.

Returns

Tensor of rank 1 containing the resulting PSNR values.

ssim(tensor1, tensor2, max_val=2.0)[source]

Calculates structural similarity (SSIM) between images.

Parameters
  • tensor1 – Tensor containing images, tensor can be either rank 3 or rank 4.

  • tensor2 – Tensor containing images with the same shape as tensor1.

  • max_val – Maximal possible pixel value in images, for 8-bit RGB this would be 255, if images are normalized to [0,1] the maximal value would be 1.0. For images in range [-1, 1], this value should be 2.0.

Returns

Tensor of rank 1 containing the resulting SSIM values.