pnmgamma {
-bt709tolinear |
-lineartobt709 |
-bt709tosrgb |
-srgbtobt709 } [-gamma=float] [-rgamma=float] [-ggamma=float]


pnmgamma [
-bt709ramp |
-srgbramp ] [-ungamma] [{gamma | redgamma greengamma bluegamma} [pnm-

This program is part of Netpbm.

Pnmgamma performs gamma adjustment on pseudo-PNM images.

The PPM format specification specifies that certain sample values in a
file represent certain light intensities in an image. In particular,
they specify that the sample values are directly proportional to lumi-
nance as defined by ITU-R Recommendation BT.709. BT.709 luminance as
a function of radiance is a power function modified with a linear ramp
near black.

However, people sometimes work with approximations of PPM and PGM
where the sample values represent intensity in different ways:

In one common variation, the sample value is directly proportional to
radiance (often called 'linear intensity').

Another popular variation is to make the samples proportional to lumi-
nance as defined by the Internation Electrotechnical Commission (IEC)
SRGB standard. The SRGB gamma transfer function is like the BT.709
one except with different constants in it.

Note that SRGB is often spelled 'sRGB'. In this document, we use
standard English typography, though, which doesn't allow for that kind
of capitalization.

pnmgamma allows you to manipulate the gamma transfer function, thus
working with and/or creating pseudo-PPM files that are useful for var-
ious things.

For example, if you feed a true PPM to pnmgamma -bt709tolinear , you
get as output a file which is PPM in every respect except that the
sample values are radiances. If you feed such a file to pnmgamma
-linearto709, you get back a true PPM.

The situation for PGM images is analogous. And pnmgamma treats PBM
images as PGM images.

When you feed a radiance-proportional pseudo-PPM image to a display
program that expects a true PPM, the display appears darker than it
should, so pnmgamma has the effect of lightening the image. When you
feed a true PPM to a display program that expects radiance-propor-
tional sample values, and therefore does a gamma adjustment of its own
on them, the display appears lighter than it should, so pnmgamma with
a gamma value less than one (the multiplicative inverse of whatever
gamma value the display program uses) has the effect of darkening the

The form of the parameters depends on whether you're using the old
syntax or the new syntax. With the old syntax, the parameters are a
mixture of gamma values and the input file name. With the new syntax,
the only parameter is the input file name and you specify gamma values
with option.

You use the old syntax if you specify -bt709ramp (or its synonym
-cieramp) or -srgramp or if you don't specify any transfer function at
all (and thus default to a simple exponential). Otherwise, you use
the new syntax.

With the old syntax, you may specify a single gamma value or 3 sepa-
rate gamma values (red, green, and blue) or no gamma values. In any
case, the meanings of those parameters is the same as the more modern
-gamma, -rgamma, -ggamma, and -bgamma options described below.














A good explanation of gamma is in Charles Poynton's Gamma FAQ at and Color FAQ at .

In brief: The simplest way to code an image is by using sample values
that are directly proportional to the radiance of the color compo-
nents. Radiance is a physical quantification based on the amount of
power in the light; it is easily measurable in a laboratory, but does
not take into account what the light looks like to a person. It
wastes the sample space because the human eye can't discern differ-
ences between low-radiance colors as well as it can between high-radi-
ance colors. So instead, we pass the radiance values through a trans-
fer function that makes it so that changing a sample value by 1 causes
the same level of perceived color change anywhere in the sample range.
We store those resulting values in the image file. That transfer
function is called the gamma transfer function and the transformation
is called gamma adjusting.

The gamma-adjusted value, proportional to subjective brightness, are
known as the luminance of the pixel.

There is no precise objective way to measure luminance, since it's
psychological. Also, perception of brightness varies according to a
variety of factors, including the surrounding in which an image is
viewed. Therefore, there is not just one gamma transfer function.

Virtually all image formats, either specified or de facto, use gamma-
adjusted values for their sample values.

What's really nice about gamma is that by coincidence, the inverse
function that you have to do to convert the gamma-adjusted values back
to radiance is done automatically by CRTs. You just apply a voltage
to the CRT's electron gun that is proportional to the gamma-adjusted
sample value, and the radiance of the light that comes out of the
screen is close to the radiance value you had before you applied the
gamma transfer function!

And when you consider that computer video devices usually want you to
store in video memory a value proportional to the signal voltage you
want to go to the monitor, which the monitor turns into a proportional
drive voltage on the electron gun, it is really convenient to work
with gamma-adjusted sample values.


Copyright (C) 1991 by Bill Davidson and Jef Poskanzer.

netpbm documentation 30 June 2007 Pnmgamma User Manual(0)