Fréchet distance

From HandWiki
Short description: Measure of similarity between curves

In mathematics, the Fréchet distance is a measure of similarity between curves that takes into account the location and ordering of the points along the curves. It is named after Maurice Fréchet.

Intuitive definition

Imagine a person traversing a finite curved path while walking their dog on a leash, with the dog traversing a separate finite curved path. Each can vary their speed to keep slack in the leash, but neither can move backwards. The Fréchet distance between the two curves is the length of the shortest leash sufficient for both to traverse their separate paths from start to finish. Note that the definition is symmetric with respect to the two curves—the Fréchet distance would be the same if the dog were walking its owner.

Formal definition

Let [math]\displaystyle{ S }[/math] be a metric space. A curve [math]\displaystyle{ A }[/math] in [math]\displaystyle{ S }[/math] is a continuous map from the unit interval into [math]\displaystyle{ S }[/math], i.e., [math]\displaystyle{ A : [0,1] \rightarrow S }[/math]. A reparameterization [math]\displaystyle{ \alpha }[/math] of [math]\displaystyle{ [0,1] }[/math] is a continuous, non-decreasing, surjection [math]\displaystyle{ \alpha: [0,1] \rightarrow [0,1] }[/math].

Let [math]\displaystyle{ A }[/math] and [math]\displaystyle{ B }[/math] be two given curves in [math]\displaystyle{ S }[/math]. Then, the Fréchet distance between [math]\displaystyle{ A }[/math] and [math]\displaystyle{ B }[/math] is defined as the infimum over all reparameterizations [math]\displaystyle{ \alpha }[/math] and [math]\displaystyle{ \beta }[/math] of [math]\displaystyle{ [0,1] }[/math] of the maximum over all [math]\displaystyle{ t \in [0,1] }[/math] of the distance in [math]\displaystyle{ S }[/math] between [math]\displaystyle{ A(\alpha(t)) }[/math] and [math]\displaystyle{ B(\beta(t)) }[/math]. In mathematical notation, the Fréchet distance [math]\displaystyle{ F(A,B) }[/math] is

[math]\displaystyle{ F(A,B) = \inf_{\alpha, \beta}\,\,\max_{t \in [0,1]} \,\, \biggl\{d \Bigl( A\bigl(\alpha(t)\bigr), \, B\bigl(\beta(t)\bigr) \Bigr) \biggr\} }[/math]

where [math]\displaystyle{ d }[/math] is the distance function of [math]\displaystyle{ S }[/math].

Informally, we can think of the parameter [math]\displaystyle{ t }[/math] as "time". Then, [math]\displaystyle{ A(\alpha(t)) }[/math] is the position of the dog and [math]\displaystyle{ B(\beta(t)) }[/math] is the position of the dog's owner at time [math]\displaystyle{ t }[/math] (or vice versa). The length of the leash between them at time [math]\displaystyle{ t }[/math] is the distance between [math]\displaystyle{ A(\alpha(t)) }[/math] and [math]\displaystyle{ B(\beta(t)) }[/math]. Taking the infimum over all possible reparametrizations of [math]\displaystyle{ [0,1] }[/math] corresponds to choosing the walk along the given paths where the maximum leash length is minimized. The restriction that [math]\displaystyle{ \alpha }[/math] and [math]\displaystyle{ \beta }[/math] be non-decreasing means that neither the dog nor its owner can backtrack.

The Fréchet metric takes into account the flow of the two curves because the pairs of points whose distance contributes to the Fréchet distance sweep continuously along their respective curves. This makes the Fréchet distance a better measure of similarity for curves than alternatives, such as the Hausdorff distance, for arbitrary point sets. It is possible for two curves to have small Hausdorff distance but large Fréchet distance.

