Could someone describe a 2d interpolation method that is better than bilinear interpolation?

3.2k views Asked by At

I have a grid of data points that I currently use Bilinear interpolation on to find the missing points in the grid. I was pointed in the directions of Kriging aka thee best linear unbiased estimator, but I was unable to find good source code or an algebraic explanation. Does anyone know of any other interpolation methods I could use?

--Update @Sam Greenhalgh I have considered Bicubic Interpolation but the results I received using the code example I found seemed off.

Here is the code example for Bicubic

Note I am coding in C# but I welcome examples from other languages as well.

    //array 4
    double cubicInterpolate(double[] p, double x)
    {
        return p[1] + 0.5 * x * (p[2] - p[0] + x * (2.0 * p[0] - 5.0 * p[1] + 4.0 * p[2] - p[3] + x * (3.0 * (p[1] - p[2]) + p[3] - p[0])));
    }
    //array 4 4
   public double bicubicInterpolate(double[][] p, double x, double y)
    {
        double[] arr = new double[4];
        arr[0] = cubicInterpolate(p[0], y);
        arr[1] = cubicInterpolate(p[1], y);
        arr[2] = cubicInterpolate(p[2], y);
        arr[3] = cubicInterpolate(p[3], y);
        return cubicInterpolate(arr, x);
    }

double[][] p = {
                new double[4]{2.728562594,2.30599759,1.907579158,1.739559264},
                new double[4]{3.254756633,2.760758022,2.210417411,1.979012766},
                new double[4]{4.075740069,3.366434527,2.816093916,2.481060234},
                new double[4]{5.430966401,4.896723504,4.219613391,4.004306461}
               };

Console.WriteLine(CI.bicubicInterpolate(p, 2, 2));
2

There are 2 answers

3
Pop On

One widely-used interpolation method is kriging (or Gaussian process regression).

However, the use of kriging is not advised when your data points are on a regular grid. The euclidian distances between data points are used to adjust the parameters of the model. But in a grid, there are much fewer values of distance than in, say, a randomly simulated set of points.

Nevertheless, even if your data points are regularly placed, it could be interesting to give it a try. If you are interested, you can use the following softwares:

  • DiceKriging package in R language (there exist others like kriging, gstat...)
  • DACE toolbox in Matlab
  • STK in Matlab/Octave
  • And many others (in python for example)...

NOTE: It can be interesting to note (I do not exactly in what context you want to apply kriging) that the kriging interpolation property can very easily be relaxed in order to take into account, for example, possible measurement errors.

0
lunarquaker On

If your data points are on a regular grid, I would recommend using a piecewise linear spline in two dimensions. You could fill the data for the rows (x-values) first, then fill the data for the columns (y-values.)

Math.NET Numerics has the piecewise linear spline function that you would need:

MathNet.Numerics.Interpolation.LinearSpline.InterpolateSorted