pado.math.calculate_ssim

calculate_ssim(img1, img2, window_size=21, sigma=None, data_range=1.0)[source]

Calculate Structural Similarity Index between multi-channel tensors.

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

  • img2 (torch.Tensor) – Second tensor [B, Channel, H, W]

  • window_size (int) – Size of Gaussian window (odd number)

  • sigma (float, optional) – Standard deviation of Gaussian window. If None, defaults to window_size/6

  • data_range (float) – Dynamic range of images

Returns:

SSIM score (-1 to 1, where 1 indicates identical images)

Return type:

float

Examples

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