About

About DistanceTransforms

DistanceTransforms is a high-performance library for computing distance transforms, available for both Julia and Python. The library provides efficient, GPU-accelerated distance transform operations with a simple API.

Features

  • High Performance: Optimized for CPU and GPU
  • Multi-platform: Julia package with Python bindings
  • GPU Support: NVIDIA (CUDA), AMD (ROCm), and Apple (Metal)
  • Versatile: Works with 1D, 2D, and 3D arrays
  • Simple API: Clean, intuitive interfaces in both languages

Applications

Distance transforms have numerous applications across different fields:

  • Medical Imaging: Organ segmentation, distance metrics between structures
  • Computer Vision: Object recognition, shape analysis, feature extraction
  • Path Planning: Navigation algorithms in robotics
  • Deep Learning: Custom loss functions like Hausdorff distance

Implementation

The core algorithm is based on the Felzenszwalb method, providing O(n) time complexity. For GPU acceleration, the library uses KernelAbstractions.jl, allowing hardware-agnostic implementation across different GPU architectures.

The Python wrapper (distance_transforms) provides seamless integration with NumPy and PyTorch, enabling Python users to leverage the high-performance Julia implementation.

Acknowledgements

This project would not be possible without several excellent Julia packages:

  • KernelAbstractions.jl: Provides hardware-agnostic GPU code that runs across different GPU platforms
  • AcceleratedKernels.jl: Makes it dead simple to write GPU kernels with normal Julia code
  • PythonCall.jl: Powers the Python interoperability layer for seamless integration
  • DLPack.jl: Enables zero-copy tensor sharing with PyTorch for efficient GPU operations

We are grateful to the developers of these packages and the broader Julia and Python communities for their ongoing support and contributions.

Citation

If you use DistanceTransforms in your research, please cite:

@ARTICLE{10912438,
  author={Black, Dale and Li, Wenbo and Zhang, Qiyu and Molloi, Sabee},
  journal={IEEE Access}, 
  title={Accelerating Euclidean Distance Transforms: A Fast and Flexible Approach with Multi-Vendor GPU, Multi-Threading, and Multi-Language Support}, 
  year={2025},
  volume={},
  number={},
  pages={1-1},
  keywords={Transforms;Graphics processing units;Benchmark testing;Euclidean distance;Three-dimensional displays;Image segmentation;Hardware;Python;Metals;Arrays;Distance Transform;Hardware Acceleration;Hausdorff Distance;High Performance Computing;Image Processing;Medical Image Analysis;Parallel Computing;Segmentation;Skeletonization},
  doi={10.1109/ACCESS.2025.3548563}}

License

DistanceTransforms is available under the MIT License.