Determine the rotation, translation and scaling in homography matrix from estimateAffinePartial2D; Can I force no scaling? (Euclidan/Rigid)

asked 2019-09-11 16:49:51 -0600

cccoleman gravatar image

I'm trying to align scans to a blank template -- images are from the same scanner at same scale, just rotated and translated. I find ORB feature matching as described here.

I've had good luck using findHomography and then sending that homography matrix to warpPerspective. However, findHomography allows more degrees of freedom than necessary; We just do rotation and translation, no scaling.

estimateAffinePartial2D gives me a 3x2 matrix -- How can I determine the rotation, translations (x&y) , and the scaling contained in that matrix? That way, if scaling is not close to 1, I know the homography is bad.

Is there a way I can FORCE the estimateAffinePartial2D to find only solutions where scaling 1???

edit retag flag offensive close merge delete

Comments

I'm not sure what the differences are between estimateAffinePartial2D and estimateRigidTransform, but I use the former (with the third parameter set to false) - you might want to compare the results between the two.

As for scaling, if you use esimateRigidTransform with the third parameter set to false, you will get a translation, rotation and uniform scale (no projective or shear)...so the upper 2x2 part of the matrix will have the form:


cos * S -sin * S
sin * S cos * S

and since cos^2 + sin^2 = 1, you can determine what S is and then divide it out of the result. It's a bit more work, but I think it would achieve what you want.

swebb_denver gravatar imageswebb_denver ( 2019-09-12 11:23:06 -0600 )edit