The Fréchet distance and its variants find application in several problems, from morphing[1] and handwriting recognition[2] to protein structure alignment.[3] Alt and Godau[4] were the first to describe a polynomial-time algorithm to compute the Fréchet distance between two polygonal curves in Euclidean space, based on the principle of parametric search. The running time of their algorithm is [math]\displaystyle{ O(mn \cdot \log(mn)) }[/math] for two polygonal curves with m and n segments.

The free-space diagram

example of a free-space diagram
Free-space diagram of the red and the blue curve. In contrast to the definition in the text, which uses the parameter interval [0,1] for both curves, the curves are parameterized by arc length in this example.

An important tool for calculating the Fréchet distance of two curves is the free-space diagram, which was introduced by Alt and Godau.[4] The free-space diagram between two curves for a given distance threshold ε is a two-dimensional region in the parameter space that consist of all point pairs on the two curves at distance at most ε:

[math]\displaystyle{ D_\varepsilon(A,B) := \bigl\{ (\alpha,\beta)\in[0,1]^2 \mathbin{\big|} d( A(\alpha), B(\beta))\le\varepsilon \bigr\} }[/math]

The Fréchet distance [math]\displaystyle{ F(A,B) }[/math] is at most ε if and only if the free-space diagram [math]\displaystyle{ D_\varepsilon(A,B) }[/math] contains a path from the lower left corner to the upper right corner, which is monotone both in the horizontal and in the vertical direction.

As a distance between probability distributions (the FID score)

In addition to measuring the distances between curves, the Fréchet distance can also be used to measure the difference between probability distributions.

For two multivariate Gaussian distributions with means [math]\displaystyle{ \mu_X }[/math] and [math]\displaystyle{ \mu_Y }[/math] and covariance matrices [math]\displaystyle{ \Sigma_X }[/math] and [math]\displaystyle{ \Sigma_Y }[/math], the Fréchet distance between these distributions is[5]

[math]\displaystyle{ d^2 =|\mu_X-\mu_Y|^2+\operatorname{tr}(\Sigma_X+\Sigma_Y-2(\Sigma_X\Sigma_Y)^{1/2}) }[/math].

This distance is the basis for the Fréchet inception distance (FID) that is used to compare images produced by a generative adversarial network with the real images that were used for training.

Variants

The weak Fréchet distance is a variant of the classical Fréchet distance without the requirement that the endpoints move monotonically along their respective curves — the dog and its owner are allowed to backtrack to keep the leash between them short. Alt and Godau[4] describe a simpler algorithm to compute the weak Fréchet distance between polygonal curves, based on computing minimax paths in an associated grid graph.

The discrete Fréchet distance, also called the coupling distance, is an approximation of the Fréchet metric for polygonal curves, defined by Eiter and Mannila.[6] The discrete Fréchet distance considers only positions of the leash where its endpoints are located at vertices of the two polygonal curves and never in the interior of an edge. This special structure allows the discrete Fréchet distance to be computed in polynomial time by an easy dynamic programming algorithm.

When the two curves are embedded in a metric space other than Euclidean space, such as a polyhedral terrain or some Euclidean space with obstacles, the distance between two points on the curves is most naturally defined as the length of the shortest path between them. The leash is required to be a geodesic joining its endpoints. The resulting metric between curves is called the geodesic Fréchet distance.[1][7][8] Cook and Wenk[7] describe a polynomial-time algorithm to compute the geodesic Fréchet distance between two polygonal curves in a simple polygon.

If we further require that the leash must move continuously in the ambient metric space, then we obtain the notion of the homotopic Fréchet distance[9] between two curves. The leash cannot switch discontinuously from one position to another — in particular, the leash cannot jump over obstacles, and can sweep over a mountain on a terrain only if it is long enough. The motion of the leash describes a homotopy between the two curves. Chambers et al.[9] describe a polynomial-time algorithm to compute the homotopic Fréchet distance between polygonal curves in the Euclidean plane with obstacles.

Examples

