MrEmper
MrEmper

Reputation: 235

C++ bicubic interpolation with a thermal image

At the moment I'm using a MLX90641 sensor on a STM32 to get a temperature grid. The grid itself is 18x12 pixels. I'd like to bicubic interpolate this grid to a 31x23 one, I think that's the most logical one?

My math / calculus knowledge is just sufficient enough to grasp the idea of bicubic interpolation. Yet I can't figure out to make it work in code.

Used language is C++ and https://www.paulinternet.nl/?page=bicubic as a source.

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);
}

Do I loop through my array of doubles and call the function bicubicInterpolate on each value? Why do they use parameters double x, double y?

Anyone able to help me apply this function to my double grid[192]?

Thanks!

Upvotes: 1

Views: 479

Answers (0)

Related Questions