Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

Separate RGB channels in 3 Mat variables

$
0
0
Hello, I am try to separate the RGB values in 3 Mat variables in order to deal with them separately. I would like to use a simple code to understand the data structure of Mat for images. The code I am trying is pasted below, but of course it does not work. Can anyone help me with this? cv::Mat host_img = cv::imread("frame.png"); cv::Mat host_img_green(host_img.size(), CV_8UC1, cv::Scalar(0,0,0)); cv::Mat host_img_red(host_img.size(), CV_8UC1, cv::Scalar(0,0,0)); cv::Mat host_img_blue(host_img.size(), CV_8UC1, cv::Scalar(0,0,0)); for (int i=0 ; i(i,j) = host_img.at(i,j)[0]; host_img_red.at(i,j) = host_img.at(i,j)[1]; host_img_blue.at(i,j) = host_img.at(i,j)[2]; } } cv::imshow("Result", host_img_green); cv::waitKey(); return 0; Thanks in advance, Durden

Viewing all articles
Browse latest Browse all 41027

Trending Articles