Ask Your Question

Revision history [back]

You can simply convert your Image to CV_32FC3 which ranges from 0.0-1.0. Here is the sample usage!

Mat mBGR_8=imread("test.bmp",1);//Range- 0 to 255
Mat mBGR_32;
mBGR_8.convertTo(mBGR_32,CV_32FC3);//BGR Range- 0.0 to 1.0

Mat mHsv_32;
cvtColor(mBGR_32, mHsv_32,COLOR_BGR2HSV);//HSV Range- 0.0 to 1.0

You can simply convert your Image to CV_32FC3 which ranges from 0.0-1.0. Here is the sample usage!

Mat mBGR_8=imread("test.bmp",1);//Range- 0 to 255
Mat mBGR_32;
mBGR_8.convertTo(mBGR_32,CV_32FC3);//BGR mBGR_8.convertTo(mBGR_32,CV_32FC3,1/255);//BGR Range- 0.0 to 1.0

Mat mHsv_32;
cvtColor(mBGR_32, mHsv_32,COLOR_BGR2HSV);//HSV Range- 0.0 to 1.0

You can simply convert your Image to CV_32FC3 which ranges from 0.0-1.0. Here is the sample usage!

Mat mBGR_8=imread("test.bmp",1);//Range- 0 to 255
Mat mBGR_32;
mBGR_8.convertTo(mBGR_32,CV_32FC3,1/255);//BGR mBGR_8.convertTo(mBGR_32,CV_32FC3,1.0/255.0);//BGR Range- 0.0 to 1.0

Mat mHsv_32;
cvtColor(mBGR_32, mHsv_32,COLOR_BGR2HSV);//HSV Range- 0.0 to 1.0

You can simply convert your Image to CV_32FC3 which ranges from 0.0-1.0. Here is the sample usage!

Mat mBGR_8=imread("test.bmp",1);//Range- 0 to 255
Mat mBGR_32;
mBGR_8.convertTo(mBGR_32,CV_32FC3,1.0/255.0);//BGR Range- 0.0 to 1.0

Mat mHsv_32;
cvtColor(mBGR_32, mHsv_32,COLOR_BGR2HSV);//HSV Range- 0.0 to 1.0
mHsv_32,COLOR_BGR2HSV);

32-Bit HSV Color Space Output Hue Range: 0 ≤ 360 Saturation Range: 0 ≤ 1.0 Value Range: 0 ≤ 1.0

vector<Mat> mHSV;
split(mInput_Hsv32,mHSV);
mHSV[0]*=(1.0/360.0);
merge(mHSV,mInput_Hsv32);

We need to scale the output!