distance-transform
Distance transforms for Lp metrics on binary ndarrays. This code is based on Meijster's algorithm. For more information see:
- https://github.com/parmanoir/Meijster-distance
- http://dissertations.ub.rug.nl/FILES/faculties/science/2004/a.meijster/c2.pdf
Example
//Generate some shape as a binary voxel imagevar x = 256 256x //Distance transform x in the Euclidean metricx //Save resultx "png"
Output

Install
Install using npm:
npm install distance-transform
API
require("distance-transform")(array[, p])
Performs a distance transform of array
in place using Meijster's algorithm.
array
is the array to transformp
is the exponent for the metric. (Default 2)
For different values of p you get different transforms
p = 1
gives the Manhattan/taxicab distance metricp = 2
gives the Euclidean distance metricp = Infinity
gives the Chebyshev/chessboard distance metric- Other values of p give various interpolants
array
is updated in place and gets the distance values.
License
(c) 2013 Mikola Lysenko. MIT License.