How to solve system of equations with fractions?

173 Views Asked by At

I have this equation

$U=\frac{a_0+a_1X+a_2Y}{1+c_1X+c_2Y}$ $V=\frac{b_0+b_1X+b_2Y}{1+c_1X+c_2Y}$

Where (X,Y) is a point on a quadrilateral and (U,V) is a point on a rectangle, and (X,Y) actually maps to (U,V) with perspective transformation. From http://www.fmwconcepts.com/imagemagick/bilinearwarp/FourCornerImageWarp2.pdf. (2nd last page)

I am trying to solve for these coefficients but I don't understand how. I know I can sub in the 4 corner coordinates of the quadrilateral corners (which I know), and U,V is the corresponding corner on the rectangle (which I also know). This would give me 8 equations. But then I don't know how to solve for the 5 unknowns. If this was a linear system of equations, then I can do it with Gaussian elimination but for this, does anyone know?

Thanks

1

There are 1 best solutions below

6
On

You have a set of 4 pairs of corners $\{ (X_i , Y_i), (U_i , V_i) \}_{i=1}^{4}$, as you said, that you know and can plug into the two given equations to solve for the coefficients. You will have 8 equations and 8 unknowns.

The equations can be quite easily manipulated into a linear form, \begin{align*} U = \frac{a_0 + a_1 X + a_2 Y}{1 + c_1 X + c_2 Y} &\iff \left(1 + c_1 X + c_2 Y \right)U = a_0 + a_1 X + a_2 Y \\ &\iff a_0 + Xa_1 + Ya_2 - XUc_1 - YUc_2 = U \\ &\iff a_0 + Xa_1 + Ya_2 + 0\cdot b_0 + 0\cdot b_1 + 0\cdot b_2 - XUc_1 - YUc_2 = U \end{align*} and similarly \begin{align*} V = \frac{b_0 + b_1 X + b_2 Y}{1 + c_1 X + c_2 Y} &\iff \left(1 + c_1 X + c_2 Y \right)V = b_0 + b_1 X + b_2 Y \\ &\iff b_0 + Xb_1 + Yb_2 - XVc_1 - YVc_2 = V \\ &\iff 0\cdot a_0 + 0\cdot a_1 + 0\cdot a_2 + b_0 + Xb_1 + Yb_2 - XVc_1 - YVc_2 = V \end{align*} And with these you can use Gaussian elimination.