static float bilinear_interpolation_at(float *x, int w, int h, float p, float q) { int ip = p; int iq = q; float a = getsamplec(x, w, h, 1, ip , iq , 0); float b = getsamplec(x, w, h, 1, ip+1, iq , 0); float c = getsamplec(x, w, h, 1, ip , iq+1, 0); float d = getsamplec(x, w, h, 1, ip+1, iq+1, 0); float r = evaluate_bilinear_cell(a, b, c, d, p-ip, q-iq); return r; }
static float bilinear_interpolation(float *x, int w, int h, float p, float q) { int ip = p; int iq = q; float a = getpixel_1(x, w, h, ip , iq ); float b = getpixel_1(x, w, h, ip+1, iq ); float c = getpixel_1(x, w, h, ip , iq+1); float d = getpixel_1(x, w, h, ip+1, iq+1); float r = evaluate_bilinear_cell(a, b, c, d, p-ip, q-iq); return r; }
// instance of "interpolator_t", for bilinear interpolation static float bilinear_interpolation_at(float *x, int w, int h, int pd, float p, float q, int l, extrapolator_t pix) { int ip = floor(p); int iq = floor(q); float a = pix(x, w, h, pd, ip , iq , l); float b = pix(x, w, h, pd, ip+1, iq , l); float c = pix(x, w, h, pd, ip , iq+1, l); float d = pix(x, w, h, pd, ip+1, iq+1, l); return evaluate_bilinear_cell(a, b, c, d, p-ip, q-iq); }
static void bilinear_interpolation_vec_at(float *result, float *x, int w, int h, int pd, float p, float q) { int ip = p; int iq = q; for (int l = 0; l < pd; l++) { float a = getsamplec(x, w, h, pd, ip , iq , l); float b = getsamplec(x, w, h, pd, ip+1, iq , l); float c = getsamplec(x, w, h, pd, ip , iq+1, l); float d = getsamplec(x, w, h, pd, ip+1, iq+1, l); float r = evaluate_bilinear_cell(a, b, c, d, p-ip, q-iq); result[l] = r; } }