使用图像点对整个图像进行仿射变换? [英] Affine transformation for entire image using image points ?
问题描述
你好,
我有2套图像点(x,y)来自2张图片(ImgX,ImgY)
我想使用这些图像点并找到两个图像之间的仿射变换。
openCV的getAffineTransform()函数给了我单个图像点的矩阵,而不是我可以应用于整个图像的最终矩阵。那么我如何获得可以应用于图像的最终仿射变换矩阵呢?
我尝试了什么:
vector< vector< Point2f> > imagePoints; // imagePoints [0]和imagePoints [1]用xy值初始化
Mat视图; // ImgX也已加载
Mat viewGray = Mat :: zeros(view.rows, view.cols,view.type());
for ( int j = 0 ; j< imagePoints [ 0 ]。size(); j ++)
{
cv :: Mat affImg = getAffineTransform (& imagePoints [ 0 ] [j],& imagePoints [ 1 ] [j]);
cv :: warpAffine(view,viewGray,affImg,view.size());
showImage( 仿射变换,viewGray);
cv :: waitKey( 0 );
}
所以,在上面的例子中,我是否需要在矩阵的向量中推送支持矩阵? div class =h2_lin>解决方案
方法如下: http://docs.opencv.org/2.4/doc/tutorials/imgproc/imgtrans/warp_affine/warp_affine.html
hello,
I have 2 sets of image points (x,y) from 2 images (ImgX, ImgY)
I would like to use these image points and find the affine transformation between the two images.
The getAffineTransform() function of openCV gives me a matrix of individual image points rather than a final matrix which I can apply for the entire image. So how do i get a final affine transformation matrix that can be applied for the image?
What I have tried:
vector<vector < Point2f > > imagePoints; //imagePoints[0] and imagePoints[1] are initilaized with x y values
Mat view ; //ImgX is also loaded
Mat viewGray = Mat::zeros( view.rows, view.cols, view.type() );
for (int j =0; j< imagePoints[0].size(); j++)
{
cv::Mat affImg= getAffineTransform( & imagePoints[0][j], & imagePoints[1][j]);
cv::warpAffine(view,viewGray,affImg, view.size());
showImage("Affine transform", viewGray);
cv::waitKey(0);
}
so, in the above case, do i need to push_back the affImg matrix in a vector of Matrix?
Here's how: http://docs.opencv.org/2.4/doc/tutorials/imgproc/imgtrans/warp_affine/warp_affine.html
这篇关于使用图像点对整个图像进行仿射变换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!