What is the inverse of this transformation from a rectangle to a quadrilateral? Given the following rectangles:

one can map any point $(x, y)$ from the rectangle to a point $P$ on the quadrilateral using the following steps:


*

*Define linear interpolation as $l(p_0, p_1, t) = p_0 + t(p_1 - p_0)$

*Get the horizontal and vertical ratios of $(x, y)$ to the dimensions of the rectangle: $r_x = \dfrac{x}{||\overline{AB}||}$ and $r_y = \dfrac{y}{||\overline{AD}||}$

*Linearly interpolate up the "vertical" segments of the quadrilateral using the previously calculated vertical ratio $r_y$: $L = l(A, E, r_x)$ and $R = l(G, F, r_x)$

*Linearly interpolate across the "horizontal" segment $\overline{LR}$ using the previously calculated horizontal ratio $r_x$: $P = l(L, R, r_y)$
Is it possible to find the inverse of this process—that being, is it possible to map a point from the quadrilateral to the rectangle instead of from the rectangle to the quadrilateral?
Note: I am looking to use such a process to draw an image file, which is a "rectangular" two-dimensional array of colors, inside a non-rectangular quadrilateral. If such an inverse process is less efficient than a different approach, then feel free to let me know, but I am still interested in whether or not it is possible to find the inverse of this process.
 A: The bilinear interpolation map that you describe is of the form $$x' = a+bx+cy+dxy \\ y' = e+fx+gy+hxy.$$ To solve this system for $x$ and $y$, you can start by multiplying the first equation by $h$ and the second by $d$ and subtracting. This gives you the linear equation $$(bh-df)x+(ch-dg)y+(ah-de)=hx'-dy'$$ which you can then solve for $x$ or $y$ and back-substitute into either of the original equations to get a quadratic in the other variable. Thus, there are up to two possible solutions corresponding to different choices of sign for the square root in the quadratic formula, but only one of them lies in the source rectangle. By continuity, this same choice of sign will give you the correct inverse image for any point in the destination quad. (Geometrically, you’re finding the intersections of two right hyperbolas with asymptotes parallel to the coordinate axes.)  
An alternative to bilinear interpolation is to user a planar homography (perspective transformation) to map from the rectangle to the quad. Unlike the bilinear interpolation above, this map is one-to-one, so can be inverted without having to make any choices to get the correct inverse. Another advantage of this type of mapping is that many computer graphics libraries provide an API to construct this mapping for any pair of (convex) quadrilaterals. To build it yourself, you can use the method described in this answer, which allows you to generate the inverse map at the same time: it’s given by the matrix $AB^{-1}$.
