Calculating rigid transformation between two point set

Hi!

I am trying to compute the rigid transformation between two point sets.
This seems to me as very commonly used operation, can someone direct me to the package or command
that achieves that?
Tnx!!

Natalie

It’s not very clear what you’re asking. Could you please specify more precisely the question.

I need to calculate T(translation) and R(rotation) matrices for two clouds of 3D (x,y,z) points A and B,
so that the following expression Σ((R*Pb + T) - Pa)^2 will tend to 0,
something like the OpenCV estimateRigidTransform() function does.
Tnx!

1 Like

There is just GitHub - maxruby/OpenCV.jl: The OpenCV (C++) interface for Julia. For a pure Julia implementation, it looks like https://github.com/peterkovesi/ImageProjectiveGeometry.jl may have what you need. Its ransacfithomography is almost what you want, except I don’t think the homogeneous transform it returns is necessarily a rigid transformation. But at the very least, that package implements RANSAC (the basic algorithm used in estimateRigidTransform as well). To me it looks like this would be the repo to contribute to if you wanted a pure Julia version.

1 Like

Hmm, just noticed that you need this for 3D (ImageProjectiveGeometry.ransacfithomography is for 2D, as is estimateRigidTransform). Still, the ransac function could be a good start, even though there are some obvious ways in which its performance can be improved.

I think the function that you want is often called Procrustes alignment.

It’s mostly SVD plus some minor transformations, and it works for any number of dimensions (not just 3).

Here’s a Matlab version which you may want to port to Julia: python - Procrustes Analysis with NumPy? - Stack Overflow

2 Likes

A RANSAC-based algorithm could actually use the Procrustes algorithm code (\ell^2-norm minimization) in the inner loop to improve handling of outliers.

Note this comment on copyright by the way: python - Procrustes Analysis with NumPy? - Stack Overflow.

I believe that the algorithm searched for is Iterative Closest Point (ICP). I’m not aware of any implementations in Julia, but maybe calling Point Cloud Library (PCL) is an option? They have a great number of variants implemented.
https://github.com/JuliaPCL/PCL.jl

1 Like

The thread is old, but this function solves the problem you want to solve, if you want to align structures in three dimensions through rigid-body movements:

https://github.com/leandromartinez98/Work/blob/master/align/align.jl

There is an example in the github directory.