How to solve series of 8 equations with 8 unknowns?

2.1k Views Asked by At

In this article http://www.fmwconcepts.com/imagemagick/bilinearwarp/FourCornerImageWarp2.pdf

they speak of solving for a0,a1,a2,a3,b0,b1,b2,b3 but I want to know how exactly.

If I substitute the 4 corner coordinates I get

$0 = a0 + a1(52) + a2(0) + a3(52)(0)$

$0 = b0 + b1(52) + b2(0) + b3(52)(0)$

$256 = a0 + a1(228) + a2(46) + a3(228)(46)$

$0 = b0 + b1(228) + b2(46) + b3(228)(46)$

$0 = a0 + a1(255) + a2(229) + a3(255)(229)$

$256 = b0 + b1(255) + b2(229) + b3(255)(229)$

$256 = a0 + a1(0) + a2(246) + a3(0)(246)$

$256 = b0 + b1(0) + b2(246) + b3(0)(246)$

[1 X0 Y0 X0Y0 0 0 0 0][a0] [0] [1 X1 Y1 X1Y1 0 0 0 0][a1] [0] [1 X2 Y2 X2Y2 0 0 0 0][a2] [256] [1 X3 Y3 X3Y3 0 0 0 0][a3] [0] [0 0 0 0 1 X0 Y0 X0Y0][b0]=[0] [0 0 0 0 1 X1 Y1 X1Y1][b1] [256] [0 0 0 0 1 X2 Y2 X2Y2][b2] [256] [0 0 0 0 1 X3 Y3 X3Y3][b3] [256]

I know I can probably solve this manually, but in general is there an algorithm that can solve this since I have to code it?