Reputation: 199
For my project, I need to measure the distance between two 3D meshes based on OBJ-Files. I have to implement two different metrics and compare them. In the course of my literature research, I have so far found only the Hausdorff distance as a metric. Apparently, the Hausdorff distance can be used to calculate the distance of 3D meshes.
Is there an adequate alternative for the Hausdorff distance?
This topic is similiar to mine, but i want to implement two different metrics. Measure distance between meshes
Upvotes: 0
Views: 1151
Reputation: 2816
Many. Depends on your case.
Hausdorff distance is "it is the greatest of all the distances from a point in one set to the closest point in the other set." from wikipedia
Consider the below example of two sets (u and v) in 2 dimensions:
from scipy.spatial.distance import directed_hausdorff
import numpy as np
u = np.array([(1.0, 0.0),
(0.0, 1.0),
(-1.0, 0.0),
(0.0, -1.0)])
v = np.array([(2.0, 0.0),
(0.0, 2.0),
(-2.0, 0.0),
(0.0, -4.0)])
print(directed_hausdorff(u, v))
(2.23606797749979, 3, 0)
Depending on the group you have: 2.23606797749979 or 3.
Going back to the definition I can easily reproduce that results using euclidian distance.
print(euclidean_distances(u, v).min(axis = 0).max(axis = 0))
print(euclidean_distances(u, v).min(axis = 1).max(axis = 0))
3.0
2.23606797749979
Let have a look to all the distances between all the points of the two sets:
print(euclidean_distances(u, v))
[[1. 2.23606798 3. 4.12310563]
[2.23606798 1. 2.23606798 5. ]
[3. 2.23606798 1. 4.12310563]
[2.23606798 3. 2.23606798 3. ]]
As you can see the sortest distance is 1 and the longest 5 for instance. I could formalize that as follow:
print(np.max(euclidean_distances(u, v)))
print(np.min(euclidean_distances(u, v)))
5
1
I could take the average, too:
print(np.mean(euclidean_distances(u, v)))
2.603913694764629
As you see, you have different alternatives there.
Upvotes: 1