# Determining input color space primaries from spectrum data

If I have an output device, for which I have a known spectrum data for each of it's primaries, I should be able to calculate the CIEXYZ of its primaries using using the integral equations together with the CIE color matching functions. I can then calculate its respective CIExyY values, which for output device are always inside the boundary if the xyY spectral locus - the chromaticity diagram.

My question relates to calculating xyY of primaries of input device.

Suppose I have a known spectrum data for the primaries of some input device - be it a digital scanner or a digital camera or any other input device. It's color filters are not perfect, this means that even a pure spectrum color is represented as non-zero values in its own RGB color space. That means that (if I'm correct) that the whole chromaticity diagram should lie inside of the device RGB color space, and it's primaries lie outside of the diagram and be represented by imaginary colors.

How do I calculate those imaginary primaries for the input device given known spectrum for its primaries? If I'm not mistaken, I cannot simply use the integral formula, because that seems to be only for output devices and the resulting primaries would lie in the locus.

I vaguely understand your question, so this response should be taken more of a long comment rather than an answer.

If I have an output device, for which I have a known spectrum data for each of it's primaries, I should be able to calculate the CIEXYZ of its primaries using using the integral equations together with the CIE color matching functions. I can then calculate its respective CIExyY values, which for output device are always inside the boundary if the xyY spectral locus - the chromaticity diagram.

This is correct in general but note that reference CIE spectral power distribtions are defined for a standard observer.

The term input primaries is a little vague, are you refering to the spd of the light source inside the input device or the combined result produced by the object's spectral reflectance factor (also an spd) multiplied by the spd of the light source of the input device ? If you know the spectral reflectance factor of the object and the color matching function and the resulting trichromatic value, you should be able to express the spd of the light source as a vector equation something like: $$x_1 \begin{matrix}a_1 \\ a_2 \\ \vdots \\ a_{\lambda}\end{matrix}+x_2 \begin{matrix}a_1 \\ a_2 \\ \vdots \\ a_{\lambda}\end{matrix}+...+x_{\lambda} \begin{matrix}a_1 \\ a_2 \\ \vdots \\ a_{\lambda}\end{matrix} = \begin{matrix}b_1 \\ b_2 \\ \vdots \\ b_{\lambda}\end{matrix}$$ where $$x$$ is from your light source spd and the others are obtained from the remaining (you can for example distribute trichromatic value uniformly to $$b$$ vector, and fill $$a$$'s with zeros for non corresponding wave lengths and use the multiplied value for the corresponding wave length), but this is more or less an educated guess rather than a tested solution. Notice that the expression is a linear system which might help you finding a solution.

This is an interesting question. I have wondered this myself in respect to the three cones of the human eye, which are primaries of an input space in the same way. How do you represent the “colours” of those cones? They are typically referred to as red, green, and blue, though the peak sensitivities lie closer to yellow, yellow-green and blue-violet. As you point out in the question, taking an integral of the response curve would be an interesting illustration, but it would not be accurate.

For cone responses it is possible to convert LMS values of (1, 0, 0), (0, 1, 0) and (0, 0, 1) to the corresponding XYZ tristimulus values, and then calculate the xy chromaticities of those values, which as you say would be imaginary chromaticity values. I think the triangle connecting these imaginary chromaticity values would necessarily contain all the real chromaticity values.

Strictly speaking the CIE 1931 xy chromaticity chart is determined by the shape of the LMS response curves. The distinctive shape of the chart depends on how the response curves overlap. If there was no overlap between the response curves then the chart would be a perfect triangle, with the chromaticity of each response curve each at one of the points of the triangle. I think this means that for different input primaries you would strictly need a different chromaticity chart. One set of tristimulus XYZ values would correspond with a range of different spectral power distributions, or technically metamers. With different input primaries you could not be sure that the same range of spectral power distributions would still resolve to a single set of input primary responses. I think this means that you cannot get exact CIE 1931 xy chromaticity values from the response curve of the input values, as there would not be an exact one-to-one conversion between the different versions of chromaticity.

I think there would still be a way of getting a good approximation. For digital cameras and digital scanners it seems likely that the input primaries working in combination are equivalent to the LMS response curves, as otherwise the device would not produce a good likeness of the original colours. I would suggest picking three widely spaced colours with known spectral power distribution which are within gamut (e.g. typical R, G and B video screen phosphors), and calculating the response values for the input primaries of your device and the tristimulus XYZ values of those colours. From these values it should be possible to calculate the matrix required to convert from the responses of the input primaries to XYZ and vice versa. Then if you calculate the imaginary RGB values of the input primaries you can convert them to XYZ values and on to xy chromaticity values.

There might also be a way of calculating an approximate conversion matrix between the device input primaries and LMS by comparing the input primary response curves and the LMS response curves, but I do not know what would be the best way of doing this.