55 rgb_to_abc(r, g, b) --> a, b, c
66 abc_to_rgb(a, b, c) --> r, g, b
77
8- All inputs and outputs are triples of floats in the range [0.0...1.0].
9- Inputs outside this range may cause exceptions or invalid outputs.
8+ All inputs and outputs are triples of floats in the range [0.0...1.0]
9+ (with the exception of I and Q, which covers a slightly larger range).
10+ Inputs outside the valid range may cause exceptions or invalid outputs.
1011
1112Supported color systems:
1213RGB: Red, Green, Blue components
13- YIQ: used by composite video signals
14+ YIQ: Luminance, Chrominance ( used by composite video signals)
1415HLS: Hue, Luminance, Saturation
1516HSV: Hue, Saturation, Value
1617"""
18+
1719# References:
18- # XXX Where's the literature?
20+ # http://en.wikipedia.org/wiki/YIQ
21+ # http://en.wikipedia.org/wiki/HLS_color_space
22+ # http://en.wikipedia.org/wiki/HSV_color_space
1923
2024__all__ = ["rgb_to_yiq" ,"yiq_to_rgb" ,"rgb_to_hls" ,"hls_to_rgb" ,
2125 "rgb_to_hsv" ,"hsv_to_rgb" ]
2630ONE_SIXTH = 1.0 / 6.0
2731TWO_THIRD = 2.0 / 3.0
2832
29-
3033# YIQ: used by composite video signals (linear combinations of RGB)
3134# Y: perceived grey level (0.0 == black, 1.0 == white)
3235# I, Q: color components
@@ -50,10 +53,10 @@ def yiq_to_rgb(y, i, q):
5053 return (r , g , b )
5154
5255
53- # HLS: Hue, Luminance, S???
56+ # HLS: Hue, Luminance, Saturation
5457# H: position in the spectrum
55- # L: ???
56- # S: ???
58+ # L: color lightness
59+ # S: color saturation
5760
5861def rgb_to_hls (r , g , b ):
5962 maxc = max (r , g , b )
@@ -87,10 +90,10 @@ def _v(m1, m2, hue):
8790 return m1
8891
8992
90- # HSV: Hue, Saturation, Value(?)
93+ # HSV: Hue, Saturation, Value
9194# H: position in the spectrum
92- # S: ???
93- # V: ???
95+ # S: color saturation ("purity")
96+ # V: color brightness
9497
9598def rgb_to_hsv (r , g , b ):
9699 maxc = max (r , g , b )
0 commit comments