/[gzz]/gzz/gfx/libcolor/spaces.py
ViewVC logotype

Diff of /gzz/gfx/libcolor/spaces.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.15 by tjl, Fri Feb 21 20:02:32 2003 UTC revision 1.16 by jvk, Sun Mar 9 10:39:16 2003 UTC
# Line 155  Wb = 0.072169 Line 155  Wb = 0.072169
155    
156  Wr,Wg,Wb = 0.3, 0.59, 0.11  Wr,Wg,Wb = 0.3, 0.59, 0.11
157    
158    # Gamma correction used with the perceptual non-linearity in YtoL and LtoY
159    # conversion functions.
160    #
161    gamma = 2
162    #
163    # Usually, the default display gamma of 1.0 actually yields an intensity
164    # exponent of 0.5 so gamma correction of 2.0 here should result in linear
165    # intensity. (The CIE L* computation assumes linear intensity).
166    
167  def YSTtoRGB(v):  def YSTtoRGB(v):
168      n = 1.0 / (Wr+Wg+Wb)      n = 1.0 / (Wr+Wg+Wb)
169      mat =  [ [n, n*(Wg+Wb), n*(Wb - Wg)  / math.sqrt(3) ],      mat =  [ [n, n*(Wg+Wb), n*(Wb - Wg)  / math.sqrt(3) ],
# Line 212  def YtoL(Y): Line 221  def YtoL(Y):
221      Y: luminance between 0 and 1      Y: luminance between 0 and 1
222      returns: lightness between 0 and 100      returns: lightness between 0 and 100
223      """      """
224        Y = Y**gamma
225      if Y <= (216./24389):      if Y <= (216./24389):
226          return Y * (24389./27)          return Y * (24389./27)
227      else:      else:
# Line 224  def LtoY(L): Line 234  def LtoY(L):
234      returns: luminance between 0 and 1      returns: luminance between 0 and 1
235      """      """
236      if L <= 8:      if L <= 8:
237          return L * (27./24389)          return pow(L * (27./24389), 1.0 / gamma)
238      else:      else:
239          return pow((L + 16.0) / 116, 3)          return pow((L + 16.0) / 116, 3.0 / gamma)

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26