The Fréchet distance between two concentric circles of radius [math]\displaystyle{ r_1 }[/math] and [math]\displaystyle{ r_2 }[/math] respectively is [math]\displaystyle{ |r_1 - r_2|. }[/math] The longest leash is required when the owner stands still and the dog travels to the opposite side of the circle ([math]\displaystyle{ r_1 + 2*r_2 }[/math]), and the shortest leash when both owner and dog walk at a constant angular velocity around the circle ([math]\displaystyle{ |r_1 - r_2| }[/math]).

Applications

Fréchet distance has been used to study visual hierarchy, a graphic design principle.[10]

See also

References

  1. 1.0 1.1 Efrat, Alon (2002), "New similarity measures between polylines with applications to morphing and polygon sweeping", Discrete and Computational Geometry 28 (4): 535–569, doi:10.1007/s00454-002-2886-1, http://valis.cs.uiuc.edu/~sariel/research/papers/01/morph/morph.pdf .
  2. Sriraghavendra, R.; Karthik, K.; Bhattacharyya, Chiranjib (2007), "Fréchet distance based approach for searching online handwritten documents", Proc. 9th International Conference on Document Analysis and Recognition (ICDAR '07), pp. 461–465, doi:10.1109/ICDAR.2007.121, http://eprints.iisc.ernet.in/26359/ .
  3. Minghui, Jiang; Ying, Xu; Binhai, Zhu (2008), "Protein structure-structure alignment with discrete Fréchet distance", Journal of Bioinformatics and Computational Biology 6 (1): 51–64, doi:10.1142/S0219720008003278, PMID 18324745, http://www.comp.nus.edu.sg/~wongls/psZ/apbc2007/apbc162a.pdf .
  4. 4.0 4.1 4.2 "Computing the Fréchet distance between two polygonal curves", International Journal of Computational Geometry and Applications 5 (1–2): 75–91, 1995, doi:10.1142/S0218195995000064, https://webspace.science.uu.nl/~kreve101/asci/ag-cfdbt-95.pdf .
  5. Dowson, D. C; Landau, B. V (1 September 1982). "The Fréchet distance between multivariate normal distributions" (in en). Journal of Multivariate Analysis 12 (3): 450–455. doi:10.1016/0047-259X(82)90077-X. ISSN 0047-259X. 
  6. Eiter, Thomas (1994), Computing discrete Fréchet distance, Tech. Report CD-TR 94/64, Christian Doppler Laboratory for Expert Systems, TU Vienna, Austria, http://www.kr.tuwien.ac.at/staff/eiter/et-archive/cdtr9464.pdf .
  7. 7.0 7.1 Cook, Atlas F. IV (2008), Geodesic Fréchet distance with polygonal obstacles, Tech. Report CS-TR-2008-0010, University of Texas at San Antonio, http://www.cs.utsa.edu/dmz/techrep/2008/CS-TR-2008-010.pdf .
  8. Maheshwari, Anil; Yi, Jiehua (2005), "On computing Fréchet distance of two paths on a convex polyhedron", Proc. 21st European Workshop on Computational Geometry, pp. 41–44, http://www.eurocg.org/www.win.tue.nl/EWCG2005/Proceedings/11.pdf .
  9. 9.0 9.1 Chambers, Erin Wolf; Colin de Verdière, Éric; Erickson, Jeff; Lazard, Sylvain; Lazarus, Francis; Thite, Shripad (2009), "Homotopic Fréchet distance between curves, or Walking your dog in the woods in polynomial time", Computational Geometry: Theory and Applications 43 (3): 295–311, doi:10.1016/j.comgeo.2009.02.008, https://members.loria.fr/SLazard/paper/frechet_cgta.pdf .
  10. Urano, Yoko; Kurosu, Aaron; Henselman-Petrusek, Gregory; Todorov, Alexander (2021). "Visual hierarchy relates to impressions of good design". CHI'21 Workshop on Eye Movements as an Interface to Cognitive State: 1–9. doi:10.31234/osf.io/hksf9. http://psyarxiv.com/hksf9/. 

Further reading