I know there is a way to generate a transformation matrix from three pairs of points taken before and after the transformation, but I can not find any documentation on how to determind the transformation matrix. Here is my problem:



|--- ---| |--- ---| |--- ---|
|x'1 x'2 x'3| | | | x1 x2 x3 |
| | | | | |
|y'1 y'2 y'3| = | Matrix M | x | y1 y2 y3 |
| | | | | |
|z'1 z'2 z'3| | | | z1 z2 z3 |
|--- ---| |--- ---| |--- ---|


Given the three pairs of points (x1,y1,z1) --> (x'1,y'1,z'1) etc., how do I find the transformation matrix M?

Spara
Posted on 2004-09-24 16:23:24 by Sparafusile
Work out the inverse the the rightmost matrix and multiply it on the righthand side of the left most one.
Posted on 2004-09-24 16:51:04 by Eóin
Thanks. I figured it was something simple like that. Now, to continue my question... if I have more than three sets of points, how can I use them all in the same way to make the transformation more accurate?

Spara
Posted on 2004-09-24 17:27:48 by Sparafusile
The transformation should be perfectly accurate with just the one set. Unless there are inaccurcies in the points data. Have anymore info?
Posted on 2004-09-25 04:54:52 by Eóin
Yeah, I'm anticipating innacuracies. I'm doing transforms on images so I'm stuck with integer point data. I may also allow the user to select their own points instead of doing it automaticaly so that'll introduce more innacuracies.

Spara
Posted on 2004-09-25 13:13:33 by Sparafusile
Well since you'll probably be dealing with small inaccurcies then working out a couple of matrices and just averaging the components indivually will probably be good enough.

If you know there will be some constraints on the atrix then renforce these on the averaged matrix. Eg if you know the transformation can only consist of translations and rotations then you could renormalise the rotation bits of the matrix. Thats just an example though which may not apply to your needs.
Posted on 2004-09-25 14:17:41 by Eóin
Ok I've run into another problem. Once I actualy implemented the code to do this I realized that (since I'm working with 2D coordinates in a 3x3 matrix) the right column of my matrix is always zero. This presents a problem when trying to find the inverse as there is no determinant.

Should I fill the right column of both of my matrices with a constant (1 for example) or should I fill it with (0, 0, 1) as if it were an identity matrix?

The goal of my program is to stitch pictures together in a mosaic so they're one image. I'm working on the image matching portion and using the transformation matrix to combine the images. Thanks.

Spara
Posted on 2004-10-06 15:33:57 by Sparafusile
Yes, you should put a 1 in the bottom right corner as you guessed.
Posted on 2004-10-07 06:50:21 by Eóin