RGB to XYZ
Given an RGB color whose components are in the nominal range [0.0, 1.0] and whose gamma is γ:

where, if the RGB system is not sRGB:

and if it is sRGB:

Implementation Notes:
- The transformation matrix [M] is calculated from the RGB reference primaries as discussed here.
- The gamma values for many common RGB color spaces may be found here.
- Your input RGB values may need to be scaled before using the above. For example, if your values are in the range [0, 255],
you must first divide each by 255.0.
- The output XYZ values are in the nominal range [0.0, 1.0].
- The XYZ values will be relative to the same reference white as the RGB system. If you want XYZ relative to a different
reference white, you must apply a chromatic adaptation transform to the XYZ color to convert
it from the reference white of the RGB system to the desired reference white.
- Sometimes the more complicated special case of sRGB shown above is replaced by a "simplified" version using a straight gamma function with γ = 2.2.