2

这是我的标记

使用cvInRangeS(hsvframe,cvScalar(90, 40, 50)and cvScalar(255, 90, 255),threshy),如何获得每种颜色(紫色和黄色)的准确值范围?

4

2 回答 2

1

使用颜色选择器网站检查它们的色调值。

http://www.color-hex.com/color/eca314

http://www.color-hex.com/color/923ca7

请注意,您需要在 (0-255) 范围内转换色相角 (0-360)。对两种颜色都使用 inranges 函数并添加图像:

cvInRangeS(hsvframe,cvScalar(20, 0, 0), cvScalar(30, 255, 255),threshorange);
cvInRangeS(hsvframe,cvScalar(200, 0, 0), cvScalar(210, 255, 255),threshpurple);
cvOr(threshorange, threshpurple, threshy);
于 2013-07-04T17:54:46.360 回答
1

你可能想试试这个:

Mat matSrcCopyForHSVColorDisplay, HSV_image_display;

//Make a copy of the original image
matSrcCopyForHSVColorDisplay = matSrc.clone(); 

//Convert RGB to HSV
cvtColor(matSrc, HSV_image_display, CV_BGR2HSV); 

//To access each pixel in the images we are using this syntax:
//image.at(y,x)[c] where y is the row, x is the column 
//and c is H, S or V (0, 1 or 2)
Vec3b p = HSV_image_display.at<Vec3b>(50, 10); //Vec3b - Array of 3 uchar numbers

//p[0] - H, p[1] - S, p[2] - V
printf(text, "H=%d, S=%d, V=%d", p[0], p[1], p[2]); 

//putText(matSrcCopyForHSVColorDisplay, text, Font_Position, 
//Font_Type, Font_Scale, Font_Colour, Font_Thickness); 
//Display the text
putText(matSrcCopyForHSVColorDisplay, text, center, 
        FONT_HERSHEY_COMPLEX_SMALL, 2, cvScalar(255, 0, 0), 1, CV_AA);

//Refresh the image
imshow("HSV Value", matSrcCopyForHSVColorDisplay); 
printf("H=%d, S=%d, V=%d\n", p[0], p[1], p[2]);
于 2015-06-02T13:46:38.310 回答