Compute the generalized distance transform of a sampled function
This module provides a Python implementation of the linear-time distance transform described in:
P. Felzenszwalb, D. Huttenlocher "Distance Transforms of Sampled Functions"
Computing the distance transform is as easy as:
import dt
import numpy as np
x = np.random.standard_normal((100,100))
y,i = dt.compute(x)
This module can handle arbitrary dimensional data:
x = np.random.standard_normal((100,100,4,5))
y,i = dt.compute(x) # compute the distance transform across ALL dimensions
y,i = dt.compute(x, axes=(0,1)) # Compute across the (0,1) axes in the tensor
You can also change the distance function, or parameters used:
y,i = dt.compute(x, f=dt.L2(0.01)) # reduce the distance penalty
Install the package using pip:
pip install git+https://github.com/andyw-0612/distance-transform
You will need Cython to build the extensions.