Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. print ('Color S RGB  to Linear RFB')
  2. print ()
  3.  
  4.  
  5.  
  6. def s2lin(x):
  7.  a = 0.055
  8.  if x <=0.04045 :
  9.   y = x * (1.0 / 12.92)
  10.  else:
  11.   y = pow( (x + a) * (1.0 / (1 + a)), 2.4)
  12.  return y
  13.  
  14. x = 0.1
  15.  
  16. z = s2lin(x)
  17.  
  18. print ('x =', x, 'z =',z)
  19. print ()
  20.  
  21. print ('Linear RGB  to   S RGB')
  22. print ()
  23.  
  24. def lin2s(x):
  25.  a = 0.055
  26.  if x <=0.0031308:
  27.   y = x * 12.92
  28.  else:
  29.   y = (1 + a) * pow(x, 1 / 2.4) - a
  30.  return y
  31.  
  32. x = 0.1
  33.  
  34. z = lin2s(x)
  35.  
  36. print ('x =', x, 'z =',z)
  37.  
  38. print ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement