Math check needed

A detailed and understandable derivation of bicubic interpolation of pixel data seems conspicuously absent on the web, so I thought I'd try to work up a GuruGram on this topic.

A possible starting point appeared as

formatting link

I've gotten through a verification of much of their arcane math and am to the point where I need verification of solutions to these plain old algebraic equations...

w0 = f(0,0) = a00 w1 = f(1,0) = a00 + a10 + a20 + a30 w2 = f(0,1) = a00 + a01 + a02 + a03 w3 = f(1,1) = a00 + a10 + a20 + a30 + a01 + a11 + a21 + a31 + a02 + a12 + a22 + a32 + a03 + a13 + a23 + a33

x0 = fx(0,0) = a10 x1 = fx(1,0) = a10 + 2a20 + 3a30 x2 = fx(0,1) = a10 + a11 + a12 + a13 x3 = fx(1,1) = 1*(a10 + a11 + a12 + a13) + 2*(a20 + a21 + a22 + a23) + 3*(a30 + a31 + a32 + a33)

y0 = fy(0,0) = a01 y1 = fy(1,0) = a01 + a11 + a21 + a31 y2 = fy(0,1) = a01 +2Aa02 + 3a03 y3 = fy(1,1) = 1*(a01+a11+a21+a31) + 2*(a02+a12+a22+a32) + 3*(a03+a13+a23+a33)

z0 = fxy(0,0) = a11 z1 = fxy(1,0) = a11 + 2a21 + 3a31 z2 = fxy(0,1) = a11 + 2a12 + 3a13 z3 = fxy(1,1) = 1*a11 + 2*a12 + 3*a13 + 2*a21 + 4*a22 + 6*a23 + 3*a31 + 6*a32 + 9*a33

Four solutions are available by inspection and another six by pairs of equations. The object is to solve a00 through a33 as functions of w1 through z3.

Your independent checking would be much appreciated. Even a minor error here would cause much later trouble. Please email me via snipped-for-privacy@tinaja.com .

--
Many thanks,

Don Lancaster                          voice phone: (928)428-4073
Synergetics   3860 West First Street   Box 809 Thatcher, AZ 85552
rss: http://www.tinaja.com/whtnu.xml   email: don@tinaja.com

Please visit my GURU\'s LAIR web site at http://www.tinaja.com
Reply to
Don Lancaster
Loading thread data ...

You can write this in matrix form much more elegantly.

Given

A = a_ij X = X(x) = x^i Y = Y(y) = y^j

then the interpolating function is

f(x,y) = X^T*A*Y

taking derivative w.r.t x or Y gives

f_x = X_x^T*A*Y f_y = X^T*A*Y_y

we can then compute the higher partials,

f_xx = X_xx^T*A*Y f_yy = X^T*A*Y_yy f_xy = X_x^T*A*Y_y

etc...

So these are your systems(you have yet to solve for A though)

Basically all you do is pre and post multiply A by x and its derivatives and y and its derivatives respectively to get the total derivative of f.

i.e.

Think of the formula as

f(x,y) = g(x)*C*h(y)

because that is essentially what you have

f_x = g'(x)*C*h(y) f_y = g(x)*C*h'(y)

etc...

Its just that one is dealing with matricies so you need to be careful with the order.

Note though that all the equations are of the form k = B^T*A*C. Each line represents an equation.

If you have some CAS package you should be able to compute the above matricies with ease and check your results.

Jon

Reply to
Jon Slaughter

a00=w0 a01=y0 a02=3*w2-3*w0-2*y0-y2 a03=2*w0-2*w2+y0+y2 a10=x0 a11=z0 a12=3*x2-3*x0-2*z0-z2 a13=2*x0-2*x2+z0+z2 a20=3*w1-3*w0-2*x0-x1 a21=3*y1-3*y0-2*z0-z1 a22=9*w0-9*w1-9*w2+9*w3+6*x0+3*x1-6*x2-3*x3+6*y0-6*y1+3*y2-3*y3+4*z0+2*z1+2*z2+z3 a23=6*w1-6*w0+6*w2-6*w3-4*x0-2*x1+4*x2+2*x3-3*y0+3*y1-3*y2+3*y3-2*z0-z1-2*z2-z3 a30=2*w0-2*w1+x0+x1 a31=2*y0-2*y1+z0+z1 a32=6*w1-6*w0+6*w2-6*w3-3*x0-3*x1+3*x2+3*x3-4*y0+4*y1-2*y2+2*y3-2*z0-2*z1-z2-z3 a33=4*w0-4*w1-4*w2+4*w3+2*x0+2*x1-2*x2-2*x3+2*y0-2*y1+2*y2-2*y3+z0+z1+z2+z3

Reply to
Klueless

Assuming you don't care to follow Jon's more basic derivation and you just want solutions to your equations, why not just put them into Scilab or Matlab or Mathcad? They're just linear equations (assuming that's a typo at y2 = ... +2Aa02 ...), and yield quickly to a matrix inversion.

Reply to
Tom Bruhns

I concur. Here's what I cut and pasted right out of Mathematica. It appears to be identical to what Klueless got.

a00=w0 a01=y0 a02=-3 w0+3 w2-2 y0-y2 a03=2 w0-2 w2+y0+y2 a10=x0 a11=z0 a12=-3 x0+3 x2-2 z0-z2 a13=2 x0-2 x2+z0+z2 a20=-3 w0+3 w1-2 x0-x1 a21=-3 y0+3 y1-2 z0-z1 a22=9 w0-9 w1-9 w2+9 w3+6 x0+3 x1-6 x2-3 x3+6 y0-6 y1+3 y2-3 y3+4 z0+2 z1+2 z2+z3 a23=-6 w0+6 w1+6 w2-6 w3-4 x0-2 x1+4 x2+2 x3-3 y0+3 y1-3 y2+3 y3-2 z0-z1-2 z2-z3 a30=2 w0-2 w1+x0+x1 a31=2 y0-2 y1+z0+z1 a32=-6 w0+6 w1+6 w2-6 w3-3 x0-3 x1+3 x2+3 x3-4 y0+4 y1-2 y2+2 y3-2 z0-2 z1-z2-z3 a33=4 w0-4 w1-4 w2+4 w3+2 x0+2 x1-2 x2-2 x3+2 y0-2 y1+2 y2-2 y3+z0+z1+z2+z3

Reply to
The Phantom

"Don Lancaster" skrev i en meddelelse news: snipped-for-privacy@mid.individual.net...

There exists an ancient program called Maxima that does symbolic math. It works Ok to check the kiddies homework.

formatting link

Reply to
Frithiof Andreas Jensen

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.