Finding translation and scale on two sets of points to get least square error in their distance?

后端 未结 8 1422
予麋鹿
予麋鹿 2020-12-07 22:19

I have two sets of 3D points (original and reconstructed) and correspondence information about pairs - which point from one set represents the second one. I need to find 3D

8条回答
  •  隐瞒了意图╮
    2020-12-07 22:36

    Start with translation of both sets of points. So that their centroid coincides with the origin of the coordinate system. Translation vector is just the difference between these centroids.

    Now we have two sets of coordinates represented as matrices P and Q. One set of points may be obtained from other one by applying some linear operator (which performs both scaling and rotation). This operator is represented by 3x3 matrix X:

    P * X = Q

    To find proper scale/rotation we just need to solve this matrix equation, find X, then decompose it into several matrices, each representing some scaling or rotation.

    A simple (but probably not numerically stable) way to solve it is to multiply both parts of the equation to the transposed matrix P (to get rid of non-square matrices), then multiply both parts of the equation to the inverted PT * P:

    PT * P * X = PT * Q

    X = (PT * P)-1 * PT * Q

    Applying Singular value decomposition to matrix X gives two rotation matrices and a matrix with scale factors:

    X = U * S * V

    Here S is a diagonal matrix with scale factors (one scale for each coordinate), U and V are rotation matrices, one properly rotates the points so that they may be scaled along the coordinate axes, other one rotates them once more to align their orientation to second set of points.


    Example (2D points are used for simplicity):

    P =  1     2     Q =   7.5391    4.3455
         2     3          12.9796    5.8897
        -2     1          -4.5847    5.3159
        -1    -6         -15.9340  -15.5511
    

    After solving the equation:

    X =  3.3417   -1.2573
         2.0987    2.8014
    

    After SVD decomposition:

    U = -0.7317   -0.6816
        -0.6816    0.7317
    
    S =  4  0
         0  3
    
    V = -0.9689   -0.2474
        -0.2474    0.9689
    

    Here SVD has properly reconstructed all manipulations I performed on matrix P to get matrix Q: rotate by the angle 0.75, scale X axis by 4, scale Y axis by 3, rotate by the angle -0.25.


    If sets of points are scaled uniformly (scale factor is equal by each axis), this procedure may be significantly simplified.

    Just use Kabsch algorithm to get translation/rotation values. Then perform these translation and rotation (centroids should coincide with the origin of the coordinate system). Then for each pair of points (and for each coordinate) estimate Linear regression. Linear regression coefficient is exactly the scale factor.

提交回复
热议问题