distanceTransform | R Documentation |
The Euclidean distance transform produces an array like its argument, but with element values representing the Euclidean distance to the nearest nonzero element. The input is treated as logically binary, with all nonzero values treated as "on", and all zeroes as "off".
distanceTransform(x, ...) ## Default S3 method: distanceTransform(x, pixdim = TRUE, signed = FALSE, ...)
x |
Any object. For the default method, this must be coercible to an array. |
... |
Additional arguments to methods. |
pixdim |
An optional numeric vector or logical value. In the former
case it will be taken as giving the physical size of the array elements of
|
signed |
Logical value. If |
An array of the same dimension as the original, whose elements give the Euclidean distance from that element to the nearest "on" element in the original.
Jon Clayden <code@clayden.org>
This implementation is based on the "marching parabolas" algorithm described by Felzenszwalb and Huttenlocher in the paper below.
P.F. Felzenszwalb & D.P. Huttenlocher (2012). Distance transforms of sampled functions. Theory of Computing 8(19):415-428.
x <- c(0,0,1,0,0,0,1,1,1,0,0) distanceTransform(x) distanceTransform(x, pixdim=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.