1 | initial version |
As StevenPuttemans suggest you can use applyColorMap,
Or in another way use HSV as color space , and use hue value for color range,
See an example,
cv::Mat hsv(200,180, CV_8UC3, cv::Scalar(0,0,0));
for(int x=0;x<hsv.cols;x++)
{
int h=x;
int s=255;
int v=255;
Scalar color;
color.val[0] = uchar(h);
color.val[1] = uchar(s);
color.val[2] = uchar(v);
hsv.col(x) = color;
}
Mat bgr;
cvtColor(hsv,bgr,CV_HSV2BGR);
imwrite("hsv.png",bgr);
2 | No.2 Revision |
As StevenPuttemans suggest you can use applyColorMap,
Or in another way use HSV as color space , and use hue value for color range,
See an example,
cv::Mat hsv(200,180, hsv(100,180, CV_8UC3, cv::Scalar(0,0,0));
for(int x=0;x<hsv.cols;x++)
{
int h=x;
int s=255;
int v=255;
Scalar color;
color.val[0] = uchar(h);
color.val[1] = uchar(s);
color.val[2] = uchar(v);
hsv.col(x) = color;
}
Mat bgr;
cvtColor(hsv,bgr,CV_HSV2BGR);
imwrite("hsv.png",bgr);