Skip to content

copper3d / Modules / Utils/segmentation/core/GaussianSmoother / GaussianSmoother

Class: GaussianSmoother

Utils/segmentation/core/GaussianSmoother.GaussianSmoother

Table of contents

Constructors

Methods

Constructors

constructor

new GaussianSmoother()

Methods

convolve1D

Static Private convolve1D(data, width, height, depth, axis, kernel): void

In-place single-axis convolution with zero-padding at boundaries.

Uses a 3-segment approach: left boundary (with bounds check), middle interior (branch-free, ~95% of work), right boundary (with bounds check). This eliminates per-element branching in the hot inner loop.

Parameters

NameTypeDescription
dataFloat32ArrayFlat float buffer (width × height × depth).
widthnumberX dimension.
heightnumberY dimension.
depthnumberZ dimension.
axisnumber0 = X, 1 = Y, 2 = Z.
kernelFloat32Array1D convolution kernel (odd length).

Returns

void

Defined in

src/Utils/segmentation/core/GaussianSmoother.ts:147


gaussianSmooth3D

Static gaussianSmooth3D(volume, channel, sigma?, spacing?): void

Smooth a single label channel in-place using separable 3D Gaussian blur.

Steps:

  1. Extract — create a Float32Array with 1.0 where voxel === channel, 0.0 elsewhere.
  2. Blur — apply separable Gaussian (X → Y → Z) on the float buffer.
  3. Threshold — binarize at 0.5.
  4. Write back — overwrite/erase voxels according to the thresholded result.

Parameters

NameTypeDefault valueDescription
volumeMaskVolumeundefinedThe MaskVolume to operate on (modified in-place).
channelnumberundefinedThe label value to smooth (must be > 0).
sigmanumber1.0Base Gaussian sigma in voxel units (default 1.0).
spacing?[number, number, number]undefinedOptional voxel spacing [sx, sy, sz]. When provided, per-axis sigma is computed as sigma / spacing[axis] so that the physical smoothing radius is isotropic.

Returns

void

Defined in

src/Utils/segmentation/core/GaussianSmoother.ts:33


generateKernel1D

Static generateKernel1D(sigma): Float32Array

Generate a normalized 1D Gaussian kernel truncated at ±3σ.

Parameters

NameTypeDescription
sigmanumberStandard deviation (in voxels). Must be > 0.

Returns

Float32Array

Normalized Float32Array of odd length.

Defined in

src/Utils/segmentation/core/GaussianSmoother.ts:107