#include <cv.h> #include <highgui.h> int main(void) { IplImage* oo = cvLoadImage("6013202130.jpg", 1); IplImage * Red = cvCreateImage(cvGetSize(oo), 8, 1); IplImage * Green = cvCreateImage(cvGetSize(oo), 8, 1); IplImage * Blue = cvCreateImage(cvGetSize(oo), 8, 1); cvSetImageCOI(oo, 1); //通道1 ,蓝色 cvCopy(oo, Blue); //复制到Blue cvSetImageCOI(oo, 2); //通道2 ,绿色 cvCopy(oo, Green); cvSetImageCOI(oo, 3); //通道3 ,红色 cvCopy(oo, Red); cvNamedWindow("Red", 1); cvNamedWindow("Green", 1); cvNamedWindow("Blue", 1); cvNamedWindow("oo", 1); cvShowImage("原图", oo); cvShowImage("Red", Red); cvShowImage("Green", Green); cvShowImage("Blue", Blue); cvWaitKey(0); cvReleaseImage(&Red); cvReleaseImage(&Green); cvReleaseImage(&Blue); cvReleaseImage(&oo); return 0; }