This article includes a list of general references, but it remains largely unverified because it lacks sufficient corresponding inline citations. (August 2014) |

A **distance transform**, also known as **distance map** or **distance field**, is a derived representation of a digital image. The choice of the term depends on the point of view on the object in question: whether the initial image is transformed into another representation, or it is simply endowed with an additional map or field.

Distance fields can also be signed, in the case where it is important to distinguish whether the point is inside or outside of the shape.^{[1]}

The map labels each pixel of the image with the distance to the nearest *obstacle pixel*. A most common type of obstacle pixel is a *boundary pixel* in a binary image. See the image for an example of a Chebyshev distance transform on a binary image.

Usually the transform/map is qualified with the chosen metric. For example, one may speak of **Manhattan distance transform**, if the underlying metric is Manhattan distance. Common metrics are:

- Euclidean distance
- Taxicab geometry, also known as
*City block distance*or*Manhattan distance*. - Chebyshev distance

There are several algorithms to compute the distance transform for these different distance metrics, however the computation of the exact Euclidean distance transform (EEDT) needs special treatment if it is computed on the image grid.^{[2]}

Applications are digital image processing (e.g., blurring effects, skeletonizing), motion planning in robotics, medical
image analysis for prenatal genetic testing, and even pathfinding.
^{[3]}
Uniformly-sampled signed distance fields have been used for GPU-accelerated font smoothing, for example by Valve researchers.^{[4]}

Signed distance fields can also be used for (3D) solid modelling. Rendering on typical GPU hardware requires conversion to polygon meshes, e.g. by the marching cubes algorithm.^{[5]}

## See also

- Signed distance function
- Function representation
- Parallel curve
- Level sets methods for distance computation.
^{[6]}

## References

**^**http://www.merl.com/publications/docs/TR2000-15.pdf**^**T.Strutz: The Distance Transform and its Computation. June, 2021, TECH/2021/06, arXiv:2106.03503v1, https://arxiv.org/abs/2106.03503**^**http://www.theoryofcomputing.org/articles/v008a019/v008a019.pdf**^**Green, Chris (2007).*Improved alpha-tested magnification for vector textures and special effects*.*ACM SIGGRAPH 2007 Courses on - SIGGRAPH '07*. p. 9. CiteSeerX 10.1.1.170.9418. doi:10.1145/1281500.1281665. ISBN 9781450318235.**^**https://www.youtube.com/watch?v=2MzSmdC49Ns**^**R. Kimmel, N. Kiryati, and A. M. Bruckstein. Distance maps and weighted distance transforms. Journal of Mathematical Imaging and Vision, Special Issue on Topology and Geometry in Computer Vision, 6:223-233,1996.

## External links

- Fast distance transform in C++ by Felzenszwalb and Huttenlocher
- Distance Transform tutorials in CVonline
- Survey of fast exact Euclidean distance transform algorithms
- Using distance mapping for AI
- Distance Transforms by Henry Kwong and Dynamic Step Distance Transforms by Richard Scott, The Wolfram Demonstrations Project.
- Morphological DistanceTransform function in Mathematica
- Morphological InverseDistanceTransform function in Mathematica
- A general algorithm for computing distance transforms in linear time [1]