# Hausdorff distance

In mathematics, the **Hausdorff distance**, or **Hausdorff metric**, also called **Pompeiu–Hausdorff distance**,^{[1]} measures how far two subsets of a metric space are from each other. It turns the set of non-empty compact subsets of a metric space into a metric space in its own right. It is named after Felix Hausdorff.

Informally, two sets are close in the Hausdorff distance if every point of either set is close to some point of the other set. The Hausdorff distance is the longest distance you can be forced to travel by an adversary who chooses a point in one of the two sets, from where you then must travel to the other set. In other words, it is the greatest of all the distances from a point in one set to the closest point in the other set.

It seems that this distance was first introduced by Hausdorff in his book *Grundzüge der Mengenlehre*, first published in 1914.

## Definition

Let *X* and *Y* be two non-empty subsets of a metric space (*M*, *d*). We define their Hausdorff distance *d*_{ H}(*X*, *Y*) by

where *sup* represents the supremum and *inf* the infimum.

Equivalently

where

that is, the set of all points within of the set (sometimes called the -fattening of or a generalized ball of radius around ).

### Remark

It is not true in general that if , then

For instance, consider the metric space of the real numbers with the usual metric induced by the absolute value,

Take

Then . However because , but .

## Properties

- In general,
*d*_{H}(*X*,*Y*) may be infinite. If both*X*and*Y*are bounded, then*d*_{H}(*X*,*Y*) is guaranteed to be finite.

*d*_{H}(*X*,*Y*) = 0 if and only if*X*and*Y*have the same closure.

- For every point
*x*of*M*and any non-empty sets*Y*,*Z*of*M*:*d*(*x*,*Y*) ≤*d*(*x*,*Z*) +*d*_{H}(*Y*,*Z*), where*d*(*x*,*Y*) is the distance between the point*x*and the closest point in the set*Y*.

- |diameter(
*Y*)-diameter(*X*)|≤2*d*_{H}(*X*,*Y*).^{[3]}

- If the intersection
*X*∩*Y*has a non-empty interior, then there exists a constant*r*>0, such that every set*X′*whose Hausdorff distance from*X*is less than*r*also intersects*Y*.^{[4]}

- On the set of all non-empty subsets of
*M*,*d*_{H}yields an extended pseudometric.

- On the set
*F*(*M*) of all non-empty compact subsets of*M*,*d*_{H}is a metric.- If
*M*is complete, then so is*F*(*M*).^{[5]} *(Blaschke selection theorem)*If*M*is compact, then so is*F*(*M*).- The topology of
*F*(*M*) depends only on the topology of*M*, not on the metric*d*.

- If

## Motivation

The definition of the Hausdorff distance can be derived by a series of natural extensions of the distance function *d*(*x*, *y*) in the underlying metric space *M*, as follows:^{[6]}

- Define a distance function between any point
*x*of*M*and any non-empty set*Y*of*M*by:

- For example,
*d*(1, [3,6]) = 2 and*d*(7, [3,6]) = 1.

- Define a distance function between any two non-empty sets
*X*and*Y*of*M*by:

- For example,
*d*([1,7], [3,6]) =*d*(1, [3,6]) = 2.

- If
*X*and*Y*are compact then*d*(*X*,*Y*) will be finite;*d*(*X*,*X*)=0; and*d*inherits the triangle inequality property from the distance function in*M*. As it stands,*d*(*X*,*Y*) is*not*a metric because*d*(*X*,*Y*) is not always symmetric, and*d*(*X*,*Y*) = 0 does not imply that*X*=*Y*(It does imply that ). For example,*d*([1,3,6,7], [3,6]) = 2, but*d*([3,6], [1,3,6,7]) = 0. However, we can create a metric by defining the**Hausdorff distance**to be:

## Applications

In computer vision, the Hausdorff distance can be used to find a given template in an arbitrary target image. The template and image are often pre-processed via an edge detector giving a binary image. Next, each 1 (activated) point in the binary image of the template is treated as a point in a set, the "shape" of the template. Similarly, an area of the binary target image is treated as a set of points. The algorithm then tries to minimize the Hausdorff distance between the template and some area of the target image. The area in the target image with the minimal Hausdorff distance to the template, can be considered the best candidate for locating the template in the target.^{[7]}
In Computer Graphics the Hausdorff distance is used to measure the difference between two different representations of the same 3D object^{[8]} particularly when generating level of detail for efficient display of complex 3D models.

## Related concepts

A measure for the dissimilarity of two shapes is given by *Hausdorff distance up to isometry*, denoted *D*_{H}. Namely, let *X* and *Y* be two compact figures in a metric space *M* (usually a Euclidean space); then *D*_{H}(*X*,*Y*) is the infimum of *d*_{H}(*I*(*X*),*Y*) along all isometries *I* of the metric space *M* to itself. This distance measures how far the shapes *X* and *Y* are from being isometric.

The Gromov–Hausdorff convergence is a related idea: we measure the distance of two metric spaces *M* and *N* by taking the infimum of *d*_{H}(*I*(*M*),*J*(*N*)) along all isometric embeddings *I*:*M*→*L* and *J*:*N*→*L* into some common metric space *L*.

## See also

## References

- ↑ R. Tyrrell Rockafellar, Roger J-B Wets, Variational Analysis, Springer-Verlag, 2005, ISBN 3-540-62772-3, ISBN 978-3-540-62772-2, pg.117.
- ↑ Munkres, James;
*Topology*(2nd edition). Prentice Hall, 1999. Pages 280--281. - ↑ Diameter and Hausdorff Distance, Math.SE
- ↑ Hausdorff Distance and Intersection, Math.SE
- ↑ [1] Completeness and Total Boundedness of the Hausdorff Metric
- ↑ {{#invoke:citation/CS1|citation |CitationClass=book }}
- ↑ Hausdorff-Based Matching
- ↑ P. Cignoni, C. Rocchini, R. Scopigno, "Metro: Measuring Error on Simplified Surfaces", Computer Graphics Forum, Volume 17, Number 2, June 1998, pp. 167-174

## External links

- http://planetmath.org/encyclopedia/HausdorffMetric.html
- Hausdorff distance between convex polygons.
- Completeness and Total Boundedness of the Hausdorff Metric (pdf)
- http://cgm.cs.mcgill.ca/~godfried/teaching/cg-projects/98/normand/main.html
- Using MeshLab to measure difference between two surfaces A short tutorial on how to compute and visualize the Hausdorff distance between two triangulated 3D surfaces using the open source tool MeshLab.
- MATLAB code for Hausdorff distance: [2]