#include <iostream>
#include <opencv2/opencv.hpp>

using namespace std;
using namespace cv;
int main()
{
	cout << "split & merge\n";
	string f = "angel.png";
	Mat im = imread(f);
	imshow("angel", im);
	waitKey(0);
/////////////////////////////////////////////////////////
	Mat zero1 = Mat::zeros(im.size(), CV_8UC1);
	Mat BGR[3];
	split(im, BGR);
	for (int i = 0; i < 3; i++) {
		imshow(to_string(i), BGR[i]);
		Mat tmp[3] = { zero1, zero1, zero1 };
		tmp[i] = BGR[i];
		Mat dd;
		merge(tmp, 3, dd);
		imshow("channel-" + to_string(i), dd);
	}
	waitKey(0);
	return 0;
}
附件列表