//進行圖像平移
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;
}