I am new here, but ran into the same challenge and tried to attack him directly at the three-dimensional level.
So here is what I did:
def Hausdorff_dist(vol_a,vol_b): dist_lst = [] for idx in range(len(vol_a)): dist_min = 1000.0 for idx2 in range(len(vol_b)): dist= np.linalg.norm(vol_a[idx]-vol_b[idx2]) if dist_min > dist: dist_min = dist dist_lst.append(dist_min) return np.max(dist_lst)
The input should be numpy.array, but the rest works directly.
I have 8000 vs 5000 3D glasses, and this lasts a few minutes, but in the end it comes close to the distance you are looking for.
This, however, is a check of the distance between two points, not necessarily the distance of two curves. (no mesh).
Edit (11/26/2015):
Recenty has completed a finely tuned version of this code. Now it is divided into two parts.
First you need to take care of capturing a box around a given point and taking the entire radius. I think this is a reasonable way to reduce the number of points required for verification.
def bbox(array, point, radius): a = array[np.where(np.logical_and(array[:, 0] >= point[0] - radius, array[:, 0] <= point[0] + radius))] b = a[np.where(np.logical_and(a[:, 1] >= point[1] - radius, a[:, 1] <= point[1] + radius))] c = b[np.where(np.logical_and(b[:, 2] >= point[2] - radius, b[:, 2] <= point[2] + radius))] return c
And another code to calculate the distance:
def hausdorff(surface_a, surface_b):
Akos Gulyban
source share