Created
April 5, 2013 12:40
-
-
Save aleroddepaz/5318999 to your computer and use it in GitHub Desktop.
Script to convert RGB color to CIE color space
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def rgb_to_xy(r, g, b): | |
X = 0.412453 * r + 0.357580 * g + 0.180423 * b | |
Y = 0.212671 * r + 0.715160 * g + 0.072169 * b | |
Z = 0.019334 * r + 0.119193 * g + 0.950227 * b | |
x = X / (X+Y+Z) | |
y = Y / (X+Y+Z) | |
return x, y | |
if __name__ == '__main__': | |
if len(sys.argv) != 4: | |
print "Incorrect number of parameters.\nUsage: %s r g b" % sys.argv[0] | |
sys.exit(1) | |
r, g, b = map(float, sys.argv[1:4]) | |
print rgb_to_xy(r, g, b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment