Draw a Reproducible CIE Colour Chart with ppmcie
You will generate a PPM image of the CIE colour tongue, inspect its dimensions, and choose whether the chart uses CIE 1931 x y or 1976 u' v' coordinates. The command writes the image to standard output, so redirect it to a new file. Allow about ten minutes for a first chart and its checks.
The route
Jump straight to the step you need, or tick off Done means at the end.
Before you start
You need a Linux system with the netpbm package installed and enough disk space for the image. No elevated privileges are required because the examples write below your home directory. This guide was checked with Netpbm 11.5.2, installed as Debian package netpbm 2:11.05.02-1.1build1. The manual page installed with that package is dated 31 July 2005, so version-specific details here describe the command available on this machine.
Check the executable before doing any work:
command -v ppmcie
ppmcie --version
On the checked installation, the second command reports that it is using libnetpbm version 11.5.2. The option is accepted as a common Netpbm option even though the main ppmcie(1) synopsis documents the chart-specific options.
Checkpoint: create the standard chart
The simplest useful invocation is the default chart. It selects the Rec. 709 colour system, plots CIE 1931 x y chromaticities, and produces a 512 by 512 image:
mkdir -p "$HOME/pictures/cie"
ppmcie > "$HOME/pictures/cie/rec709-xy.ppm"
ppmcie does not take an output filename. The shell redirection is what creates the file. The command produces a binary PPM, so do not use a text editor to inspect it.
Verify the result with Netpbm's file inspector:
pnmfile "$HOME/pictures/cie/rec709-xy.ppm"
Expected output is equivalent to:
/home/you/pictures/cie/rec709-xy.ppm: Netpbm image data, size = 512 x 512, rawbits, pixmap
The chart includes axes, labels, the selected system's Maxwell triangle, its white point, a black-body curve and wavelength markings. The triangle indicates the selected system's gamut. Colours outside it are approximations unless you are using a device that understands the alternate colour values described below.
Choose the coordinate system and size
CIE 1931 x y coordinates are the default. Use -upvp for CIE 1976 u' v' coordinates, where equal distances correspond more closely to visual colour discrimination:
ppmcie -upvp -width 800 -height 600 > "$HOME/pictures/cie/rec709-upvp-800x600.ppm"
pnmfile "$HOME/pictures/cie/rec709-upvp-800x600.ppm"
Expected output includes size = 800 x 600. The chart is stretched when width and height differ, so use equal values when geometric proportions matter.
-size 1024 sets both dimensions at once. The equivalent separate options are -width 1024 -height 1024. For a quick preview, use a smaller image:
ppmcie -size 256 > "$HOME/pictures/cie/preview.ppm"
pnmfile "$HOME/pictures/cie/preview.ppm"
Do not confuse output size with colour depth. These options change pixel dimensions only; the generated PPM still has a maximum sample value of 255.
Checkpoint: compare standard colour systems
Rec. 709 is the default and is the only built-in choice whose output is a true PPM image according to the manual. You can select other standard primary sets for comparison:
for system in rec709 ebu hdtv ntsc smpte cie; do
ppmcie -$system -size 512 > "$HOME/pictures/cie/$system.ppm" || exit $?
done
pnmfile "$HOME/pictures/cie"/*.ppm
-ebu represents PAL and SECAM primaries, -ntsc the NTSC primaries, -smpte the cited SMPTE recommendations, -hdtv the wider HDTV ideal primaries, and -cie the largest possible gamut within the chart. The names describe the colour system used for the plot, not a conversion of the image into a universally compatible colour space.
This is the most common trap with ppmcie: output from these alternatives is pseudo-PPM. A normal PPM viewer expects gamma-corrected, positive ITU-R BT.709 samples and will display the colours incorrectly when given one of these variations. Use the default -rec709 output when you need an ordinary PPM image for a normal viewer.
Use custom primary coordinates
For a custom colour system, provide the CIE x and y coordinates for red, green, blue and white. Supplying any of these options selects a custom system, so provide all four sets for an unambiguous chart:
ppmcie \
-red 0.64 0.33 \
-green 0.30 0.60 \
-blue 0.15 0.06 \
-white 0.3127 0.3290 \
-size 512 \
> "$HOME/pictures/cie/custom.ppm"
pnmfile "$HOME/pictures/cie/custom.ppm"
The command still creates a 512 by 512 PPM-shaped file, but the samples describe the custom system rather than necessarily being valid BT.709 display data. Record the coordinates alongside the file if the chart is going into a report or test fixture.
Reduce visual clutter without changing the chart data
Use these switches when the annotations are distracting or when you need a clean plot for another tool:
ppmcie -size 512 -noblack -nowpoint -nolabel -noaxes \
> "$HOME/pictures/cie/clean.ppm"
-noblack omits the black-body curve, -nowpoint omits the white-point marker, -nolabel omits the label, and -noaxes omits the axes. These options do not make the image colour-managed or remove the gamut limitation.
By default, colours outside the selected Maxwell triangle are dimmed to three-quarters brightness after being substituted with a representable approximation. Add -full to plot the whole tongue at full brightness:
ppmcie -full -size 512 > "$HOME/pictures/cie/full-brightness.ppm"
Use this deliberately. It changes the visual convention that distinguishes the selected gamut from the rest of the tongue, so a reader comparing charts needs to know whether -full was used.
Common failures and safe recovery
If pnmfile reports a missing or invalid image, inspect the redirection path and run the command again. A failed shell pipeline can leave a partial file, so write to a temporary name when replacing an existing chart:
ppmcie -size 1024 > "$HOME/pictures/cie/rec709-xy.ppm.new" && \
mv "$HOME/pictures/cie/rec709-xy.ppm.new" "$HOME/pictures/cie/rec709-xy.ppm"
pnmfile "$HOME/pictures/cie/rec709-xy.ppm"
The original remains in place if ppmcie fails. If the replacement fails validation, remove only the temporary file with rm -- "$HOME/pictures/cie/rec709-xy.ppm.new". That deletion is irreversible, so check the pathname before running it. No command in this guide needs sudo.
If a viewer shows strange colours, check whether you used -ebu, -hdtv, -ntsc, -smpte, -cie or custom coordinates. Generate a plain Rec. 709 chart again for a conventional PPM viewer. If a later Netpbm tool needs a mapped palette, the manual points to pnmquant or ppmdither; those are separate conversions and can discard colour detail.
Done means
ppmcieis installed and reports the expected Netpbm version.- A redirected command has created a PPM file without elevated privileges.
pnmfileconfirms the intended dimensions.- You recorded whether the chart uses
x yoru' v', which colour system was selected, and whether-fullchanged the brightness convention. - You know that default Rec. 709 output is the safe choice for an ordinary PPM viewer, while other systems produce pseudo-PPM output.