Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save KelSolaar/451666b9060b70a71d20 to your computer and use it in GitHub Desktop.
Save KelSolaar/451666b9060b70a71d20 to your computer and use it in GitHub Desktop.
Secondary Chromaticity Coordinates Computation
P = np.array(
[[0.6650, 0.3220],
[0.2950, 0.6070],
[0.1500, 0.0600]])
W = np.array([0.3127, 0.3290])
NPM = colour.normalised_primary_matrix(P, W)
NPM_i = np.linalg.inv(NPM)
R = np.ravel(NPM)[3:6] # This is the Luminance ratios.
print(R)
# [ 0.20076008 0.72604503 0.07319489]
xyY_red = np.hstack((P[0], R[0]))
print(xyY_red)
# [ 0.66500000 0.32200000 0.20076008]
xyY_green = np.hstack((P[1], R[1]))
print(xyY_green)
# [ 0.29500000 0.60700000 0.72604503]
RGB_red = colour.XYZ_to_RGB(colour.xyY_to_XYZ(xyY_red),
W,
W,
XYZ_to_RGB_matrix=NPM_i)
RGB_green = colour.XYZ_to_RGB(colour.xyY_to_XYZ(xyY_green),
W,
W,
XYZ_to_RGB_matrix=NPM_i)
xy_yellow = colour.XYZ_to_xy(
colour.RGB_to_XYZ(RGB_red + RGB_green,
W,
W,
NPM))
print(xy_yellow)
# [ 0.42177907 0.50934585]
# Spreadsheet: 0,4218 0,5093
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment