3
$\begingroup$

I'm trying to do bicubic interpolation on an 8*8 matrix(image) shown below.

A = 10   20  30  40  50  60  70  80
    90  100 110 120 130 140 150 160
    170 180 190 200 210 220 230 240
    250  10  20  30  40  50  60  70
     80  90 100 110 120 130 140 150
    160 170 180 190 200 210 220 230
    240 250  10  20  30  40  50  60
     70  80  90 100 110 120 130 140

I used the following matlab code for it and I got an output

interp2(A,'bicubic')

But even after googling I'm not getting how to do it manually. Can anyone help me to get the idea using this example(only for few pixels)?

$\endgroup$
4
$\begingroup$

Here pretty good explanation.

I'll start by consider the 1D case of cubic interpolation (because its easier to explain) and then go onto the 2D case.

The basic idea of cubic interpolation is to estimate the values between any two points by as a cubic function, $f(x)$, with first derivative, $f'(x)$

$$f(x) = ax^3 + bx^2 + cx + d$$ $$f'(x) = 3ax^2 + 2bx + c$$

so that, when spliced to the adjacent cubic splines on the left and on the right, the interpolated function (the "zeroth derivative") and its first derivative are continuous. That means, at the left boundary of some given spline, the zeroth and first derivatives are equal to the those of the right boundary of the adjacent spline immediately to the left.

Without loss of generality, we can assume that we are interpolating between $x=0$ and $x=1$. On the left and right boundaries, we see that

$$f(0) = d$$ $$f(1) = a+b+c+d$$ $$f'(0) = c$$ $$f'(1) = 3a+2b+c$$

Solving for the polynomial coefficients

$$a = 2f(0) - 2f(1) + f'(0) + f'(1)$$ $$b = -3f(0) + 3f(1) - 2f'(0) - f'(1)$$ $$c = f'(0)$$ $$d = f(0)$$

Now consider the four points around the region being estimated, which are $(-1,y_{-1})$, $(0,y_0)$, $(1,y_1)$, $(2,y_2)$, and impose boundary conditions that

$$f(0) = y_0$$ $$f(1) = y_1$$

and define the two boundary derivatives as

$$f'(0) = \frac{y_1-y_{-1}}{2}$$ $$f'(1) = \frac{y_2-y_0}{2}$$

which is consistent to how they will be defined for the adjacent splines.

Then

$$a = -\frac{y_{-1}}{2} + \frac{3y_0}{2} - \frac{3y_1}{2} + \frac{y_2}{2}$$ $$b = y_{-1} - \frac{5y_0}{2} + 2y_1 - \frac{y_2}{2}$$ $$c = -\frac{y_{-1}}{2} + \frac{y_1}{2}$$ $$d = y_0$$

once the coefficients are known you can interpolate $f(x)$ for any point between the central 2 points, $(0,y_0)$ and $(1,y_1)$.

For bicubic interpolation the principle is pretty much the same but you estimate a surface using 16 points (4x4 grid) rather than just a curve. One simple way to do this is to first interpolate the columns and then interpolate the resulting rows.

$\endgroup$
  • $\begingroup$ these are, BTW, also called Hermite polynomials. $\endgroup$ – robert bristow-johnson Sep 19 '14 at 16:29
  • $\begingroup$ I have never understood what all the fuss over cubic hermite splines was before reading this answer. It is so awesome, thank you so much! $\endgroup$ – Alan Wolfe Aug 6 '15 at 1:20

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.