Hi all,
I'm trying to wrap my head around interpolation. The source data is a uniform array of values which are equally spaced - much like an array of image pixels in fact.
I understand bilinear interpolation, but stepping up to bicubic is causing me problems.
Here is an example of what I'm trying to achieve:
d00----d10----d20----d30
| | | |
| | | |
d01----d11----d21----d31
| | x | |
| | | |
d02----d12----d22----d32
| | | |
| | | |
d03----d13----d23----d33
Here I have a representation of the data required to sample the point 'x'. The dXX values represent the surrounding values which serve as the interpolation input.
I understand I have to weight these values based on there position relative to the point'x'. At the moment, this weight is based on the position in the containing cell - on my example, the 'x' point is roughly 3/4 the way across the cell, and 1/4 the way down.
From that, I use the following equation to get the value at 'x':
float dx = 0.75; // 3/4 across
float dy = 0.25; // 1/4 down.
float x = dx;
float y = dy;
float x2 = x * x;
float x3 = x2 * x;
float y2 = y * y;
float y3 = y2 * y;
float xVal = d00 + (d10 * x) + (d01 * y) + (d20 * x2) + (d11 * x * y) + (d02 * y2) +
(d21 * x2 * y) + (d12 * x * y2) + (d22 * x2 * y2) + (d30 * x3) + (d03 * y3) +
(d31 * x3 * y) + (d13 * x * y3) + (d32 * x3 * y2) + (d23 * x2 * y3) + (d33 * x3 * y3);
But.. it doesn't work. I think I'm almost there, but I'm having trouble figuring out where I'm going wrong. Has anyone done this before, or can someone figure out where I'm going wrong?