I’ve done some work on this. For a particular photo of a tree from a Nikon D800, using the raw .NEF file, the xy diagram showing white where any pixel is that chromaticity, is:
The circles show the sRGB primaries and white point. Some chromaticities are outside the triangle of primaries, and a few are outside the horseshoe.
Telling dcraw to make an sRGB image, then converting that to xyY gives the following diagram:
dcraw has heavily reduced chroma (roughly speaking, “saturation”), and has changed some hues.
Instead of using dcraw’s sRGB conversion, we do some tweaking on chromaticities, and we get this…
… which is closer to the original xyY chart, and contained within the sRGB primaries, but has some clipping.
The tweaking is done by these Windows BAT commands:
set INPRIM=0.56,0.44,0.35,0.65,0.08,0.06
set OUTPRIM=0.56,0.44,0.35,0.65,0.12,0.07
%IMDEV%convert ^
cbc_xyy.miff ^
-set colorspace xyY ^
-process 'barymap channels xyY inPrim %INPRIM% gain 0.85 outPrim %OUTPRIM% v' ^
-process 'barymap channels xyY ign inPrim sRGB clampBarycentric outPrim sRGB v' ^
-depth 32 ^
-define quantum:format=floating-point ^
cbc_tx9.miff
I chose those numbers manually. Further automation is possible.
More detail is at Colours as barycentric coordinates. I haven’t yet published the source code for “barymap”.