priors.nlmeans

Contents

priors.nlmeans#

bartorch.priors.nlmeans()#

Non-local means filter along axes, BART’s nlmeans.

Each voxel becomes \(\sum_j w_{ij} y_j / \sum_j w_{ij}\) over the voxels \(j\) within patch_distance of it along every axis of axes, with

\[w_{ij} = \exp\Bigl( -\frac{\sum_o g_o |y_{i+o} - y_{j+o}|^2}{2 h^2 \|g\|_2} \Bigr),\]

where \(o\) runs over a patch of patch_length per axis and \(g\) is a Gaussian of standard deviation a over it. The image is reflected at its edges.

Parameters:
  • input (torch.Tensor) – Image \(y\).

  • axes (int or tuple of int) – Axes the patches and the search span.

  • patch_length (int, default=None) – Odd patch length per axis; BART’s 5 when omitted.

  • patch_distance (int, default=None) – Search radius per axis; BART’s 5 when omitted. Zero returns input.

  • h (float, default=None) – Filter strength, in the units of input’s values; BART’s 0.04 when omitted. A large h makes the filter a box mean.

  • a (float, default=None) – Standard deviation of \(g\), in voxels; (patch_length - 1) / 4 when omitted.

Returns:

Filtered image, of input’s shape.

Return type:

torch.Tensor

Raises:

ValueError – An even patch_length.