JSPM

distance-transform

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 729
  • Score
    100M100P100Q99647F
  • License MIT

Distance transforms for ndarrays

Package Exports

  • distance-transform

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (distance-transform) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

distance-transform

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

build status

Example

//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
require("distance-transform")(x)

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

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 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.

License

(c) 2013 Mikola Lysenko. MIT License.