I am trying to develop an algorithm, but I barely can describe it so I'm not sure what to look for.I have two images img_A and img_B. img_A is the original, while img_B is an image of the same item but slightly different. Let's say one is a photo of a person, while the other is a drawing of that same person. This means that img_B is very similar, to img_A, but it could be slightly rotated and maybe a bit bigger/smaller.What I am trying to do is :from a point from img_A a_a get the corresponding a_b on the img_B.I think I need to define two points on img_A and their correspoinding points on img_B to define the axis correspondance. Once I have those 4 points, I calculate a_b. The 4 axis points will be defined by hand once, then the User will select a point a_a by hand and the correspoinding a_b will be calculated.On a visual example: I select the center of the left eye and the lower point of the chin from both images. I then select the right eye from img_A and as a result I get the coordinates of a_b. (if the drawing was perfectly done, the coordinate of a_b will correspond to the right eye on img_b).How I develop this? I need a matrix to multiply a_a to obtain a_b? how?
Find transformation function for point on an image
math
You are looking for an affine transformation of the formf(v) = s * R * v + twhere v is a 2D vector in the coordinate system of image A, s is a scaling factor (positive real value), R is a 2x2 rotation matrix of the form [cos(alpha)   sin(alpha)] [-sin(alpha)  cos(alpha)]and t is a 2D vector, the translation. f(v) then gives you the corresponding point in image B. So what you need to calculate is s, alpha and t.Lets assume you have two points p1 and p2 in the coordinate system of image A, and two corresponding points q1 and q2 in the coordinate system of image B. Then you can easily calculate s = |q2-q1|/|p2-p1|. The angle alpha is the angle difference between the direction angles of the vector from p1 to p2 and the vector from q1 to q2. The direction angle for p1 to p2 is calculated by atan(dy/dx) where dx and dy are the x and y coordinates of p2-p1 (for q1 to q2 it works similar). To avoid problems of a zero denominator and the sign, use the atan2 function, which is available in many programming languages.So now you have s and R, and from f(p1)=q1 you can now deduce t= q1- s * R * p1which gives you finally the translation t.