Home / Alt manpages / ppmcie(1)

  • ppmcie(1)
  • User command
  • linux

Draw a CIE Colour Chart with ppmcie

ppmcie draws the CIE colour tongue as a PPM image, the horseshoe-shaped chart that shows every hue the human eye can distinguish. It writes to standard output, so you always redirect it, and it defaults to a Rec. 709 gamut you can swap for NTSC, PAL, HDTV or your own custom primaries. Allow about ten minutes for a first chart and its checks.

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.

1. Check the executable

command -v ppmcie
ppmcie --version

On the checked installation, the second command reports that it is using libnetpbm version 11.5.2. --version is accepted as a common Netpbm option even though the main ppmcie(1) synopsis documents only the chart-specific options.

Checkpoint

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.

2. Create the standard chart

mkdir -p "$HOME/pictures/cie"
ppmcie > "$HOME/pictures/cie/rec709-xy.ppm"
  • No output filename option. The shell redirection is what creates the file.
  • Binary output. The command produces a binary PPM, so do not open it in a text editor.

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 marks the selected system's gamut: colours outside it are approximations unless you use a device that understands the alternate colour values described below.

3. 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 stretches when width and height differ, so use equal values when geometric proportions matter.

-size 1024 sets both dimensions at once; it is equivalent to -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.

4. Compare standard colour systems

Rec. 709 is the default and 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 uses the NTSC primaries.
  • -smpte uses the cited SMPTE recommendations.
  • -hdtv uses the wider HDTV ideal primaries.
  • -cie uses the largest possible gamut within the chart.

Each name describes the colour system used for the plot, not a conversion of the image into a universally compatible colour space.

Warning

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.

5. 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.

6. Reduce visual clutter

Use these switches when the annotations are distracting or 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.
  • -noaxes omits the axes.

None of these make the image colour-managed or remove the gamut limitation.

By default, colours outside the selected Maxwell triangle are substituted with a representable approximation and dimmed to three-quarters brightness. Add -full to plot the whole tongue at full brightness:

ppmcie -full -size 512 > "$HOME/pictures/cie/full-brightness.ppm"

Use this deliberately: it removes the visual cue that distinguishes the selected gamut from the rest of the tongue, so a reader comparing charts needs to know whether -full was used.

Common traps

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 stays in place if ppmcie fails.

Recovery

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, then generate a plain Rec. 709 chart for a conventional 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

  • Installed and confirmed: ppmcie is installed and reports the expected Netpbm version.
  • File written safely: a redirected command has created a PPM file without elevated privileges.
  • Dimensions checked: pnmfile confirms the intended size.
  • Choices recorded: you noted whether the chart uses x y or u' v', which colour system was selected, and whether -full changed the brightness convention.
  • Gamut understood: you know that default Rec. 709 output is safe for an ordinary PPM viewer, while other systems produce pseudo-PPM output.