RGB与HSV转换

IplImage* HSVImage = cvCreateImage(cvGetSize(m_pFrame), 8, 3);  
 // HSV颜色空间各通道  
 IplImage* H = cvCreateImage(cvGetSize(m_pFrame), IPL_DEPTH_8U, 1);  
 IplImage* S = cvCreateImage(cvGetSize(m_pFrame), IPL_DEPTH_8U, 1);  
 IplImage* V = cvCreateImage(cvGetSize(m_pFrame), IPL_DEPTH_8U, 1);  
 cvCvtColor(m_pFrame, HSVImage, CV_BGR2HSV); //BGR→YUV  
 cvSplit( HSVImage, H, S, V, NULL);//分割通道  
 cvEqualizeHist(V,V);
 cvMerge(H,S,V,NULL,HSVImage);
 cvCvtColor(HSVImage,m_pFrame,CV_HSV2BGR);

 cvReleaseImage(&H);
 cvReleaseImage(&S);
 cvReleaseImage(&V);
 cvReleaseImage(&HSVImage);

 

 

IplImage* red=cvCreateImage(cvGetSize(m_pFrameDet),8,1);
  IplImage*green=cvCreateImage(cvGetSize(m_pFrameDet),8,1);
  IplImage*blue=cvCreateImage( cvGetSize(m_pFrameDet),8,1);
  cvSplit(m_pFrameDet,blue,green,red,NULL);
  cvEqualizeHist(red,red);
  cvEqualizeHist(green,green);
  cvEqualizeHist(blue,blue);
  cvMerge(blue,green,red,NULL,m_pFrameDet);
  cvReleaseImage(&red);
  cvReleaseImage(&green);
  cvReleaseImage(&blue);

你可能感兴趣的:(RGB与HSV转换)