/** * GaussianSmoother — 3D Gaussian smoothing for segmentation masks. * * Applies a separable 3D Gaussian blur to a single label channel within a * MaskVolume, then thresholds the result back to a binary mask. This smooths * jagged edges and fills small holes in segmentation annotations. * * Pure, stateless utility — no DOM/Canvas/GUI dependencies. * * Performance: uses direct typed-array access (bypassing getVoxel/setVoxel * boundary checks) and branch-free convolution for the interior region. */ import type { MaskVolume } from './MaskVolume'; export declare class GaussianSmoother { /** * 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. * * @param volume The MaskVolume to operate on (modified in-place). * @param channel The label value to smooth (must be > 0). * @param sigma Base Gaussian sigma in voxel units (default 1.0). * @param spacing Optional voxel spacing [sx, sy, sz]. When provided, per-axis * sigma is computed as `sigma / spacing[axis]` so that the * physical smoothing radius is isotropic. */ static gaussianSmooth3D(volume: MaskVolume, channel: number, sigma?: number, spacing?: [number, number, number]): void; /** * Generate a normalized 1D Gaussian kernel truncated at ±3σ. * * @param sigma Standard deviation (in voxels). Must be > 0. * @returns Normalized Float32Array of odd length. */ static generateKernel1D(sigma: number): Float32Array; /** * 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. * * @param data Flat float buffer (width × height × depth). * @param width X dimension. * @param height Y dimension. * @param depth Z dimension. * @param axis 0 = X, 1 = Y, 2 = Z. * @param kernel 1D convolution kernel (odd length). */ private static convolve1D; }