It looks like you're new here. If you want to get involved, click one of these buttons!
Hello Matthias-
This question is more of a geometric question but I'm sure you will have a very short and simple code that can help a lot:
Say I want to align an image to a layout. Both the image and the layout have a set of 3 matching respective landmarks.
So the image landmarks set is: (Im1x,Im1y) (Im2x,Im2y) (Im3x,Im3y) and the layout landmark set is (La1x,La1y) (La2x,La2y) (La3x,La3y)
Can you suggest a code that will transpose the image to the layout using above landmarks coordinates?
Thanks for your time and effort! Itamar
Comments
Hi Itamar,
The method which achieves this is "Matrix3d.adjust". Here is a sample:
The output is (beautified):
which is a displacement of 100, 20 plus a scaling by 0.05 plus a small shear I have induced because I used a y value of 101 for the third image point instead of 100.
This matrix you can then put into the "matrix" property of your pya.Image object to place it according to the landmark mapping.
Matthias
Thank you so much for it Matthias
Hi Matthias -
Can you suggest a method to evaluate similarity of shapes?
Looking at the example above, the image coords form a right-angle triangle. Triangle with (almost) the same proportion of angles and sides is formed by the layout coords.
So in this case the similarity method should indicate that shapes are pretty similar (after the appropriate rotation and scaling).
If we change for example the first image coord to be (100, 150), the similarity method should give lower score for similarity.
Thanks!
Hi @mikamar,
at first glance I'd say the "diagonality" of the upper-left 2x2 matrix of the example case should give you a similarity. That matrix is
That is pretty "diagonal". It's obviously possible to define a metrics that indicates the "non-diagonality", but that depends on whether you include rotations or mirroring into your definition of "similarity".
Matthias