gaussian_blur: Gaussian Blur for Volumetric Images

View source: R/spat_filter.R

gaussian_blurR Documentation

Gaussian Blur for Volumetric Images

Description

This function applies an isotropic discrete Gaussian kernel to smooth a volumetric image (3D brain MRI data). The blurring is performed within a specified image mask, with customizable kernel parameters.

Usage

gaussian_blur(vol, mask, sigma = 2, window = 1)

Arguments

vol

A NeuroVol object representing the image volume to be smoothed.

mask

An optional LogicalNeuroVol object representing the image mask. This mask defines the region where the blurring is applied. If not provided, the entire volume is processed.

sigma

A numeric value specifying the standard deviation of the Gaussian kernel. Default is 2.

window

An integer specifying the kernel size. It represents the number of voxels to include on each side of the center voxel. For example, window=1 results in a 3x3x3 kernel. Default is 1.

Details

The function uses a C++ implementation for efficient Gaussian blurring. The blurring is applied only to voxels within the specified mask (or the entire volume if no mask is provided). The kernel size is determined by the 'window' parameter, and its shape by the 'sigma' parameter.

Value

A NeuroVol object representing the smoothed image.

References

Gaussian blur: https://en.wikipedia.org/wiki/Gaussian_blur

See Also

NeuroVol-class, LogicalNeuroVol-class, bilateral_filter

Examples

# Load a sample brain mask
brain_mask <- read_vol(system.file("extdata", "global_mask.nii", package = "neuroim2"))

# Apply Gaussian blurring to the brain volume
blurred_vol <- gaussian_blur(brain_mask, brain_mask, sigma = 2, window = 1)

# View a slice of the original and blurred volumes
image(brain_mask[,,50])
image(blurred_vol[,,50])


bbuchsbaum/neuroim2 documentation built on Jan. 2, 2025, 3:38 p.m.