title: Extracting RGB channels in OpenCV under C++
body: <p>I'm using OpenCV to convert image data captured using an IDS uEye camera into a useful format, using the following code:</p>
  
  <pre><code>IplImage* tmpImg = cvCreateImage(cvSize(width,height),IPL_DEPTH_8U,3);
  tmpImg-&gt;imageData = pFrameBuffer[k];
  frame = cv::cvarrToMat(tmpImg);
  </code></pre>
  
  <p>This works perfectly - I can then use <code>imwrite(filename,frame);</code> further downstream to write the processed images out as a sensible format. I would ideally like to be able to save the RGB channels as separate 'grayscale' image files, but I don't understand the OpenCV documentation regarding single-channel operations. Can anyone suggest a means of accomplishing this? Preferably it's not overly computationally expensive (looping over an image pixel-by pixel isn't an option - I'm working with 60-230fps video at up to 1280x1064, and all the processing has to be done at the point of capture).</p>
  
  <p>Running the latest Debian Testing if that makes any difference (I don't think it should).</p>