Skip to main content

distance_transform_edt

Function distance_transform_edt 

pub fn distance_transform_edt(
    mask: &BinaryMask,
) -> Result<Image<f32, 1>, VisionError>
Expand description

Computes the exact Euclidean distance from every foreground pixel to the nearest background pixel using unit pixel spacing.

Background pixels have distance zero. A non-empty mask must contain at least one background pixel; otherwise the finite distance is undefined and an error is returned. The implementation applies the separable linear-time squared-distance transform by Felzenszwalb and Huttenlocher.

See https://doi.org/10.4086/toc.2012.v008a019.