This question already has an answer here:
I need to write a script for an illustration program which will take an image, allow the user to outline the rectangular face within the image, and then warp the image so that the rectangular face is actually rectangular to the viewing plane. See the image below. I do not need to do the actual mapping, the program will do that for me if I give it a new rectangle to 'fit' the image to.
Given the set of image corner coordinates (A, B, C and D) and a set of coordinates within the image (E, F, G and H), how do I determine the coordinates of the final transformed image (I, J, K and L)?
As far as which rectangle to map E-H to in order to get I-L, let's call those M, N, O, and P. They will be known.
I am only looking for help with the mathematics of the transformations. I can handle the programming part once I understand the maths.