In mathematics, the Hausdorff distance, or Hausdorff metric, also called Pompeiu–Hausdorff distance, 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 and Dimitrie Pompeiu.

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 someone can be forced to travel by an adversary who chooses a point in one of the two sets, from where they 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.

This distance was first introduced by Hausdorff in his book Grundzüge der Mengenlehre, first published in 1914, although a very close relative appeared in the doctoral thesis of Maurice Fréchet in 1906, in his study of the space of all continuous curves from <math>[0,1] \to \R^3</math>.

Definition

thumb|250px|right|Components of the calculation of the Hausdorff distance between the green curve X and the blue curve Y.

Let <math display="inline">(M,d)</math> be a metric space. For each pair of non-empty subsets <math display="inline">X \subset M</math> and <math display="inline">Y \subset M</math>, the Hausdorff distance between <math display="inline">X</math> and <math>Y</math> is defined as

<math display="block"> d_{\mathrm H}(X,Y) := \max\left\{\,\sup_{x \in X} d(x,Y),\ \sup_{y \in Y} d(X,y) \,\right\},</math>

where <math display="inline">\operatorname{sup}</math> represents the supremum operator, <math display="inline">d(a, B) := \displaystyle\inf_{b \in B} d(a,b)</math> quantifies the distance from a point <math display="inline">a \in X</math> to the subset <math display="inline">B\subseteq X</math>, and <math display="inline">\operatorname{inf}</math> is the infimum operator.

An equivalent definition is as follows. For each set <math>X \subset M,</math> let

<math display="block">

X_\varepsilon := \bigcup_{x \in X} \{z \in M \mid d(z,x) \leq \varepsilon\},

</math>

which is the set of all points within <math display="inline">\varepsilon</math> of the set <math display="inline">X</math> (sometimes called the <math display="inline">\varepsilon</math>-fattening of <math display="inline">X</math> or a generalized ball of radius <math display="inline">\varepsilon</math> around <math display="inline">X</math>).

Then, the Hausdorff distance between <math display="inline">X</math> and <math display="inline">Y</math> is defined as

<math display="block">

d_\mathrm{H}(X,Y) := \inf\{\varepsilon \geq 0 \mid X \subseteq Y_\varepsilon \text{ and } Y \subseteq X_\varepsilon\}.

</math>

Equivalently,

  • If the intersection X&nbsp;∩&nbsp;Y has a non-empty interior, then there exists a constant r&nbsp;>&nbsp;0, such that every set X′ whose Hausdorff distance from X is less than r also intersects Y.
  • On the set of all subsets of M, d<sub>H</sub> yields an extended pseudometric.
  • On the set F(M) of all non-empty compact subsets of M, d<sub>H</sub> is a metric.
  • If M is complete, then so is F(M).
  • 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.

Motivation

The definition of the Hausdorff distance can be derived by a series of natural extensions of the distance function <math>d(x,y)</math> in the underlying metric space M, as follows:

  • Define a distance function between any point x of M and any non-empty set Y of M by <math display="block>

d(x, Y) = \inf\{d(x, y) \mid y \in Y\}.

</math> For example, d(1, {3, 6}) = 2 and d(7, {3, 6}) = 1.

  • Define a (not necessarily symmetric) "distance" function between any two non-empty sets X and Y of M by <math display="block>

d(X, Y) = \sup\{d(x, Y) \mid x \in X\}.

</math> For example, <math>d(\{1, 7\}, \{3, 6\}) = \sup\{d(1, \{3, 6\}), d(7, \{3, 6\})\} = \sup\{d(1, 3), d(7, 6)\} = 2.</math>

  • If X and Y are compact, then d(X,&nbsp;Y) will be finite; d(X,&nbsp;X)&nbsp;=&nbsp;0; and d inherits the triangle inequality property from the distance function in M. As it stands, d(X,&nbsp;Y) is not a metric because d(X,&nbsp;Y) is not always symmetric, and does not imply that (it does imply that <math>X \subseteq \overline{Y}</math>). For example, , but . However, we can create a metric by defining the Hausdorff distance to be <math display="block">

d_\text{H}(X, Y) = \max\{d(X, Y), d(Y, X)\}.

</math>

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.

In computer graphics the Hausdorff distance is used to measure the difference between two different representations of the same 3D object particularly when generating level of detail for efficient display of complex 3D models.

thumb|Oceanic pole of inaccessibility at

If <math>X</math> is the surface of Earth, and <math>Y</math> is the land-surface of Earth, then by finding the point Nemo, we see <math>d_\text{H}(X, Y)</math> is around 2,704.8&nbsp;km.

A measure for the dissimilarity of two shapes is given by Hausdorff distance up to isometry, denoted D<sub>H</sub>. Namely, let X and Y be two compact figures in a metric space M (usually a Euclidean space); then D<sub>H</sub>(X,&nbsp;Y) is the infimum of d<sub>H</sub>(I(X),&nbsp;Y) among 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: measuring the distance of two metric spaces M and N by taking the infimum of <math>d_\text{H}\big(I(M), J(N)\big)</math> among all isometric embeddings <math>I\colon M \to L</math> and <math>J\colon N \to L</math> into some common metric space L.

See also

  • Wijsman convergence
  • Kuratowski convergence
  • Hemicontinuity
  • Fréchet distance
  • Hypertopology

References

  • Hausdorff distance between convex polygons.
  • 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: [http://www.mathworks.com/matlabcentral/fileexchange/27905-hausdorff-distance]