[OpenCV] Split multichannel image


/ Published in: C++
Save to your folder(s)



Copy this code and paste it in your HTML
  1. ...
  2.  
  3. // img is given as a 3 channel image
  4.  
  5. IplImage* ch1 = cvCreateImage(cvSize(img->width, img->height), IPL_DEPTH_8U, 1);
  6. IplImage* ch2 = cvCreateImage(cvSize(img->width, img->height), IPL_DEPTH_8U, 1);
  7. IplImage* ch3 = cvCreateImage(cvSize(img->width, img->height), IPL_DEPTH_8U, 1);
  8.  
  9. cvZero(ch1);
  10. cvZero(ch2);
  11. cvZero(ch3);
  12.  
  13. cvSplit(img, ch1, ch2, ch3, NULL);
  14.  
  15. ...
  16.  
  17. cvReleaseImage(&ch1);
  18. cvReleaseImage(&ch2);
  19. cvReleaseImage(&ch3);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.