FRNN icon indicating copy to clipboard operation
FRNN copied to clipboard

What is the function of the grid points? Can it be used to subsample a point cloud in a voxel downsample way?

Open liuzhy71 opened this issue 1 year ago • 3 comments

Hi,

Thank you for the great work!

Currently I need to find the k nearest neighbor for a point cloud, then I need to downsample the point cloud in a voxel downsample way, can the grid output be use for the downsampling?

liuzhy71 avatar Mar 13 '23 13:03 liuzhy71

Hi,

I hope I understand your question correctly. Here is the documentation for the returned grid structure:

https://github.com/lxxue/FRNN/blob/59a4c8fdc786c64afd991919af39f1a65d4ec2ff/frnn/frnn.py#L217-L223

In sorted_points2, points are sorted according to their voxel index. Therefore, with pc2_grid_off you will know the points inside one specific voxel (Here 2 are hard-coded for 2D points, you might want to change to 3):

https://github.com/lxxue/FRNN/blob/3e370d8d9073d4e130363faf87d2370598b5fbf2/frnn/csrc/grid/find_nbrs.cu#L50-L60

And then you can do whatever you want to downsample the points inside each voxel.

lxxue avatar Mar 13 '23 15:03 lxxue

Thanks a lot! Are we allowed to change the initial grid size before fitting the knn?

liuzhy71 avatar Mar 14 '23 01:03 liuzhy71

Yes, the search radius r and radius_cell_ratio jointly determine the grid size: https://github.com/lxxue/FRNN/blob/3e370d8d9073d4e130363faf87d2370598b5fbf2/frnn/frnn.py#L77

For KNN you should find a radius large enough so that you can find K neighbors within the radius for sure. When the radius_cell_ratio is an integer, the method runs more efficiently since it search 2*ceil(radius_cell_ratio)+1 grids on one dimension.

lxxue avatar Mar 14 '23 10:03 lxxue