distmap: Distance map transform
Computes the distance map transform of a binary image.
The distance map is a matrix which contains for each pixel
the distance to its nearest background pixel.
distmap(x, metric=c('euclidean', 'manhattan'))
Image object or an array.
x is considered as a binary image, whose pixels of value 0
are considered as background ones and other pixels as
A character indicating which metric to use, L1 distance (
or L2 distance (
euclidean). Default is
Image object or an array, with pixels
containing the distances to the nearest background points.
A fast algorithm of complexity O(M*N*log(max(M,N))), where (M,N) are the
x, is used to compute the distance map.
ReferencesM. N. Kolountzakis, K. N. Kutulakos. Fast Computation of the Euclidean
Distance Map for Binary Images, Infor. Proc. Letters 43 (1992).
x = readImage(system.file("images", "shapes.png", package="EBImage"))
dx = distmap(x)
display(dx/10, title='Distance map of x')