// 水平翻转(现成的函数)
Mat mirrorImage;
flip(gray_src, mirrorImage, 1);
//对矩阵做类似于水平镜像的变换不用flip函数实现
Mat dst;
dst.create(gray_src.size(), gray_src.type());
Mat map_x;
Mat map_y;
map_x.create(gray_src.size(), CV_32FC1);
map_y.create(gray_src.size(), CV_32FC1);
for(int i = 0; i < gray_src.rows; ++i) {
for(int j = 0; j < gray_src.cols; ++j) {
map_x.at<float>(i, j) = (float)(gray_src.cols - j) ;
map_y.at<float>(i, j) = (float) i;//(src.rows - i) ;
}
}
remap(gray_src, dst, map_x, map_y, INTER_LINEAR);
imshow("dst", dst);
参考链接:https://blog.csdn.net/yang6464158/article/details/41621473