Spatial Correlation Coefficient (SCC)

Module Interface

class torchmetrics.image.SpatialCorrelationCoefficient(high_pass_filter=None, window_size=8, **kwargs)[source]

Compute Spatial Correlation Coefficient (SCC).

As input to forward and update the metric accepts the following input

  • preds (Tensor): Predictions from model of shape (N,C,H,W) or (N,H,W).

  • target (Tensor): Ground truth values of shape (N,C,H,W) or (N,H,W).

As output of forward and compute the metric returns the following output

  • scc (Tensor): Tensor with scc score

Parameters:
  • hp_filter – High-pass filter tensor. default: tensor([[-1,-1,-1],[-1,8,-1],[-1,-1,-1]]).

  • window_size (int) – Local window size integer. default: 8.

  • kwargs (Any) – Additional keyword arguments, see Advanced metric settings for more info.

Example

>>> import torch
>>> _ = torch.manual_seed(42)
>>> from torchmetrics.image import SpatialCorrelationCoefficient as SCC
>>> preds = torch.randn([32, 3, 64, 64])
>>> target = torch.randn([32, 3, 64, 64])
>>> scc = SCC()
>>> scc(preds, target)
tensor(0.0023)

Functional Interface

torchmetrics.functional.image.spatial_correlation_coefficient(preds, target, hp_filter=None, window_size=8, reduction='mean')[source]

Compute Spatial Correlation Coefficient (SCC).

Parameters:
  • preds (Tensor) – predicted images of shape (N,C,H,W) or (N,H,W).

  • target (Tensor) – ground truth images of shape (N,C,H,W) or (N,H,W).

  • hp_filter (Optional[Tensor]) – High-pass filter tensor. default: tensor([[-1,-1,-1],[-1,8,-1],[-1,-1,-1]])

  • window_size (int) – Local window size integer. default: 8,

  • reduction (Optional[Literal['mean', 'none', None]]) – Reduction method for output tensor. If None or "none", returns a tensor with the per sample results. default: "mean".

Return type:

Tensor

Returns:

Tensor with scc score

Example

>>> import torch
>>> from torchmetrics.functional.image import spatial_correlation_coefficient as scc
>>> _ = torch.manual_seed(42)
>>> x = torch.randn(5, 3, 16, 16)
>>> scc(x, x)
tensor(1.)
>>> x = torch.randn(5, 16, 16)
>>> scc(x, x)
tensor(1.)
>>> x = torch.randn(5, 3, 16, 16)
>>> y = torch.randn(5, 3, 16, 16)
>>> scc(x, y, reduction="none")
tensor([0.0223, 0.0256, 0.0616, 0.0159, 0.0170])