Skip to content

How to obtain XYZ from the RGB value for the display? #730

Answered by KelSolaar
chesschi asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @chesschi,

You could compute them as follows, there is the hidden assumption which is that the values are encoded in legal range:

import numpy as np
import colour

BT709 = colour.RGB_COLOURSPACES['ITU-R BT.709']

xyY = np.array([0.64, 0.33, 20]) / [1, 1, 100]
RGB = colour.XYZ_to_RGB(
    colour.xyY_to_XYZ(xyY),
    BT709.whitepoint,
    BT709.whitepoint,
    BT709.XYZ_to_RGB_matrix)
RGB_p = colour.oetf(RGB, method='ITU-R BT.709')
print(colour.full_to_legal(RGB_p, bit_depth=10, out_int=True))

# array([914,  64,  64])

I hope this helps! :)

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by KelSolaar
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #515 on January 16, 2021 22:51.