#include <opencv\cv.h> #include <opencv2\core\core.hpp> #include <opencv2\highgui\highgui.hpp> using namespace cv ; using namespace std ; int main() { Mat now ,result; now=imread("girl.jpg") ; if(now.empty()) return -1 ; //printf("%d %d\n",now.cols ,now.rows) ; imshow("mygirl",now) ; waitKey(0) ; int N=now.rows ; int M=now.cols ; result.create(N,M,now.type()) ; for(int i=0;i<N;i++) for(int j=0;j<M;j++){ result.at<Vec3b>(i,j)[0]=now.at<Vec3b>(i,M-1-j)[0] ; result.at<Vec3b>(i,j)[1]=now.at<Vec3b>(i,M-1-j)[1] ; result.at<Vec3b>(i,j)[2]=now.at<Vec3b>(i,M-1-j)[2] ; } imshow("girl2",result) ; imwrite("girl2.jpg",result) ; waitKey(0) ; return 0; }