mr2.utils.filters.gaussian_filter

mr2.utils.filters.gaussian_filter(x: Tensor, sigmas: float | Sequence[float] | Tensor, dim: int | Sequence[int] | None = None, truncate: int = 3, pad_mode: Literal['constant', 'reflect', 'replicate', 'circular'] = 'constant', pad_value: float = 0.0) → Tensor[source]

Smooth a tensor with a separable N-dimensional Gaussian filter.

Each axis uses samples of \(\exp(-t^2/(2\sigma^2))\), truncated at ceil(truncate * sigma) pixels on either side and normalized to sum to one.

Parameters:
  • x (Tensor) – Tensor to filter

  • sigmas (float | Sequence[float] | Tensor) – Standard deviation for Gaussian kernel. If iterable, must have length equal to the number of axes.

  • dim (int | Sequence[int] | None, default: None) – Axis or axes to filter over. If None, filters over all axes.

  • truncate (int, default: 3) – Truncate the filter at this many standard deviations.

  • pad_mode (Literal['constant', 'reflect', 'replicate', 'circular'], default: 'constant') – Padding mode

  • pad_value (float, default: 0.0) – Padding value for pad_mode = constant

Returns:

Smoothed tensor with the same shape as the input.