filters
voxel.filters.gaussian_filter(volume, sigma, *components, space=None, truncate=2.0, stride=1, separable=True, padding_mode='replicate') -> vx.Volume
¶
Apply Gaussian smoothing to a volume.
Parameters:
-
sigma(float or Tensor) –Standard deviation(s) of size \((1,)\) or \((3,)\).
-
*components(float, default:()) –Additional components of
sigma, allowing values to be passed as separate positional arguments, e.g.gaussian_filter(vol, 1, 1, 2, 'voxel'). -
space(Space, default:None) –The space of the sigma values, either 'voxel' or 'world'. Can be provided as the last positional argument.
-
truncate(float, default:2.0) –The number of standard deviations to extend the kernel before truncating.
-
stride(int or Tensor, default:1) –Downsampling stride(s) in voxel units.
-
separable(bool, default:True) –Whether to filter with three separable 1D kernels or a single dense 3D kernel. The results are equivalent.
-
padding_mode(str, default:'replicate') –Border padding mode, e.g. 'replicate' or 'zeros'.
Returns:
-
Volume–Smoothed floating-point volume.
voxel.filters.box_filter(volume, size, *components, space=None, stride=1, separable=True, padding_mode='replicate') -> vx.Volume
¶
Apply mean filtering to a volume with a box kernel.
The box extent is rounded to the nearest odd number of voxels along each dimension.
Parameters:
-
size(float or Tensor) –Box extent(s) of size \((1,)\) or \((3,)\).
-
*components(float, default:()) –Additional components of
size, allowing values to be passed as separate positional arguments, e.g.box_filter(vol, 3, 3, 1, 'voxel'). -
space(Space, default:None) –The space of the size values, either 'voxel' or 'world'. Can be provided as the last positional argument.
-
stride(int or Tensor, default:1) –Downsampling stride(s) in voxel units.
-
separable(bool, default:True) –Whether to filter with three separable 1D kernels or a single dense 3D kernel. The results are equivalent.
-
padding_mode(str, default:'replicate') –Border padding mode, e.g. 'replicate' or 'zeros'.
Returns:
-
Volume–Filtered floating-point volume.
voxel.filters.apply_filter(volume, kernel, stride=1, padding_mode='replicate') -> vx.Volume
¶
Apply a filter kernel to a volume with 'same'-style output extents.
Channels are filtered independently. When strided, the grid is downsampled to a spatial size of \(ceil(baseshape / stride)\) and the volume geometry is updated to reflect the new voxel spacing.
Parameters:
-
kernel(Tensor or list) –A single dense 3D kernel of shape \((W, H, D)\) or a sequence of three 1D kernels applied separably per dimension.
-
stride(int or Tensor, default:1) –Downsampling stride(s) in voxel units.
-
padding_mode(str, default:'replicate') –Border padding mode, e.g. 'replicate' or 'zeros'.
Returns:
-
Volume–Filtered floating-point volume.
voxel.filters.gaussian_kernel_1d(sigma, truncate=2.0, device=None, dtype=None) -> torch.Tensor
¶
Generate a 1D Gaussian kernel with a specified standard deviation.
Parameters:
-
sigma(float) –Standard deviation in element (voxel) space.
-
truncate(float, default:2.0) –The number of standard deviations to extend the kernel before truncating.
-
device(device, default:None) –The device on which to create the kernel.
-
dtype(dtype, default:None) –The kernel datatype.
Returns:
-
Tensor–A normalized kernel of length \(2 * int(truncate * sigma + 0.5) + 1\).