opencv 用户文档 错误更正 仿射变换
来源:互联网 发布:淘宝现金红包哪里抢 编辑:程序博客网 时间:2024/05/25 13:33
今天在看opencv官方给出的仿射变换计算仿射变换矩阵的文档的时候,发现官方文档中有个很明显的错误,再次给大家提个醒。
官方文档连接: http://opencv.willowgarage.com/documentation/cpp/imgproc_geometric_image_transformations.html#warpAffine
其中,在说如何计算仿射矩阵的时候, 原文是这样说的:
cv::getRotationMatrix2D¶
Comments from the Wiki
- Mat getRotationMatrix2D(Point2f center, double angle, double scale)
Calculates the affine matrix of 2d rotation.
Parameters: - center – Center of the rotation in the source image
- angle – The rotation angle in degrees. Positive values mean counter-clockwise rotation (the coordinate origin is assumed to be the top-left corner)
- scale – Isotropic scale factor
The function calculates the following matrix:
where
The transformation maps the rotation center to itself. If this is not the purpose, the shift should be adjusted.
See also: getAffineTransform() , warpAffine() , transform()
然后由仿射矩阵计算每个像素的放射变换后的位置是这样:
但是,很明显的,根据上面的计算,得到的 新的 y 的坐标是错误的
上面的仿射变换矩阵中第二行第三列的元素 中间的 减号弄错了,应该是加号
beta * center.x + (1 - alpha)*center.y
这样计算得到的仿射变换后的点的坐标才是正确的。
可以通过查看源码很容易的看到应该是 加号 “+”
cv::Mat cv::getRotationMatrix2D( Point2f center, double angle, double scale ){ angle *= CV_PI/180; double alpha = cos(angle)*scale; double beta = sin(angle)*scale; Mat M(2, 3, CV_64F); double* m = (double*)M.data; m[0] = alpha; m[1] = beta; m[2] = (1-alpha)*center.x - beta*center.y; m[3] = -beta; m[4] = alpha; m[5] = beta*center.x + (1-alpha)*center.y; return M;}
m[5] 就是上面仿射矩阵中的第二行第三列的元素,可以看到,正确的算法应该是 “+” 号。
- opencv 用户文档 错误更正 仿射变换
- opencv 仿射变换
- OpenCV仿射变换
- opencv仿射变换
- opencv-图像仿射变换
- OpenCv图像仿射变换
- opencv之仿射变换
- OpenCV实现仿射变换
- OpenCV实现仿射变换
- opencv仿射变换与透视变换
- opencv仿射变换与透视变换
- opencv仿射变换、透视变换
- OpenCV图像变换(仿射变换与透视变换)
- opencv笔记3:仿射变换
- OpenCV函数cvWarpAffine仿射变换实例
- opencv学习(6)---仿射变换
- OpenCV: 三对点计算仿射变换
- opencv学习-imgprocess-仿射变换warpAffine
- 数组取最大值最小值
- ios 子视图
- 游久浏览器v1.0.2.1101绿色版[多标签&多窗口通用浏览器]
- failover机制
- Struts 2 概要说明
- opencv 用户文档 错误更正 仿射变换
- 收藏maven错误
- 数据库ACID 理论
- Java中abstract和interface的区别
- 黑马程序员_DbHelper类库
- Android 之 下拉框(Spinner)的使用(1)
- SQL Server 自增列
- Poj 3277 City Horizon - 线段树
- offsetof(struct_type, member) : (type *)0