peal.global_utils.generate_ssim_overlay

peal.global_utils.generate_ssim_overlay(x, counterfactual, alpha_factor=1.5)[source]

Highlight structural, rather than pixelwise, change in red.

Uses the 1 - SSIM map of ssim_map(), normalised to its maximum, as both the red channel and the alpha of an overlay on a washed-out greyscale copy of the image. Unlike generate_overlay() this ignores uniform brightness or colour shifts and reacts to changed structure.

Parameters:
  • x (torch.Tensor) – A single image each, shape (C, H, W).

  • counterfactual (torch.Tensor) – A single image each, shape (C, H, W).

  • alpha_factor (float, optional) – Multiplier on the alpha mask.

Returns:

RGB overlay of shape (3, H, W).

Return type:

torch.Tensor