Created
February 13, 2015 09:38
-
-
Save KelSolaar/b003ff2e631f18f2cb6e to your computer and use it in GitHub Desktop.
Colour - Computing Adapted Colourspace Primaries
This file contains hidden or 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 numpy as np | |
import colour | |
P_R = np.array([0.64, 0.33]) | |
P_G = np.array([0.30, 0.60]) | |
P_B = np.array([0.15, 0.06]) | |
D65 = colour.xy_to_XYZ(colour.ILLUMINANTS['cie_2_1931']['D65']) | |
D50 = colour.xy_to_XYZ(colour.ILLUMINANTS['cie_2_1931']['D50']) | |
CAT = 'Bradford' | |
XYZ_R = colour.xy_to_XYZ(P_R) | |
XYZ_G = colour.xy_to_XYZ(P_G) | |
XYZ_B = colour.xy_to_XYZ(P_B) | |
M = np.vstack([XYZ_R, XYZ_G, XYZ_B]) | |
Y = np.dot(np.transpose(np.linalg.inv(M)), D65) | |
XYZ_Rn = colour.xyY_to_XYZ(np.append(P_R, Y[0])) | |
XYZ_Gn = colour.xyY_to_XYZ(np.append(P_G, Y[1])) | |
XYZ_Bn = colour.xyY_to_XYZ(np.append(P_B, Y[2])) | |
R = colour.chromatic_adaptation_VonKries(XYZ_Rn, D65, D50, CAT) | |
G = colour.chromatic_adaptation_VonKries(XYZ_Gn, D65, D50, CAT) | |
B = colour.chromatic_adaptation_VonKries(XYZ_Bn, D65, D50, CAT) | |
P_a = np.vstack((R, G, B)) | |
print(P_a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment