Next Previous Contents

Color correction for pnm2ppa

The pnm2ppa project team ppa-rpms@users.sourceforge.net

v0.6, October 28, 2000


Information and instructions for color correction of pnm2ppa color printing. http://sourceforge.net/projects/pnm2ppa (Updated for pnm2ppa-1.0 and later.)

Overview of Color correction.

Color Pixmap input to pnm2ppa (ppm format, produced by the ghostscript output devices ppmraw or ppm) specifies the color of a pixel as three coordinates (Red, Green, Blue) in the range 0-255. The program pnm2ppa converts these to relative amounts of Cyan, Magenta and Yellow ink drops printed on the page.

Color correction allows the user to attempt to match the printed colors to some reference colors, such as those displayed on the terminal, or those printed on a different printer, or those printed on the same printer with a different driver (such as the Win9x drivers supplied by HP with their PPA printers).

The color output from pnm2ppa can be controlled in two ways:

pnm2ppa will carry out "color correction", unless it is called with the --noGamma command line option. However, unless you set up a color correction scheme, the default color correction does not change any colors.

Color correction is specified by three color intensity functions (curves), one for each of Red, Green, and Blue. In their simplest form, these curves have a standard form controlled by a single "gamma" parameter such as GammaR. The more sophisticated correction, in the file pnm2ppa.gamma, specifies these curves more generally as a table of numbers that translate each possible color intensity value to a new value.

Note that, in principle, different color corrections are needed for different print quality settings, and for different brands and qualities of paper!

At present the methods for constructing a color correction for pnm2ppa are not very user-friendly. If you can improve them, please help!.

Color correction with "gamma" values in the configuration file.

The PixMap (ppa) format specifies colors by an intensity for each primary color, Red, Green and Blue, in the range 0-255, so (0,0,0) is black, and (255,255,255) is white. The standard color intensity enhancement function replaces the ppm intensity i of each primary color by Enh(i) which is the closest integer to ( i / 256) raised to the power Gamma, times 256.

You can specify the Gamma values in the configuration file as decimal numbers GammaR, GammaG, GammaB, but how do you find out what values to choose?. Perhaps by experimenting with changing the Gamma values.

A source of information on Gamma color correction is www.cgsd.com/papers/gamma.html

One method for constructing a Gamma correction has been built into pnm2ppa, but it wastes quite a lot of ink, and many users find it less effective than producing a customized color correction curve as described in the next section.

You must first use pnm2ppa to print a color test page, and then generate a file gamma.ppm to compare to it. To do this, type

pnm2ppa -g -i - -o /dev/lp0
(replace /dev/lp0 by whatever printer device your PPA printer uses, or use ... -o - | lpr -l , etc.). Note also that as pnm2ppa is not receiving any ghostscript input to tell it the paper size, this must be correctly specified by a configuration file entry or, e.g., a -s a4 option, if the default US Letter paper is not being used. This procedure will print a color calibration page.

The printed output is an array of sets of three colored bands, red, blue and green, each of which increases in brightness from left to right. The topmost set of bands should be referrred to as bands "0", the next ones as "1", etc.

Next, run the extra program calibrate_ppa which will produce a (large, 10MB) PixMap (ppm) file:

calibrate_ppa -g -o gamma.ppm
This will produce the PixMap file as gamma.ppm in the current directory.

To color-correct the printer so that its colors match those on the terminal screen, you should now attempt to view the file gamma.ppm using some application (such as the GNU image manipulation program gimp, or xv) that can view .ppm files. For each color, identify the printed band (0, 1, 2, ... etc) that most closely corresponds to the brightness profile shown on the screen. The default values are now:

RedGammaIdx 0
GreenGammaIdx 0
BlueGammaIdx 0
(i.e., no color correction). Enter your modified values for these in the pnm2ppa configuration file (usually /etc/pnm2ppa.conf).

The actual Gamma value is then 1.0 - 0.033*(Color)GammaIdx ;

To color-correct with respect to another printer (or the Win9x drivers), you must manage to print gamma.ppm on that other device, then make the comparison. (Or print the output of pnm2ppa -g on that device; the top line is the same uncorrected color data as gamma.ppm.)

Color correction using a "gamma file".

A "gamma correction file" is a binary file containing 3 x 256 numbers, which are lookup tables of corrected red green and blue color intensities.

The program pnm2ppa will use a default correction file /etc/pnm2ppa.gamma if it exists, unless the --noGamma option is used. The default correction file location can be changed by using the pnm2ppa option -F gammafile , where "gammafile" is the name (including the full path) of the gamma correction file to be used.

Currently, there are two available tools for constructing a gamma correction file:


Next Previous Contents