Abstract
FastGeodis is an open-source Python library designed to provide high-performance computation of Geodesic and Euclidean distance transforms. By leveraging the parallel processing capabilities of PyTorch, OpenMP, and CUDA, FastGeodis achieves significant speedups—up to 74x on GPUs—compared to existing open-source implementations. This efficiency enables real-time interactive 3D medical image segmentation and facilitates the integration of distance transforms into deep learning workflows.
Introduction
In the field of medical imaging, distance transforms are fundamental tools used to calculate the proximity of every pixel or voxel to a reference set of points. While Euclidean distance provides a simple straight-line metric, Geodesic distance transforms (GDT) are often superior for segmentation tasks. GDTs account for the underlying image "terrain," such as tissue intensity gradients, allowing for more accurate delineation of anatomical structures.
Despite their utility, GDTs are computationally intensive. Researchers have traditionally faced a trade-off between slow, single-threaded open-source libraries and highly optimized proprietary software often restricted by patents. FastGeodis addresses this gap by providing a fast, parallelized, and entirely open-source implementation compatible with the modern deep learning ecosystem.
Methods
The primary innovation of FastGeodis lies in its implementation of the parallelizable raster scan method, specifically the algorithm proposed by Criminisi et al. (2009). This method was selected to ensure the library remains free of patent restrictions while maintaining high efficiency.
Algorithmic Logic
The algorithm computes distances through a series of "propagation passes." For 2D data, four passes are performed (top-to-bottom, bottom-to-top, left-to-right, and right-to-left). For 3D volumes, the library executes six passes to ensure coverage across all spatial dimensions. Within each pass, the elements of a single row (in 2D) or a single plane (in 3D) can be computed simultaneously, allowing for massive parallelization.
Implementation Stack
FastGeodis is built on the PyTorch framework, which provides a unified interface for both CPU and GPU hardware. The library utilizes OpenMP for multi-threading on CPUs and CUDA for high-throughput parallelization on GPUs. This architecture allows the library to support not only standard Geodesic and Euclidean transforms but also Signed Geodesic transforms and Geodesic Symmetric Filtering (GSF), which are critical for advanced interactive segmentation.
Performance and Results
The performance of FastGeodis was evaluated against GeodisTK, a widely used open-source library, using 3D medical volume data. Benchmarks were conducted on a system equipped with an Nvidia GeForce Titan X (12 GB) GPU and a 6-Core Intel Xeon E5-1650 CPU.
The results demonstrate substantial improvements in processing speed:
- CPU Performance: FastGeodis achieved a 20x speedup over GeodisTK by utilizing multi-threaded parallelization.
- GPU Performance: The library achieved a 74x speedup, reducing the computation time for large 3D volumes from seconds or minutes to mere milliseconds.
These gains make real-time interaction possible, where a user can provide "scribbles" on a 3D scan and receive instantaneous segmentation feedback.
Discussion and Future Work
By integrating with PyTorch, FastGeodis allows distance transforms to be used directly within deep learning training loops. This opens new avenues for "distance-aware" neural networks that can incorporate spatial priors more effectively.
While more optimized algorithms exist in literature, such as those by Weber et al., they are currently encumbered by patents. FastGeodis prioritizes accessibility and open-source compliance. Future developments may focus on "online learning" applications, where segmentation models adapt in real-time to user input, a feat now possible due to the removal of the GDT computational bottleneck.
Conclusion
FastGeodis provides a critical missing piece in the open-source medical imaging toolkit. By offering a high-performance, GPU-accelerated implementation of Geodesic distance transforms, it empowers researchers to develop more responsive interactive tools and more sophisticated deep learning models.
Summary updated