Compute distance between 2 models

I have reconstructed two 3D models in the scene. I want to convert them into point clouds and then calculate a comprehensive distance between the two models.

How should I achieve this? For example, if I convert each model into 10 points and also convert the other model into 10 points, then I can use the Kabsch algorithm in this case.

With Python script.

If the models are vtkPolyData, as you would get from model mrml nodes in slicer, then there are vtk filters that compute distance. E.g. hausdorff distance

import vtk
hausdorff_filter = vtk.vtkHausdorffDistancePointSetFilter()
hausdorff_filter.SetInputData(0, polydata1)
hausdorff_filter.SetInputData(1, polydata2)
hausdorff_filter.Update()
print(hausdorff_filter.GetHausdorffDistance())

Of course if you have the point clouds in hand then you can also write your own algorithm in python

1 Like