#include "opencv2/core/core.hpp"
#include"opencv2/highgui/highgui.hpp"
#include<opencv2/opencv.hpp>
#include "iostream"
using namespace std;
using namespace cv;
void OnMirror_X(Mat img,Mat &OutImg)
{
int Width=img.cols;
int Height=img.rows;
OutImg.create(Height,Width,img.type());
for(int i=0;i<Height;i++)
for(int j=0;j<Width/2;j++)
{
if(img.channels()==1)
{
OutImg.at<uchar>(i,j)=img.at<uchar>(i,Width-j-1);
OutImg.at<uchar>(i,(Width-j-1))=img.at<uchar>(i,j);
}
else if(img.channels()==3)
{
OutImg.at<Vec3b>(i,j)=img.at<Vec3b>(i,Width-j-1);
OutImg.at<Vec3b>(i,Width-j-1)=img.at<Vec3b>(i,j);
}
}
}
void OnMirror_Y(Mat img,Mat &OutImg)
{
int Width=img.cols;
int Height=img.rows;
OutImg.create(Height,Width,img.type());
for(int i=0;i<Height/2;i++)
for(int j=0;j<Width;j++)
{
if(img.channels()==1)
{
OutImg.at<uchar>(i,j)=img.at<uchar>(Height-i-1,j); //一开始没加-1 内存老报错!!!~~~ 细心啊
OutImg.at<uchar>(Height-i-1,j)=img.at<uchar>(i,j);
}
else if(img.channels()==3)
{
OutImg.at<Vec3b>(i,j)=img.at<Vec3b>(Height-i-1,j);
OutImg.at<Vec3b>(Height-i-1,j)=img.at<Vec3b>(i,j);
}
}}#include "opencv2/core/core.hpp"
#include"openc