"Interpolation Solutions" |
|
Bilinear Interpolation Method |
|
X = |
|
Y = |
|
Results Z = |
|
IMPLEMENTATION
Bilinear Interpolation
The bilinear interpolation is an extension of the linear interpolation for interpolating functions of two variables,
z = f(x,y), on a regular grid.
This type of interpolation plays an important role in computer vision and image processing. It is a texture mapping
method that produces a reasonably realistic image, and is also known as bilinear texture mapping.
Algorithm Creation
The bilinear interpolation uses four vertex values sorrounding each rectangular unit cell to obtain any value inside the
unit cell. To get the value at (x,y), and the vertices of the unit cell are located at
(x0,y0),(x0,y1),(x1,y0),
and (x1,y1), where they have the given function values z00,z01,
z10, and z11, respectively.
The linear interpolation on the top row of neighbors, between (x0,y0) and
(x1,y0), estimates the value f(x1,y0)
at (x1, y0) as:
f(x,y0) = x1 - x / x1 - x0 z00 +
x - x0 / x1 - x0 * z10
|
Likewise, the linear interpolation on the bottom row of neighbors follow the same concept.
Testing the Bilinear Interpolation Method
In order to test the Bilinear Interpolation method as defined above, a new TestBilinear()
static method has been added and executed. Supporting code and methods are not shown.
In order to test the bilinear interpolation, a two-dimensional data mapping grid with four points
was defined: (0,0), (0,1), (1,0), and (1,1), which have the values 0, 10, 10, and 5, respectively.
The user can manipulate grid values to test the bilinear method.
static void TestBilinear();
{
ListBox1.Items.Clear();
ListBox2.Items.Clear();
ListBox3.Items.Clear();
double[] xarray = new double[] { 0,1 };
double[] yarray = new double[] { 0,1 };
double[] x = new double[9];
double[] y = new double[9];
MatrixR z = new MatrixR(9, 9);;
VectorR vx = new VectorR(x);
VectorR vy = new VectorR(y);
for (int i = 0; i < 9; i++)
{
for (int j = 0; j < 9; j++)
{
z[i, j] = Interpolation.Bilinear(xarray, yarray, zarray, x[i], y[j]);
}
ListBox1.Items.Add(" " + vx.ToString());
ListBox2.Items.Add(" " + vy.ToString());
ListBox3.Items.Add(" " + z.ToString());
}
|
|
|