Distance transforms for ndarrays
Switch branches/tags
Nothing to show
Latest commit 10d2c34 Mar 20, 2016 @rreusser rreusser Version bump for doc fix
Failed to load latest commit information.
example upgrade to 1.0 Jun 27, 2013
lib adding files May 20, 2013
test Tap -> tape Jul 8, 2015
.gitignore adding files May 20, 2013
.travis.yml Bumped to 1.0.0 Jul 8, 2015
LICENSE adding files May 20, 2013
README.md Update README.md Mar 20, 2016
dt.js upgrade to 1.0 Jun 27, 2013
package.json Version bump for doc fix Mar 20, 2016



Distance transforms for Lp metrics on binary ndarrays. This code is based on Meijster's algorithm. For more information see:

build status


//Generate some shape as a binary voxel image
var x = require("zeros")([256, 256])
x.set(128, 128, 1)

//Distance transform x in the Euclidean metric

//Save result
require("save-pixels")(x, "png").pipe(process.stdout)



Install using npm:

npm install distance-transform


require("distance-transform")(array[, p])

Performs a distance transform of array in place using Meijster's algorithm.

  • array is the array to transform
  • p is the exponent for the metric. (Default 2)

For different values of p you get different transforms

  • p = 1 gives the Manhattan/taxicab distance metric
  • p = 2 gives the Euclidean distance metric
  • p = Infinity gives the Chebyshev/chessboard distance metric
  • Other values of p give various interpolants

array is updated in place and gets the distance values.


(c) 2013 Mikola Lysenko. MIT License.