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

>>> from torch import randn
>>> from torchmetrics.image import SpatialCorrelationCoefficient as SCC
>>> preds = randn([32, 3, 64, 64])
>>> target = 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

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