![](http://img.zemanta.com/pixy.gif?x-id=df7bd669-8336-4401-af68-63a6b02fd956)
/*
15 Converts a BGR image to HSV colorspace
16
17 @param bgr image to be converted
18
19 @return Returns bgr converted to a 3-channel, 32-bit HSV image with
20 S and V values in the range [0,1] and H value in the range [0,360]
21 */
22 IplImage* bgr2hsv( IplImage* bgr )
23 {
24 IplImage* bgr32f, * hsv;
25
26 bgr32f = cvCreateImage( cvGetSize(bgr), IPL_DEPTH_32F, 3 );
27 hsv = cvCreateImage( cvGetSize(bgr), IPL_DEPTH_32F, 3 );
28 cvConvertScale( bgr, bgr32f, 1.0 / 255.0, 0 );
29 cvCvtColor( bgr32f, hsv, CV_BGR2HSV );
30 cvReleaseImage( &bgr32f );
31 return hsv;
32 }