Help with bicubic interpolation algorithm

2

I'm trying to implement the bicubic interpolation algorithm but I'm having a lot of difficulty with interpolated values (it's not related to taking the values of the original matrix, but the relationship of the weights of distances).

Following the idea of this guy here (this case is for bilinear interpolation but it helps to understand the idea of weights): link

In this case, the weights for a factor 2 magnification image would be: 0 0.5 1 (here it would change to the next pixel of the original image).

But in a bicubic interpolation 16 pixels are used as shown in the following image:

Whatcreatesa"4x4 mask" type of the original pixels, ie it would only change the index when x or y exceeds 3. I made a logic for this index and it works but my doubt is related to dx and dy because they will have to go from 0 to 3 (since it is the horizontal and vertical distance) weighted between 0 and 1 right? that is, for a factor 2 increase they will have to go from 0 0.5 1 1.5 2 2.5 3 (weighted would be 0 0.1666 0.25 0.5 0.666 0.83 1 )?

I'm doing with these weights and playing in the polynomial, which can be seen here: link

But the values are a lot of the ones you want (although you're picking up the right pixels and doing the right algorithm).

Is the idea of manipulating weighted weights the same? Or is it incorrect?

If you can explain in a simpler way this algorithm to see if I'm thinking the right way, I'd appreciate it.

EDITED:

For example, consider the following array:

Ifweincreaseitinorder2wouldgetitsweightswouldlooksomethinglike:

If we do

P= Cubo(pixel[index],pixel[index+1],pixel[index+2],pixel[index+3],dx);
Q= Cubo(pixel[index+4],pixel[index+5],pixel[index+6],pixel[index+7],dx);
R= Cubo(pixel[index+8],pixel[index+9],pixel[index+10],pixel[index+11],dx);
S= Cubo(pixel[index+12],pixel[index+13],pixel[index+14],pixel[index+15],dx);

matriz[i][j] =Cubo(P,Q,R,S,dy);

where the cube would be this function:

Cubo(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]))); 
}

If we do this for the value of line 0 and column 1 (dx = 0.1666 and dy = 0) it will generate { 5.04 ,1.98, 1.69, 3.02} and the result of this matriz[i][j] =Cubo(5.04 ,1.98, 1.69, 3.02, dy) will be 1.98 whereas it should give something between 8 e 5 .

Does anyone know what's going wrong?

    
asked by anonymous 09.01.2018 / 01:25

0 answers