1.openCV中经常将RGB图像转换成HSV图像然后进行颜色的辨别和处理
我们能够查到一般HSV的范围是
H: [0,360]
S: [0,100]
V: [0,100]
但是在openCV中,HSV的范围却是
H: [0,180]
S: [0,255]
V: [0,255]
那是因为openCV做了如下的变换
h= H/2;
s = (float)S/100*255;
v = (float)v/100*255;
所以在openCV中
一般颜色的HSV分布如下:
image.png
如果要对应正常的HSV,那么
h要 x2
s要 /2.55
v要 /2.55
===========================
2.互相转换:
1、RGB转化到HSV的算法:
max=max(R,G,B)
min=min(R,G,B)
V=max(R,G,B)
S=(max-min)/max
ifR = max,H =(G-B)/(max-min)* 60
ifG = max,H = 120+(B-R)/(max-min)* 60
ifB = max,H = 240 +(R-G)/(max-min)* 60
ifH < 0,H = H+ 360
2、HSV转化到RGB的算法:
if s = 0
R=G=B=V
else
H /= 60;
i = INTEGER(H)
f = H - i
a = V * ( 1 - s )
b = V * ( 1 - s * f )
c = V * ( 1 - s * (1 - f ) )
switch(i)
case 0: R = V; G = c; B = a;
case 1: R = b; G = v; B = a;
case 2: R = a; G = v; B = c;
case 3: R = a; G = b; B = v;
case 4: R = c; G = a; B = v;
case 5: R = v; G = a; B = b;
3.转换工具
https://c.runoob.com/front-end/868
4.颜色对照表一级颜色的英文名称
https://tool.oschina.net/commons?type=3
颜色中文分类以及颜色范围
https://www.baishitou.cn/webcolor/colorlist.html
5.颜色调节工具