I am currently writing a MEX file for Matlab in C to first rotate an image and then interpolate it bicubically. While researching I found a partial implementation of bicubic interpolation in C++ on https://www.paulinternet.nl/?page=bicubic. However, the code there only interpolates a 4 by 4 area and returns only a single interpolated value instead of enough values to fill the initial area.
Can anybody tell me how bicubic interpolation is applied to an entire image? Is the image divided into 4x4 chunks that are then interpolated? How do I get values for the entire area of the image? Also, what exactly are "x" and "y" in the function "bicubicInterpolate"?
double cubicInterpolate (double p[4], 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])));
}
double bicubicInterpolate (double p[4][4], double x, double y) {
double arr[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);
}
I tried to discern that from the code from this post "https://stackoverflow.com/questions/20923956/bicubic-interpolation", but I do not understand how the fraction is calculated.
Thank you for your help.