Imagine a typical device gamut on CIE xy diagram:
x and y coordinates for primary colors (red, green and blue) is defined and known, how to calculate secondary colors (cyan, magenta and yellow)?
Photography Stack Exchange is a question and answer site for professional, enthusiast and amateur photographers. It only takes a minute to sign up.Sign up to join this community
Performing the operation directly using the chromaticity coordinates (ie: taking the midpoint between the two chromaticity coordinates) will yield incorrect results as the chromaticity diagram is highly non uniform.
Assuming you are using linear light values you could perform the following chain of computations:
Now this is likely more dedicated to SO but you could use colour to perform those computations:
% matplotlib inline import numpy as np import pylab import colour from colour.plotting import * # Conversion from RGB to chromaticity coordinates. # Defining RGB values for reference. RGB_r = np.array([1, 0, 0]) RGB_g = np.array([0, 1, 0]) # We assume they are encoded in *sRGB* colourspace. XYZ_r = colour.sRGB_to_XYZ(RGB_r, apply_EOCF=False) XYZ_g = colour.sRGB_to_XYZ(RGB_g, apply_EOCF=False) # Conversion to chromaticity coordinates. xy_r = colour.XYZ_to_xy(XYZ_r) print(xy_r) # [ 0.64 0.33] xy_g = colour.XYZ_to_xy(XYZ_g) print(xy_g) # [ 0.3 0.6] # Conversion to CIE xyY in order to maintain Luminance ratios. # Using sRGB Luminance ratios, second row of the NPM. xyY_r = [0.64, 0.33, colour.sRGB_COLOURSPACE.RGB_to_XYZ_matrix[1, 0]] xyY_g = [0.3, 0.6, colour.sRGB_COLOURSPACE.RGB_to_XYZ_matrix[1, 1]] xy_s = colour.XYZ_to_xy( colour.sRGB_to_XYZ( colour.XYZ_to_sRGB(colour.xyY_to_XYZ(xyY_r), apply_OECF=False) + colour.XYZ_to_sRGB(colour.xyY_to_XYZ(xyY_g), apply_OECF=False))) print(xy_s) # [ 0.41930366 0.50525886] # Plotting. RGB_colourspaces_CIE_1931_chromaticity_diagram_plot( ('sRGB', ), bounding_box=(-0.1, 0.9, -0.1, 0.9), standalone=False) pylab.plot(xy_r, xy_r, 'o', markersize=15, color=RGB_r) pylab.plot(xy_g, xy_g, 'o', markersize=15, color=RGB_g) pylab.plot(xy_s, xy_s, 'o', markersize=15, color=RGB_s)