正在加载图片...
图2-02HSV颜色空间 自从HSV颜色空间出现之后,已经出现了几种大同小异的RGB和HSV颜色空间之间 的转换算法,它们之间没有转换矩阵,但可对算法进行描述。这两个颜色空间之间的转换算 法和程序在因特网上可以找到,本节引用的算法引自: http://www.realtime.ru/wwwboard/messages/120.html 本节引用的程序引自 http:/www.cisksu.edu/-seteam20/ 1.RGB到HSV的转换 (1)RGB→HSV( Travis)算法描述 Given RGB values. find the max and min in)/ nax Ifs=0.h is undefined RI=(max-R)/(max-min) Bl=(max-B)/(max-min ifr= max and g= min. h=5+B1 else ifR= max and g not= min, H=l-Gl else ifG= max and B= min, H=RI+1 else ifG= max and B notman, h=3-BI else ifR= max H=3+GI else=5-RI H=H 60 (converts to degrees so S and V lie between 0 and 1, H between 0 and 360) (2)RGB→HSⅤ Foley and vanDam)算法描述 of rgB min= minimum of rgb S=(max-min)/max if s =o.h is undefined else delta max-min 77 图 2-02 HSV 颜色空间 自从 HSV 颜色空间出现之后,已经出现了几种大同小异的 RGB 和 HSV 颜色空间之间 的转换算法,它们之间没有转换矩阵,但可对算法进行描述。这两个颜色空间之间的转换算 法和程序在因特网上可以找到,本节引用的算法引自: http://www.realtime.ru/wwwboard/messages/120.html 本节引用的程序引自: http://www.cis.ksu.edu/~seteam20/ 1. RGB 到 HSV 的转换 (1) RGB→HSV (Travis)算法描述 Given RGB values, find the max and min. V = max S = (max-min) / max If S = 0, H is undefined else R1 = (max-R) / (max-min) G1 = (max-G) / (max-min) B1 = (max-B) / (max-min) if R = max and G = min, H = 5 + B1 else if R = max and G not= min, H = 1 - G1 else if G = max and B = min, H = R1 + 1 else if G = max and B not=main, H = 3 - B1 else if R = max, H = 3 + G1 else H = 5 - R1 H = H*60 (converts to degrees so S and V lie between 0 and 1, H between 0 and 360) (2) RGB→HSV(Foley and VanDam)算法描述 max = maximum of RGB min = minimum of RGB V = max S = (max - min) / max if S = 0, H is undefined, else delta = max-min
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有