---
title: Spatial Correlation Coefficient (SCC)
description: Compute Spatial Correlation Coefficient (SCC).
canonical: >-
  https://lightning.ai/docs/torchmetrics/stable/image/spatial_correlation_coefficient
---
# Spatial Correlation Coefficient (SCC) {#spatial-correlation-coefficient-scc}

## Module Interface {#module-interface}

### `class torchmetrics.image.SpatialCorrelationCoefficient(high_pass_filter=None, window_size=8, **kwargs)` {#torchmetrics.image.SpatialCorrelationCoefficient}

[\[source\]](https://github.com/Lightning-AI/torchmetrics/blob/v1.9.0/src/torchmetrics/image/scc.py#L24-L83)

Compute Spatial Correlation Coefficient ([SCC](https://www.ingentaconnect.com/content/tandf/tres/1998/00000019/00000004/art00013)).

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

*   `preds` ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")): Predictions from model of shape `(N,C,H,W)` or `(N,H,W)`.
    
*   `target` ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")): 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`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")): 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`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")) – Local window size integer. default: 8.
    
*   **kwargs** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any "(in Python v3.15)")) – Additional keyword arguments, see [Advanced metric settings](/docs/torchmetrics/1.9.0/user-guide/overview.md#metric-kwargs) for more info.
    

Example

```python
>>> 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 {#functional-interface}

### `torchmetrics.functional.image.spatial_correlation_coefficient(preds, target, hp_filter=None, window_size=8, reduction='mean')` {#torchmetrics.functional.image.spatial_correlation_coefficient}

[\[source\]](https://github.com/Lightning-AI/torchmetrics/blob/v1.9.0/src/torchmetrics/functional/image/scc.py#L167-L220)

Compute Spatial Correlation Coefficient ([SCC](https://www.ingentaconnect.com/content/tandf/tres/1998/00000019/00000004/art00013)).

Parameters:

*   **preds** ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")) – predicted images of shape `(N,C,H,W)` or `(N,H,W)`.
    
*   **target** ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")) – ground truth images of shape `(N,C,H,W)` or `(N,H,W)`.
    
*   **hp\_filter** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")\]) – High-pass filter tensor. default: tensor(\[\[-1,-1,-1\],\[-1,8,-1\],\[-1,-1,-1\]\])
    
*   **window\_size** ([`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")) – Local window size integer. default: 8,
    
*   **reduction** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal "(in Python v3.15)")\[`'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`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")

Returns:

Tensor with scc score

Example

```python
>>> 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])
```

---

**Navigation**

- Parent: [Image](/docs/torchmetrics/1.9.0/image.md)
