源代码:
#include<iostream> #include<opencv2/opencv.hpp> #include<opencv2/highgui.hpp> using namespace std; using namespace cv; int main(int argc, char** argv[]) { Mat img; Mat img_meg; vector<Mat>split_; img = imread("E:\Test\c3.jpg"); if (!img.data) { cout <<" error" << endl; } split(img,split_); imshow("B", split_[0]); imshow("G", split_[1]); imshow("R", split_[2]); merge(split_, img_meg); imshow("",img_meg); waitKey(0); return 0; }