vtkPoints id re-ordering

Hi everyone

I have two vtkPoints sets; both have an equal number of points. The point sets resulted from resampling two more or less similar-looking polydatas (triangular meshes). My goal is to re-order the vertex indices of one of the point sets to morphologically match the other point set (i.e. template point set). So far, I was able to achieve this goal by manually selecting some corresponding points in both point sets and eventually superimposing them to reorder the ids of the target point set.
My question is, is there any way to do it without using superimposition procedures?

Hello,

I don’t understand why the point id’s are important to have the same shape on both point sets… it looks like I didn’t understand the problem. Is it possible to illustrate the problem and what you want to achieve with a figure?

thanks,

PC

Hi

Thanks for the reply. Sorry if the problem was vague; I’m going to provide an example. I have two laser-scanned human faces (triangular meshes), one of which I call the template, and the other one is the target. I resampled (blue noise resampling) both the template and target to get, for example, 200 uniformly distributed vertices. The result of such resampling is two point sets which both have 200 vertices, and they cover the face in a similar pattern.
Now, in the resampled template, the vertex’s index on the tip of the nose is 70, while in the resampled target, the vertex’s index on the nose’s tip is 25. I’m trying to find a way to re-order the target indices so the nose landmark gets the same index (70).
I’m going to treat these vertices as corresponding landmarks and perform Procrustes superimposition via an automated procedure. Hopefully, this example clarified my problem a little more. The tip of the nose was an example; most of the points on the resampled target has different index from the resampled template.

Thank you for your time,

Kaveh

Hello,

That’s clearer now. Well, I know no way to do that in VTK in a single shot. Hence, you have to break down that into simpler tasks:

let output_ps := blank pointset;
For each point in reference_ps:
   let pr := current point in reference_ps;
   let p2 := second_ps.find_closest( pr );
   output_ps.addpoint( p2 );
endFor
let second_ps := output_ps;

That way, you’ll have the second point set with collocated points with the same index order of the first point set. Now it’s up to you to translate that pseudocode into VTK calls.

regards,

PC

Hi,

Thank you very much for the idea; I appreciate it. The problem is that the template and target meshes were digitised separately, so they have different coordinate systems (meshes are far apart). So the closest point approach (vtk point locator or cell locator) won’t be a proper procedure unless I manually superimpose my meshes. Since the coordinate systems are sometimes rotated, even the automated methods of superimposition (such as ICP) don’t work most of the time.

From ages ago, I remember that Maya used to have a tool that could re-order vertex ids (it’s not an open source, so that I couldn’t see the algorithm behind that tool). I was hoping for a similar thing in vtk. I guess the optimal solution is manually superimposing my data (there are hundreds and hundreds of them, that’s why I was thinking about an automated procedure).

Thanks again for your time and attention.

Best,

Kaveh

Hello,

In that case, you need to pre-process the target mesh so they closely match in space and, hence, satisfies the algorithm’s pre-condition. This is an operation called point set registration (Point-set registration - Wikipedia). Chose one that only uses rigid transformations so the points’ relative distances remain the same.

Further reading:

Doing it in VTK:
https://vtk.org/doc/nightly/html/classvtkIterativeClosestPointTransform.html

Doing it in ITK:
https://examples.itk.org/src/registration/metricsv4/registertwopointsets/documentation
Doing it in CGAL:
https://doc.cgal.org/latest/Point_set_processing_3/index.html#Point_set_processing_3Examples_registration_PointMatcher

You can do a duckduckgo search for other libraries out there with such operation implemented.

regards,

PC

1 Like

This is great. The example in CGAL is perfect, and I’m going to implement it. Thank you very much, and have a wonderful day.

Best,

Kaveh

1 Like