A point-cloud to point-cloud distance can be simply computed using the nearest neighbor distance. The issue is that the nearest neighbour is not necessarily the actual nearest point on the surface represented by the cloud. Especially in our case: the reference cloud has a low density. In this case, an interpolation technique was used (pseudo code):
from scipy import interpolate
import numpy as np
ref_point_cloud = np.load("ref_point_cloud.npy").item() # Grid
f = interpolate.interp2d(ref_point_cloud['x'], ref_point_cloud['y'], ref_point_cloud['z'], kind='linear', copy=False, bounds_error=True)
#### Read dense point cloud (point_cloud_dense) code here ####
for point in point_cloud_dense:
distance = abs(f(point(x), point(y)) - ref_point_cloud['z'])
The interpolation seems a time consuming technique, but it works. Is there a more time efficient technique to compute the distances of the points relatively to the reference point cloud?
Final goal: Remove ground points from a dense MLS point cloud, using a reference point cloud with only ground level points. A distance threshold will decide if a point belongs to the ground surface.
Refs: https://www.cloudcompare.org/doc/wiki/index.php?title=Cloud-to-Cloud_Distance https://pointclouds.org/documentation/tutorials/kdtree_search.html