using DistanceTransforms: transform, boolean_indicator
using CairoMakie: Figure, Axis, heatmap!
# Create a sample binary array
= rand([0, 1], 10, 10)
arr
# Apply distance transform
= transform(boolean_indicator(arr))
result
# Visualize
= Figure(size = (800, 400))
fig = Axis(fig[1, 1], title = "Original")
ax1 = Axis(fig[1, 2], title = "Distance Transform")
ax2 heatmap!(ax1, arr, colormap = :grays)
heatmap!(ax2, result, colormap = :grays)
fig
Overview
DistanceTransforms.jl is a high-performance Julia package for computing distance transforms. It offers significant performance improvements over traditional implementations, especially for large arrays.
Installation
Install DistanceTransforms.jl using Julia’s package manager:
using Pkg
Pkg.add("DistanceTransforms")
Quick Example
Key Features
- Fast Distance Transform: Employs the efficient Felzenszwalb algorithm
- Multi-threading: Parallelized computation on CPU
- GPU Support:
- NVIDIA (CUDA)
- AMD (ROCm)
- Apple (Metal)
- Intel (oneAPI)
- Flexible Input: Works with arrays of various dimensions (1D, 2D, 3D)
Next Steps
- Explore the User Guide for comprehensive documentation
- Check the API Reference for detailed function information