参考论文:Image Warping with Scattered Data Interpolation
Inverse distance weighted interpolation算法(IDW)实际上就是根据给定的控制点对和控制点对的位移矢量(方向和距离),计算控制点对周围像素的反距离加权权重影响,从而实现图像每一个像素点的位移。
代码实现如下:
//IDW:Inverse distgance weighted interpolation method
//Reference:Image Warping with Scattered Data Interpolation
int f_IDW(unsigned char* srcData, int width, int height, int stride, int inputPoints[], int outputPoints[], int pointNum)
{
int ret = 0;
unsigned char* pSrc = srcData;
int aa, bb, cc, dd, pos, pos1, xx, yy;
double r1, r2, r3;
unsigned char *pSrcL1;
unsigned char *pSrcL2;
unsigned char* tempData = (unsigned char*)malloc(sizeof(unsigned char)* height * stride);
memcpy(tempData, srcData, sizeof(uns