Skip to main content

trilinear_mask_f32

Function trilinear_mask_f32 

Source
fn trilinear_mask_f32(
    src: &[f64],
    n: [usize; 3],
    coords: &[Vec<f64>; 3],
) -> Vec<f32>
Expand description

trilinear of a 0/1 mask as MATLAB’s interp3(..., 'linear') computes it on a single array, which is how STI Suite’s V_SHARP resamples its mask both ways: each fraction rounded to f32, then (1 − f)·v₀ + f·v₁ in f32, along axis 1 first (interp3’s X, the second array dimension), then axis 0, then axis 2.

The masks are thresholded at > 0.5, and on non-integer resamplings exact ties at 0.5 occur; f64 puts some of them at 0.5 + 1e-15 (in), STI’s single at 0.5 or 0.49999997 (out). On a 27×31×24 phantom at 1.2×0.8×1.5 mm (STI Suite V_SHARP in licensed MATLAB R2023b, spied, 2026-10-30) this reproduces every one of STI’s thresholded working-mask voxels (the values to 1 ulp at 39 of 116,280); f64 put 19 voxels on the other side and moved the local field by 0.96 %.