作者:gnuhpc
出处:http://www.cnblogs.com/gnuhpc/
/* Converts a BGR image to HSV colorspace @param bgr image to be converted @return Returns bgr converted to a 3-channel, 32-bit HSV image with S and V values in the range [0,1] and H value in the range [0,360] */ IplImage* bgr2hsv( IplImage* bgr ) { IplImage* bgr32f, * hsv; bgr32f = cvCreateImage( cvGetSize(bgr), IPL_DEPTH_32F, 3 ); hsv = cvCreateImage( cvGetSize(bgr), IPL_DEPTH_32F, 3 ); cvConvertScale( bgr, bgr32f, 1.0 / 255.0, 0 ); cvCvtColor( bgr32f, hsv, CV_BGR2HSV ); cvReleaseImage( &bgr32f ); return hsv; }