I'm trying to write a program that operates on 3D point clouds (.ply, .pcd), I need to know the density of the given point cloud file and compare it with a threshold or certain percentage to decide for some operations. How can I do that?
I have found this for 3D point clouds on the web:
Two methods can be used to compute the density:
- either 'Precise': the density is estimated by counting for each point the number of neighbors N (inside a sphere of radius R)
- or 'Approximate': the density is simply estimated by determining the distance to the nearest neighbor (which is generally much faster). This distance is considered as being equivalent to the above spherical neighborhood radius R (and N = 1).
However I'm not sure how to put this into matlab code, I guess I should use pcfitplane for sphere fitting and findNearestNeighbors. Would appreciate a step by step example.