Ask Your Question
2

How to extract red color plane in OpenCV C++

asked 2013-05-18 11:22:41 -0600

Ali Tillawi gravatar image

How to extract red color plane in OpenCV C++?

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
5

answered 2013-05-18 11:50:37 -0600

berak gravatar image

easy!

Mat src=imread("my.png");
Mat planes[3];
split(src,planes);  // planes[2] is the red channel
edit flag offensive delete link more

Comments

Is it applicable for android programming in Java with openCv? if not then can you please suggest me the alternative for this code, Thank you.

khatri.kelash gravatar imagekhatri.kelash ( 2017-01-18 11:40:30 -0600 )edit

Thank you Sir for reply, I managed to write the code, and convert the related 3 channels from matrix form to bitmap form but code is not working. The app just show dialog box [Unfortunaly app has stopped].

khatri.kelash gravatar imagekhatri.kelash ( 2017-01-21 13:08:10 -0600 )edit
2

answered 2015-10-06 10:27:00 -0600

Mizux gravatar image

prefer to use void cv::extractChannel (InputArray src, OutputArray dst, int coi )

cv::Mat out; cv::extractChannel(in, out, 0) // Supposing RGB channel with red first out....

src: http://docs.opencv.org/master/d2/de8/group__core__array.html#gacc6158574aa1f0281878c955bcf35642

edit flag offensive delete link more
0

answered 2013-05-21 08:09:39 -0600

Ali Tillawi gravatar image

updated 2013-05-21 08:57:53 -0600

Thank you :)

I have used this one and it worked well:

IplImage* frame_r = cvCreateImage(size, IPL_DEPTH_8U, 1);
IplImage* frame_g = cvCreateImage(size, IPL_DEPTH_8U, 1);
IplImage* frame_b = cvCreateImage(size, IPL_DEPTH_8U, 1);

    cvSplit(frame, frame_b, frame_g, frame_r, NULL);
edit flag offensive delete link more

Comments

2

What you are doing isn't C++ code but using the old C-style API. Keep in mind that the support for the old API will start to get less and less, since people are stimulated to use the newer, more clear C++ interfacing of OpenCV.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-05-21 09:10:51 -0600 )edit

Sir how to subtract among three planes example r-g+b

kamachisundaram gravatar imagekamachisundaram ( 2014-11-20 03:40:28 -0600 )edit

That is just a simple operator. I think you can subtract and add matrices. Have you tried

Mat temp = red - green + blue;

This should work for your needs!

StevenPuttemans gravatar imageStevenPuttemans ( 2014-11-20 03:44:46 -0600 )edit

Question Tools

Stats

Asked: 2013-05-18 11:22:41 -0600

Seen: 39,615 times

Last updated: May 21 '13