//进行图像平移
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;
}