DistanceTransforms.jl is a Julia package that provides efficient distance transform operations on arrays (CPU & GPU).
To get started with DistanceTransforms.jl, you'll first need to import the package:
using DistanceTransforms
The most up-to-date version of DistanceTransforms.jl can be found on the main/master branch of the GitHub repository. If you're using an unregistered version, you may need to add the package explicitly.
For detailed documentation and tutorials, you can refer to the official notebook.
Distance transforms are essential for many computer vision-related tasks. With DistanceTransforms.jl, you can easily apply efficient distance transform operations on arrays in Julia.
For example, to use the quintessential distance transform operation:
using DistanceTransforms
arr = [
0 1 1 0
0 0 0 0
1 1 0 0
]
result = transform(boolean_indicator(arr))
The library is built around a common transform
interface, allowing users to apply various distance transform algorithms to arrays using a unified approach.
DistanceTransforms.jl offers advanced features such as multi-threading and GPU acceleration. These capabilities significantly enhance performance, especially for large data sets and high-resolution images.
DistanceTransforms.jl efficiently utilizes multi-threading, particularly in its Felzenszwalb distance transform algorithm. This parallelization improves performance for large data sets and high-resolution images.
x = boolean_indicator(rand([0f0, 1f0], 100, 100))
single_threaded = @benchmark transform($x; threaded = false)
multi_threaded = @benchmark transform($x; threaded = true)
DistanceTransforms.jl extends its performance capabilities by embracing GPU acceleration. The same transform
function used for CPU computations automatically adapts to leverage GPU resources when available.
x_gpu = CUDA.CuArray(boolean_indicator(rand([0, 1], 100, 100)))
gpu_transformed = transform(x_gpu)
For benchmarks and more details on advanced usage, refer to the advanced usage notebook.
Check out the corresponding Python (wrapper) package: py-distance-transforms