#include <iostream> #include <opencvcv.h> #include <opencv2corecore.hpp> #include <opencv2highguihighgui.hpp> using namespace std ; using namespace cv ; int main(){ Mat now=imread("girl.jpg") ; if(now.empty()){ cout<<"Can't find !"<<endl ; return -1 ; } imshow("old!",now) ; waitKey(0) ; Mat re;; re.create(now.rows, now.cols, now.type()) ; for(int i=0;i<now.rows;i++) for(int j=0;j<now.cols;j++) for(int k=0;k<now.channels();k++){ re.at<Vec3b>(i,j)[k]=255-now.at<Vec3b>(i,j)[k] ; } imshow("new!",re) ; imwrite("girl3.jpg",re) ; waitKey(0) ; return 0 ; }