How to calculate the transformation Matrix3d?

susu
edited July 2015 in Ruby Scripting
Hello Everyone,

I import lots of images and align them by landmarks often. I am not a Ruby guy and I am writing a Python program to achieve it. My idea is to modify the .lys file. So far my program has managed to import and put images to the right positions automatically. It however does not use landmarks yet to make distortions. The next step would be it. To do that, I need to know how to calculate the transformation matrix, Matrix3d, by the four landmarks I set manually and the four targets on my design. The KLayout documentation demonstrates how to use the matrix alone. It would be useful to know the formula of each matrix element as a function of the landmarks and targets.

Thank you in advance,
Su

Comments

  • edited November -1

    Hi Su,

    it's kind of difficult to give the formula in simple form here.

    If you look at the source code you'll find the computation in dbMatrix.cc, lines 631 and following.

    The computation boils down to solving a linear equation system with 8 variables (the matrix components except the 1.0 in the lower right element) and 8 equations corresponding to the x/y coordinates of the four landmark positions.

    Matthias

Sign In or Register to comment.