# How do you interpolate between points in an image (2D), e.g. using splines?

I can understand just fine how to use 1-dimensional interpolation on data points where one coordinate is a function of the other: y = f(x). However, when we have an image, we generally have points in the image that are not given uniquely by such a function, e.g. two points (x1,y1) and (x1,y2), so how do we describe this in order to interpolate between points in the image?

• you can assume the function that best represent your image, and use this function to find any value at any location. – HforHesham Jan 10 '14 at 18:59

There are various methods on 2d interpolation (this one, and this one). But most of them considered at least 4 points rather than 2. The simplest 2d interpolation is 3 1d interpolation, in which you interpolate the points between (x1-d1, y1-d2) and (x1+d1, y1-d2) as (x2,y2), then you interpolate the points between (x1-d3, y1+d4) and (x1+d3, y1+d4) as (x3,y3). Finally (x1,y1) is obtained by 1d interpolation of (x2,y2) and (x3,y3).

the simplest interpolation method is nearest neighbour. If you have 4 points with values given by Ms the interpolated value is given by P = f(x,y):

P$\ = f(x,y)$

= M_11 if $\ |x-x_1|<= |x-x_2|$ and $\ |y-y_1|<= |y-y_2|$,

= M_12 if $\ |x-x_1|< |x-x_2|$ and $\ |y-y_2|< |y-y_1|$,

= M_21 if $\ |x-x_2|< |x-x_1|$ and $\ |y-y_1|< |y-y_2|$,

= M_22 if $\ |x-x_2|< |x-x_1|$ and $\ |y-y_2|< |y-y_1|$.

Another method is bilinear interpolation. Given by:

In both cases the Ms stand for the values at each of 4 points. The x's and y's are coordinates.

I presume that these methods work better when you have a uniform grid (i.e. your Ms are equally spaced apart). Fancier methods may be able to capture more complex data locations. For example kriging.

You asked about 2 point interpolation in a 2D space. Perhaps this occurs at the edges and part of the reason why you get edge effects. Others will be able to correct me on this. I hope this helps somehwat.