#include <cv.hpp> using namespace cv; int main( int argc, char** argv ) { Mat image; int height, width; // load lena picture and convert to grayscale image = imread("resource/lena.png", IMREAD_GRAYSCALE); // store height and width height = image.rows; width = image.cols; // show image imshow("lena1", image); // inverse image for(int i = 0; i < height; i++) { for(int j = 0; j < width; j++) { image.at<uchar>(i, j) = 255 - image.at<uchar>(i,j); } } // show image again to compare imshow("lena2", image); waitKey(0); return 0; }Result:
Thursday, November 17, 2016
Using opencv to inverse Image.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment