|
Correa 1
C++ library with Python bindings to analyse the shape of simple closed curves in R^2
|
This page describes the various distance metrics implemented in the Correa shape comparison library. These metrics quantify the dissimilarity between two 2D polygonal shapes from different geometric and topological perspectives.
The Fréchet distance measures the similarity between two curves by considering their trajectories. It can be intuitively understood as the minimum length of a leash required for a person walking along one curve and their dog walking along another curve, where both can control their speed but cannot go backwards.
Mathematical Definition: Given two curves P and Q, the Fréchet distance is:
![\[\delta_F(P, Q) = \inf_{\alpha, \beta} \max_{t \in [0,1]} d(P(\alpha(t)), Q(\beta(t)))
\]](form_0.png)
where $\alpha$ and $\beta$ are continuous monotone reparameterizations.
Properties:
Use Cases:
These metrics compare shapes based on the properties of fitted ellipses. Three types of ellipse fits are computed for each polygon:
1. Maximum Volume Inscribed Ellipse:
2. Minimum Volume Inscribing Ellipse:
3. Least-Squares Ellipse:
Distance Computation: For each ellipse type, we compute the aspect ratio r = a/b (where a and b are semi-major and semi-minor axes). The distance between two polygons is the absolute difference in their aspect ratios:
![\[d_E(P_1, P_2) = |r_1 - r_2|
\]](form_1.png)
Properties:
Use Cases:
These metrics analyze shapes based on their curvature properties, capturing local geometric features and bending characteristics.
1. Willmore Energy: The Willmore energy measures the total squared curvature of a curve:
![\[W = \int \kappa^2 \, ds
\]](form_2.png)
where $\kappa$ is the curvature and s is arc length.
The distance between two polygons is:
![\[d_W(P_1, P_2) = |W_1 - W_2|
\]](form_3.png)
Properties:
2. Wasserstein Distance on Curvature Distributions: Treats the curvature distribution along each polygon as a probability measure and computes the optimal transport distance between them.
![\[d_{OT}(\mu_1, \mu_2) = \inf_{\gamma \in \Gamma(\mu_1, \mu_2)} \int |x - y| \, d\gamma(x, y)
\]](form_4.png)
Properties:
Use Cases:
This metric uses topological data analysis to compare shapes based on their persistent homology features, specifically 0-dimensional persistence (connected components).
Persistence Diagrams: A persistence diagram is a multiset of points (b, d) in the plane, where:
2-Wasserstein Distance: The distance between two persistence diagrams $D_1$ and $D_2$ is:
![\[W_2(D_1, D_2) = \left( \inf_{\gamma: D_1 \to D_2} \sum_{p \in D_1} \|p - \gamma(p)\|_2^2 \right)^{1/2}
\]](form_5.png)
where the infimum is over all bijections $\gamma$ (including the diagonal).
Properties:
Use Cases:
All comparison programs also compute the sphericity difference:
![\[d_S(P_1, P_2) = 4\pi \left| \frac{A_1}{L_1^2} - \frac{A_2}{L_2^2} \right|
\]](form_6.png)
where A is area and L is perimeter length.
Properties:
Different metrics are appropriate for different applications:
| Metric | Best For | Computational Cost |
|---|---|---|
| Fréchet | Path similarity, ordered matching | Medium |
| Ellipse-based | Overall shape, elongation | Low |
| Curvature-based | Local features, smoothness | Medium |
| Persistence | Topological features, noisy data | High |
| Sphericity | Quick comparison, roundness | Very Low |
Recommendations:
All distance metrics are implemented in the following programs:
The distance type is selected via the -d command-line flag.