imagecolorsgraphicsgamut

How can I approximate the P3-RGB value 555nm-looking light


There are common methods for srgb but I couldn't find one for P3


Solution

  • Just a short answer. I've no time for full details, but it may gives you inputs to do proper calculations.

    You said: approximate, so I would go in Wikipedia and look e.g. colour space, where you can find classical chromaticity diagram, in such case: Chromaticity diagram

    The outer line are the spectral colours (+ the line of purples on bottom). If you look, the spectral line has blue numbers, that are the wavelength (in nm), so you can estimate where 555 is and find the coordinates of CIE xy (often we use the missing coordinate as Brightness, but on border of gamut you must take what you get).

    Now you get the chromaticity you want to reproduce. So let's check (also in Wikipedia) the data of Display-P3 (which I think it is a derivation of DCI-P3), so https://en.wikipedia.org/wiki/DCI-P3

    You get the chromaticities of the 3 primaries of P3, and white point. Now it is up to you to find the point on the line between green and red which approximate with the desired x,y. Usually two methods are used: one is the nearest point (so perpendicular point), the second is the point which intersect the line which pass from your point with white point, and the line red-green. Of just look chromaticity diagram of P3 (maybe in gamut page or googling), and visually you select a x,y coordinate.

    Now things get more complex (because I think someone refactor Wikipedia pages). We have x,y and we want R,G,B in Display-P3. Often we work with intermediate colour space XYZ (which you should find transformation from/to all colour spaces). E.g. https://en.wikipedia.org/wiki/CIE_1931_color_space#CIE_xy_chromaticity_diagram_and_the_CIE_xyY_color_space you know hot to convert to X,Y,Z Select Y (brightness) as 1 or 255 (as you prefer). Later we will scale so that no R,G,B values are above 255 (so maximum brightness for a chromaticity).

    What I do not find quickly it is how to convert XYZ to R,G,B in Display-P3 but you should find the data, or just the general conversion with R,G,B (with primary chromaticities given as parameter). Just remember in such step that we worked in linear space, so you need to apply gamma (and possibly scale values before that: same scale value for the 3 channels and always on linear space else hue will change).

    Note: and thinking again, possibly it is an overkill (but colour libraries should have functions for all steps, but maybe the wavelength chromaticity)

    Note 2: but the thinking again gave me a better solution: go to CIE standard observer (1931), and you can download the CIE-RGB data per wavelength (raw data of experiment and interpolation. You have negative values, but it is ok. So how you just linear transform from one RGB to an other RGB colour space, and apply gamma.