彩色图像RGB通道的分离、合并


#include <iostream>
#include "cv.h"
#include "highgui.h"

using namespace std;
using namespace cv;

int main(int argc,char* argv[])
{
	Mat img = imread("lena.jpg"/*,CV_LOAD_IMAGE_COLOR*/);
	Mat channel[3];
	split(img,channel);
	imshow("original",img);
	imshow("B",channel[0]);
	imshow("G",channel[1]);
	imshow("R",channel[2]);

	//set blue channel to 0
	channel[0] = Mat::zeros(img.rows,img.cols,CV_8UC1);
	//merge red and green channels
	merge(channel,3,img);
	imshow("R_G_merge",img);

	waitKey(0);
	return 1;
}

对摄像头摄入视频帧的RGB彩色通道分离

Mat frame;
vector<Mat> rgb;

cap >> frame;
imshow("original", frame);
split(frame, rgb);

imshow("red", rgb.at(2));
imshow("green", rgb.at(1));
imshow("blue", rgb.at(0));

From: http://lib.csdn.net/article/opencv/25901

猜你喜欢

转载自blog.csdn.net/tony2278/article/details/83015684
今日推荐