OpenCV函數remap詳解

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;
	}
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章