为什么把单位矩阵等同于OpenCV中的变换矩阵?
Why equate an identity matrix to a transformation matrix in OpenCV
在opencv和c++中,如果我之前已经找到了2个图像之间的变换矩阵,为什么我需要这样做
Mat affineTransform=getAffineTransform(coordinates_1.data(),coordinates_2.data()) ;
Mat perspectiveTransform=Mat::eye(3,3,CV_64FC1);
for(unsigned int y=0; y<2; ++y){
for(unsigned int x=0; x<3; ++x){
perspectiveTransform.at<double>(y,x) = affineTransform.at<double>(y,x);
}
而不是直接对图像应用变换矩阵。我理解Mat::eye()的意思,但是为什么要经历这些呢?
注意: originaltransformationmatrix 是一个Mat对象,找到的变换矩阵是一个3 × 3矩阵
仿射变换有如下形式:
(a, b, c)
(d, e, f)
对点(x,y)进行如下变换:
x_new = a*x + b*y + c;
y_new = d*x + e*y + f;
透视图转换有以下形式:
(a, b, c)
(d, e, f)
(g, h, 1)
对点(x,y)进行如下变换:
z = g*x + h*y + 1;
x_new = (a*x + b*y + c)/z;
y_new = (d*x + e*y + f)/z;
这意味着如果你想定义只做仿射变换的透视图变换,它应该是:
(a, b, c)
(d, e, f)
(0, 0, 1)
这正是你的代码所做的。首先创建矩阵:
(1, 0, 0)
(0, 1, 0)
(0, 0, 1)
然后用仿射变换的行代替前两行。顺便说一下,它可以用不需要循环的更简洁的方式完成:
perspectiveTransform(Rect(0,0,3,2)) = affineTransform.clone();
相关文章:
- 基于范围的变换以实现正常循环
- C++中是否有任何函数等同于python中字典的get函数?
- OpenCV 傅里叶变换复杂输出问题
- SFML 纹理变换(放大)
- 平面缓冲区可以利用向量中的 0 吗?还是其他小波比哈尔变换更好?
- 有没有一种惯用的方法可以在不存储变换或不必要地重新计算的情况下找到数组变换的最小/最大值?
- 在特征中显示仿射变换
- 什么是 C# 等同于C++句柄
- 离散傅立叶变换C++
- ICP变换矩阵平移和旋转
- 如何从2D数组为QHeightMapSurfaceDataProxy创建高度图以显示2D傅立叶变换结果
- POD类型是否完全等同于琐碎的标准布局类型
- 将 3D 变换转换为 2D
- 试图让我的枚举等同于 std::error_code
- 使用变换翻转地图,接收错误"type int unexpected"
- 指示 Qi 变换属性失败的适当方法是什么?
- 如何在 c++ 中将变换与对的向量一起使用
- 骨骼动画:变换矩阵(collada)之间的插值
- 函数已知时的傅里叶变换
- 为什么把单位矩阵等同于OpenCV中的变换矩阵?