图像径向畸变矫正
来源:互联网 发布:上海 日料 知乎 编辑:程序博客网 时间:2024/04/27 13:24
1. 最近遇到图像畸变矫正的问题,
因此学习了张正友的"A Flexible New Technique for CameraCalibration"一文,只考虑二阶径向畸变,描述如下:
2. 校正径向畸变
径向畸变的校正过程就是给理想像素点位置赋予畸变后的坐标处的像素值的过程。
其中(u,v)为理想的像素坐标,由于径向畸变的存在,实际得到的有畸变的位置变成了u',v'. 为了达到矫正的目的,将理想图像坐标(u,v)处的坐标值赋为实际得到的图像中的(u'.v')处的像素值即可。
畸变校正对比如下图:
校正后:
实现代码如下:
void undistortion(Mat &sourceImg, Mat &compensatedImg){float normalizedX;//nomalizeX = Xw / Zwfloat normalizedY;//nomalizeY = Yw / Zwfloat distance;//radiusfloat radialDistor;//radial distortion factorint CAM_U0=269;int CAM_V0=244;float CAM_FX=1674.549990;float CAM_FY=1675.318550;float CAM_K1=-0.273573;float CAM_K2=-0.790143;uchar sourceV;//gray value of current positionint distorPixelPositionX;//畸变后的位置int distorPixelPositionY; //畸变后的位置//compensatedImg = cvCreateImage(cvSize(sourceImg->height, sourceImg->width), IPL_DEPTH_8U, 1);//show_image(sourceImg);for(int h = 0; h < sourceImg.rows; h++){for(int w = 0; w < sourceImg.cols; w++){normalizedX = ((float)w - CAM_U0) / CAM_FX;normalizedY = ((float)h - CAM_V0) / CAM_FY;distance = normalizedX * normalizedX + normalizedY * normalizedY;radialDistor = CAM_K1 * distance + CAM_K2 * pow(distance , 2) ;//compensatedX = (((float)w - CAM_U0) / CAM_FX ) / radialDistor;//compensatedY = (((float)h - CAM_V0) / CAM_FY ) / radialDistor;distorPixelPositionX = w+((float)w-CAM_U0)*radialDistor;distorPixelPositionY = h+((float)h-CAM_V0)*radialDistor;if(distorPixelPositionX < 0 || distorPixelPositionX > sourceImg.cols - 1){distorPixelPositionX = 0;}if(distorPixelPositionY < 0 || distorPixelPositionY > sourceImg.rows- 1){distorPixelPositionY = 0;}//sourceV = cvGet2D(sourceImg, h, w);sourceV = sourceImg.at<uchar>(distorPixelPositionY,distorPixelPositionX);;compensatedImg.at<uchar>(h,w)=sourceV;//cvSet2D(compensatedImg, newPixelPositionY, newPixelPositionX, sourceV);}}}
0 0
- 图像径向畸变矫正
- 图像矫正----认识畸变(Distortion)
- 摄像机标定和图像径向畸变校正
- 摄像机标定和图像径向畸变校正
- 摄像机模型,畸变模型及畸变图像的矫正
- opencv 图像畸变矫正加速、透视变换加速方法总结
- 鱼眼镜头图像畸变矫正(fish eye distortion)
- opencv 图像畸变矫正加速、透视变换加速方法总结
- 畸变矫正(反畸变)
- 镜头畸变矫正
- 摄像机标定矫正畸变
- 摄像机标定--矫正畸变
- labview畸变矫正
- 几何畸变矫正
- 相机畸变矫正
- 什么是径向畸变?
- C/C++ 图像处理(9)------图像の桶形畸变矫正
- 相机的标定+畸变矫正
- Coder-Strike 2014 - Finals (online edition, Div. 2) Online Meeting
- C# 模拟键盘 和 鼠标
- 在asp.net中调用process.start执行程序
- Coder-Strike 2014 - Finals (online edition, Div. 2 A、B)
- java服务器性能
- 图像径向畸变矫正
- 数论poj1845 因子和,等比数列求和
- self.view.fream
- python中创建指定大小的多维数组
- 经典算法之迷宫问题
- 解析innodb status各项参数
- 留学高中生独自在宿舍玩死亡游戏 客死异乡
- JavaScript中对象的属性
- 看看有多少个网站能帮到你