Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

distmap

Distance map transform


Description

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.

Usage

distmap(x, metric=c('euclidean', 'manhattan'))

Arguments

x

An 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 foreground ones.

metric

A character indicating which metric to use, L1 distance (manhattan) or L2 distance (euclidean). Default is euclidean.

Details

A fast algorithm of complexity O(M*N*log(max(M,N))), where (M,N) are the dimensions of x, is used to compute the distance map.

Value

An Image object or an array, with pixels containing the distances to the nearest background points.

Author(s)

Gregoire Pau, gpau@ebi.ac.uk, 2008

References

M. N. Kolountzakis, K. N. Kutulakos. Fast Computation of the Euclidean Distance Map for Binary Images, Infor. Proc. Letters 43 (1992).

Examples

x = readImage(system.file("images", "shapes.png", package="EBImage"))
  display(x)
  dx = distmap(x)
  display(dx/10, title='Distance map of x')

EBImage

Image processing and analysis toolbox for R

v4.32.0
LGPL
Authors
Andrzej Oleś, Gregoire Pau, Mike Smith, Oleg Sklyar, Wolfgang Huber, with contributions from Joseph Barry and Philip A. Marais
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.