我試圖在OpenCV 3.2中創建材質的直方圖,但被HSV範圍弄糊塗 - 它們似乎與文檔不匹配,或者我接近錯誤。OpenCV cvtColor CV_BGR2HSV CV_32FC3飽和度範圍
// cv::Mat bgrPhoto contains a test image
cv::Mat3f hsvPhoto;
bgrPhoto.convertTo(hsvPhoto, CV_32FC3);
cv::cvtColor(hsvPhoto, hsvPhoto, CV_BGR2HSV, CV_32FC3);
std::vector<cv::Mat1f> hsvChannels;
cv::split(hsvPhoto, hsvChannels);
// Documentation [0.0, 1.0]: measured here Hue to 360.0, Sat to 1.0, Val to 255.0
double minHue, maxHue, minSat, maxSat, minVal, maxVal;
cv::minMaxIdx(hsvChannels[0], &minHue, &maxHue, 0, 0);
cv::minMaxIdx(hsvChannels[1], &minSat, &maxSat, 0, 0);
cv::minMaxIdx(hsvChannels[2], &minVal, &maxVal, 0, 0);
OpenCV存儲來自[0 - 255]的[0 - 180],'S'和'V'值的'H'通道值。對於'float',相應地轉換值。 – zindarod
H [0,360],S,V in [0,1]。請參閱[文檔](http://docs.opencv.org/master/de/d25/imgproc_color_conversions.html#color_convert_rgb_hsv)。此外,您正在嘗試使用21(CV_32FC3評估爲21)目標通道創建輸出圖像。只需使用'cv :: cvtColor(hsvPhoto,hsvPhoto,CV_BGR2HSV);'。另外'bgrPhoto.convertTo(hsvPhoto,CV_32F);'因爲只需要指定類型而不是深度。 – Miki