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.

Visual Explanation


marked as duplicate by Namaste, amd, qwr, Leucippus, JMP Oct 6 '17 at 1:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ did you try the computer science stack exchange. $\endgroup$ – user451844 Oct 5 '17 at 22:41
  • $\begingroup$ I just need the mathematics involved. I can write the program once I understand the maths. $\endgroup$ – Jed Oct 5 '17 at 22:50
  • $\begingroup$ Basically a duplicate of math.stackexchange.com/q/296794/265466. You want the inverse of the transformation constructed there. $\endgroup$ – amd Oct 5 '17 at 23:03
  • $\begingroup$ These equations might help you: desmos.com/calculator/krm1owqa5b $\endgroup$ – Austin Weaver Oct 5 '17 at 23:16

Browse other questions tagged or ask your own question.