RGB与HSV 互转

一、RGB转化到HSV的算法:
max=max(R,G,B);
min=min(R,G,B);
V=max(R,G,B);
S=(max-min)/max;
HSV颜色空间模型(圆锥模型)HSV颜色空间模型(圆锥模型)[2]
if (R = max) H =(G-B)/(max-min)* 60
if (G = max) H = 120+(B-R)/(max-min)* 60
if (B = maxH = 240 +(R-G)/(max-min)* 60
if (H < 0H = H+ 360

二、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;
阅读更多
个人分类: ISP图像处理
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