双线性插值,英文也叫 Bilinear Interpolation 是个对数据非常不错拟合方法.可以想像成在二维网格下对X和Y方向上的两次插值.具体的公式什么的就不多说了,可以参见维基百科
这个插值方法估计很多做研究的都需要用上(当然我不使用matlab), 于是我把公式翻译成C/C++函数, 欢迎使用.如果精度不够,可以改成 双精度 double 类型.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | // https://helloacm.com inline float BilinearInterpolation(float q11, float q12, float q21, float q22, float x1, float x2, float y1, float y2, float x, float y) { float x2x1, y2y1, x2x, y2y, yy1, xx1; x2x1 = x2 - x1; y2y1 = y2 - y1; x2x = x2 - x; y2y = y2 - y; yy1 = y - y1; xx1 = x - x1; return 1.0 / (x2x1 * y2y1) * ( q11 * x2x * y2y + q21 * xx1 * y2y + q12 * x2x * yy1 + q22 * xx1 * yy1 ); } |
// https://helloacm.com inline float BilinearInterpolation(float q11, float q12, float q21, float q22, float x1, float x2, float y1, float y2, float x, float y) { float x2x1, y2y1, x2x, y2y, yy1, xx1; x2x1 = x2 - x1; y2y1 = y2 - y1; x2x = x2 - x; y2y = y2 - y; yy1 = y - y1; xx1 = x - x1; return 1.0 / (x2x1 * y2y1) * ( q11 * x2x * y2y + q21 * xx1 * y2y + q12 * x2x * yy1 + q22 * xx1 * yy1 ); }
GD Star Rating
loading...
本文一共 134 个汉字, 你数一下对不对.loading...
上一篇: 我姐去北京上大学
下一篇: 爸爸, Daddy
扫描二维码,分享本文到微信朋友圈