blur: Gaussian blur for arrays of arbitrary dimension

View source: R/blur.R

blurR Documentation

Gaussian blur for arrays of arbitrary dimension

Description

Smooth a numeric array of arbitrary dimension with a separable Gaussian kernel. This function is conceptually similar to gblur from the EBImage package (which is limited to 2D), but works for arrays of any dimension.

Usage

blur(x, sigma, boundary = "replicate")

Arguments

x

A numeric array to be smoothed.

sigma

A non-negative numeric scalar or numeric vector specifying the standard deviation(s) of the Gaussian kernel in pixel units. If a single value is provided, it is used for all dimensions.

boundary

A character string specifying the boundary handling, or a character vector of length equal to the number of dimensions of 'x'. Possible values are '"none"', '"circular"', and '"replicate"'. If a single value is provided, it is used for all dimensions.

Details

The Gaussian kernel is separable, so smoothing is performed via successive 1D convolutions along each dimension.

This function is similar in spirit to gblur from EBImage, but generalises naturally to arrays of arbitrary dimension.

Boundary handling can be controlled via 'boundary':

  • '"none"' uses centered filtering without padding and therefore returns 'NA' values near array boundaries.

  • '"circular"' applies periodic wrap-around boundary conditions.

  • '"replicate"' extends the array by repeating the edge values.

For finite arrays, the Gaussian kernel is truncated as needed so that its length does not exceed the array extent along any dimension.

Value

A numeric array with the same dimensions as 'x', containing the blurred values.


cooltools documentation built on Sept. 11, 2026, 5:06 p.m.