Opencv进行图像平移
作者:互联网
//进行图像平移
Mat ImageTranslation(Mat srcImage, int xOffset, int yOffset)
{
Size dst_sz = srcImage.size();
//定义平移矩阵
Mat t_mat = Mat::zeros(2, 3, CV_32FC1);
t_mat.at<float>(0, 0) = 1;
t_mat.at<float>(0, 2) = xOffset; //水平平移量
t_mat.at<float>(1, 1) = 1;
t_mat.at<float>(1, 2) = yOffset; //竖直平移量
//根据平移矩阵进行仿射变换
Mat TranslationMat;
warpAffine(srcImage, TranslationMat, t_mat, dst_sz);
return TranslationMat;
}
标签:平移,srcImage,Mat,int,TranslationMat,Opencv,图像,mat 来源: https://www.cnblogs.com/DoublearmyLi/p/14275363.html