This was originally posted as a programming question so I will try to keep it as abstract as possible.
We are dealing with two images. The first is the original and second is a distorted version of the original. Sample images attached.
The original has one square (marker) drawn at the top-left, one at the top-right and one at the bottom right. The three squares are used for determining orientation. We know the $width$, $height$ of the image and the $(x,y)$ coordinates of all three markers. There is also a point of interest $(p)$ on the image whose $(x,y)$ position we know.
The distorted version has some transformations applied to it (translation, scaling and rotation only). This is very common if a document/image is printed and scanned back into the system. It could even be upside down, skewed etc. but for now let's ignore that and assume that even rotation is no more than 15 degrees.
Now, I am able to detect the $(x,y)$ coordinates of all markers and calculate the angle of rotation, the amount of $(x,y)$ translation and the $(x,y)$ scaling factor.
Now, I am able to detect the $(x,y)$ coordinates of all markers for the transformed image and need to calculate the transformed $p$:
$tp = f(om1, om2, om3, op, tm1, tm2, tm3)$ where
- $om1, om2, om3$ are the original markers.
- $op$ is the original point of interest.
- $tm1, tm2, tm3$ are the transformed markers.
- $tp$ is the transformed point of interest.
There are two distinct questions here:
- How can I calculate coordinates for the transformed $(p)$?
- What corner cases should be factored in?