一、通道分离与合并
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/557bbc5c60ce09d3b299a621dcbb14f2.png)
using namespace std;
using namespace cv;
class QuickDemo
{
public:
void channels_Demo(Mat& image)
{
std::vector<Mat> mv;
split(image, mv);
Mat zero = Mat::zeros(image.size(), CV_8UC1);
Mat dst_blue, dst_green, dst_red;
std::vector<Mat> mv_blue, mv_green, mv_red;
mv_blue.push_back(mv[0]);
mv_blue.push_back(zero);
mv_blue.push_back(zero);
merge(mv_blue, dst_blue);
imshow("123", dst_blue);
waitKey(0);
mv_green.push_back(zero);
mv_green.push_back(mv[1]);
mv_green.push_back(zero);
merge(mv_green, dst_green);
imshow("123", dst_green);
waitKey(0);
mv_red.push_back(zero);
mv_red.push_back(zero);
mv_red.push_back(mv[2]);
merge(mv_red, dst_red);
imshow("123", dst_red);
waitKey(0);
int from_to[] = { 0,2,1,1,2,0 };
mixChannels(&image,1, &dst, 1, from_to, 3);
}
};
int main()
{
Mat src = imread("data/right.bmp");
if (src.empty())
{
cout << "load image error !" << endl;
}
QuickDemo qd;
qd.channels_Demo(src);
}