https://blog.csdn.net/fb_help/article/details/88068805
Void remap(InputArray src,OutputArray dst,InputArray map1,InputArray map2,
int interpolation,int borderMode=BORDER_CONSTANT,const Scalar&borderValue=Scalar())
map需要给出目标到原的映射关系
如map[i,j]=mapx
i,j为目标图像坐标,mapx为源图像横坐标。
例如去畸变时,原图像为畸变,目标图像为无畸变。map(undistortX)计算如下
i,j,为目标图的像素坐标。
for (int i = 0; i < undistortX.rows; i++)
{
float* row = undistortX.ptr<float>(i);
for (int j = 0; j < undistortX.cols; j++)
{
double uc = (j - cx) / fx;
double vc = (i - cy) / fy;
double rc2 = uc*uc + vc*vc;
double UC=uc*(1+k1*pow(rc2,1)+k2*pow(rc2,2));
row[j] = UC*fx + cx;
//cout<<undistortX.ptr<float>(i)[j] <<" "<< row[j]<< endl;
}
}