1.用纯白图像-原图

Mat img = imread(path);
imshow("src", img);
waitKey();

Mat white = cv::Mat(250,250,CV_8UC3,Scalar(255,255,255));
imshow("white", white);
waitKey();

Mat dst = white - img;
imshow("dst", dst);
waitKey();

[opencv]三通道图像反色_Opencv

 

Talk is cheap. Show me the code