PointSet to PointSet registration with random sampling

Hi,
I need to register two point clouds; however my point sets have too many points, so it is quite slow to run.
I have followed the example from the IterativeClosestPoint.
A solution I can think of is to randomly sample my point clouds at each iteration, though I don’t think the registration method allows it…
Any workaround for first randomly sampling my PointSets before registering? I looked around but couldn’t find any. Should I write my own filter? Are there any guidelines/best practices for that?

Hi @Roulbac,

Yes, random sampling the points is one good approach.

The points in a PointSet have an integer index. In Python , you could quickly generate integer indices with numpy.random.shuffle and numpy.arange.

In C++, you could reuse the RandomPermutation code used by itk:ImageRandomNonRepeatingConstIteratorWithIndex:

In either case, create a new point set and populated with points from the complete set using the first N indices.

A bonus challenge is to create a class that encapsulates this operation, and contribute it to the community!

1 Like

Thank you!
Excited to try and contribute that once I get a bit of a break from school stuff!

1 Like

Hello Matt,

Thank you for your post regarding the random sampling on a pointset. Could you please advise how would one uniformly sample the pointsets?

Thank you,
Keyur Shah

I think that two options are full sampling and random sampling. Every n-th point does not make much sense for point sets as it does for images.

1 Like

Hello Dzenan,

Thank you for your response. Another quick question, would you know how to write a pointset to a file? I could not find an example to do so.

Thank you,
Keyur Shah

ITK has no specialized classes for reading and writing point sets.

For 3D points sets, it is possible to save point sets in mesh file formats like .OBJ. In C++, itk::MeshFileReader / itk::MeshFileWriter can be used. In Python, these are exposed with the more Pythonic itk.meshread / itk.meshwrite functions in ITK 5.1.