0

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

Mec-Eng
  • 199
  • 10

1 Answers1

1

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.

Rafael Valero
  • 2,736
  • 18
  • 28
  • Thank you very much for your detailed and very informative answer. Why then is the Hausdorff distance used to compare 3D models in most scientific papers or programs (MeshLab etc.)? Is the Hausdorff Distance a completely independent metric or rather a "subset" of the Euclidean distance? – Mec-Eng Mar 20 '21 at 14:35
  • It is based in the euclidean. This is probably how has evolved in the area or for particular case. So it is right to use it if other are doing that for the same problem. But there are other ways use in other fields. That does not mean they are better. – Rafael Valero Mar 20 '21 at 14:42
  • Thank you very much for your efforts, I appreciate it very much. Do I understand it correctly that the Hausdorff distance is a specialized / optimized form of the Euclidean distance? Can we still say that they are two different metrics? In my project I should implement different metrics for the comparison of 3D meshes, that's why I ask so detailed :) – Mec-Eng Mar 20 '21 at 16:04