.TL Pnmgamma User Manual .SH 1 pnmgamma .LP Updated: 18 February 2006 .br Table Of Contents .SH 2 NAME .LP pnmgamma - perform gamma correction on a PNM image .SH 2 SYNOPSIS .LP \fBpnmgamma \fR .br [ \fB-bt709ramp\fR | \fB-srgbramp\fR | ] [\fB-ungamma\fR] .br [\fIgamma\fR | \fIredgamma\fR \fIgreengamma\fR \fIbluegamma\fR [\fIpnmfile\fR]] \fBpnmgamma\fR { \fB-bt709tolinear\fR | \fB-lineartobt709\fR | \fB-bt709tosrgb\fR | \fB-srgbtobt709\fR } [\fB-gamma=\fR\fIfloat\fR] [\fB-rgamma=\fR\fIfloat\fR] [\fB-ggamma=\fR\fIfloat\fR] [\fB-bgamma=\fR\fIfloat\fR] [\fIpnmfile\fR] .SH 2 DESCRIPTION .LP .LP This program is part of Netpbm. .LP \fBPnmgamma\fR performs gamma correction on pseudo-PNM images. .LP 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 luminance as defined by ITU-R Recommendation BT.709. .LP However, people sometimes work with approximations of PPM and PGM where the sample values represent intensity in different ways. For example, the sample value might be directly proportional to radiance (often called "linear intensity"). Or a different gamma transfer function may be used. The relationship between the sample values and radiance is often called a gamma transfer function. .LP \fBpnmgamma\fR allows you to manipulate the gamma transfer function, thus working with and/or creating pseudo-PPM files that are useful for various things. .LP For example, if you feed a true PPM to \f(CWpnmgamma -bt709tolinear \fR, 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 \f(CWpnmgamma -linearto709\fR, you get back a true PPM. .LP The situation for PGM images is analogous. And \fBpnmgamma\fR treats PBM images as PGM images. .LP 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 \fBpnmgamma\fR has the effect of lightening the image. When you feed a true PPM to a display program that expects radiance-proportional sample values, and therefore does a gamma correction of its own on them, the display appears lighter than it should, so \fBpnmgamma\fR with a gamma value less than one (the multiplicative inverse of whatever gamma value the display program uses) has the effect of darkening the image. .SH 2 PARAMETERS .LP .LP 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. .LP You use the old syntax if you specify \fB-bt709ramp\fR (or its synonym \fB-cieramp\fR) or \fB-srgramp\fR or if you don't specify any transfer function at all (and thus default to a simple exponential). Otherwise, you use the new syntax. .LP With the old syntax, you may specify a single gamma value or 3 separate 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 \fB-gamma\fR, \fB-rgamma\fR, \fB-ggamma\fR, and \fB-bgamma\fR options described below. .SH 2 OPTIONS .LP .RS .IP "\fB-bt709tolinear\fR" Convert the image from ITU Recommendation BT.709 luminance to radiance (sometimes called "linear"). I.e. convert from true PPM or PGM to a radiance-linear variation that can be used with certain tools that need it. .LP This option was new in Netpbm 10.32 (February 2006). .IP "\fB-lineartobt709\fR" Convert the image from radiance to ITU Recommendation BT.709 luminance. I.e. convert to true PPM or PGM from a "linear" variation. .LP This option was new in Netpbm 10.32 (February 2006). .IP "\fB-bt709tosrgb\fR" Convert the image from ITU Recommendation BT.709 luminance to SRGB luminance. I.e. convert from true PPM or PGM to an SRGB-based variation that is required by certain tools and display devices. .LP This option was new in Netpbm 10.32 (February 2006). .IP "\fB-srgbtobt709\fR" Convert the image from SRGB luminance to ITU Recommendation BT.709 luminance. I.e. convert to true PPM or PGM from an SRGB-based variation. .LP This option was new in Netpbm 10.32 (February 2006). .IP "\fB-bt709ramp\fR" Use the ITU-R Recommendation BT.709 gamma transfer function. Note that it is true BT.709 only if you use the default gamma value (i.e. don't specify any gamma parameters). This transfer function is a power function modified with a linear ramp near black. .LP If you specify none of the transfer functions the transfer function defaults to a simple power function. .LP This option was renamed in Netpbm 10.32 (February 2006). Before that, its name is \fB-cieramp\fR. .IP "\fB-cieramp\fR" This is an obsolete synonym for \fB-bt709ramp\fR. .LP The name of this option comes from a former belief that this was a standard of CIE (International Commission On Illumination), but it now (August 2005) looks like it never was. .IP "\fB-srgbramp \fR" Use the Internation Electrotechnical Commission (IEC) SRGB gamma transfer function (as specified in the standard IEC 61966-2-1). Note that it is true SRGB only if you use the default gamma value (i.e. don't specify any gamma parameters). This transfer function is like the one selected by \fB-bt709ramp\fR, but with different constants in it. .LP 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. .LP If you specify neither \fB-bt709ramp\fR nor \fB-srgbramp\fR, the transfer function defaults to a simple power function. .IP "\fB-ungamma\fR" Apply the inverse of the specified transfer function (i.e. go from gamma-corrected luminance to radiance). .LP This is valid only with \fB-bt709ramp\fR (aka \fB-cieramp\fR), \fB-srgbramp\fR, and the default exponential transfer function. .IP "\fB-gamma=\fR\fIfloat\fR" This specifies the gamma value to use in the transfer function. All of the transfer functions involve an exponent, and the gamma value is that exponent. .LP The standards specify a particular gamma value. If you use anything else, you are varying from the standard. .LP The default is the standard value. For the simple exponential transfer function (which is not a standard), the default is 2.2. .LP If you specify one of the component-specific options (\fB-rgamma\fR, etc.), that overrides the \fB-gamma\fR value. .LP With the \fB-bt709ramp\fR (aka \fB-cieramp\fR), \fB-srgbramp\fR, or the default exponentional transfer function, you can't actually use this option, but you specify the same thing with parameters. .LP This option was new in Netpbm 10.32 (February 2006). .IP "\fB-rgamma=\fR\fIfloat\fR" .IP "\fB-ggamma=\fR\fIfloat\fR" .IP "\fB-bgamma=\fR\fIfloat\fR" These options are just like \fB-gamma\fR, except they specify the value for a particular one of the color components. .LP If you don't specify this option for a particular color component, the default is the \fB-gamma\fR value (or \fB-gamma\fR's default if you didn't specify that either). .LP With the \fB-bt709ramp\fR (aka \fB-cieramp\fR), \fB-srgbramp\fR, or the default exponentional transfer function, you can't actually use this option, but you specify the same thing with parameters. .LP This option was new in Netpbm 10.32 (February 2006). .IP "\fB-maxval=\fR\fImaxval\fR" This is the maxval of the output image. By default, the maxval of the output is the same as that of the input. .LP Because the transformation is not linear, you need a greater maxval in the output in order not to lose any information from the input. For example, if you convert to radiance-linear sample values with with \f(CW-ungamma -bt709ramp\fR and default gamma value, and your maxval is 255 on both input and output, 3 different input sample values all generate output sample value 254. In order to have a different output sample value for each input sample value, you would need an output maxval at least 3 times the input maxval. .LP This option was new in Netpbm 10.32 (February 2006). Before that, you can achieve the same result by increasing the maxval of the input or decreasing the maxval of the output using \fBpnmdepth\fR. .RE .SH 2 WHAT IS GAMMA? .LP .LP A good explanation of gamma is in Charles Poynton's Gamma FAQ at http://www.poynton.com/GammaFAQ.html and Color FAQ at http://www.poynton.com/ColorFAQ.html. .LP In brief: The simplest way to code an image is by using sample values that are directly proportional to the radiance of the color components. 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 differences between low-radiance colors as well as it can between high-radiance colors. So instead, we pass the radiance values through a transfer 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 correcting. .LP The gamma-corrected value, proportional to subjective brightness, are known as the luminance of the pixel. .LP 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. .LP Virtually all image formats, either specified or de facto, use gamma-corrected values for their sample values. .LP What's really nice about gamma is that by coincidence, the inverse function that you have to do to convert the gamma-corrected 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-corrected 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! .LP 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-corrected sample values. .SH 2 SEE ALSO .LP \fBpnm\fR .SH 2 AUTHOR .LP Copyright (C) 1991 by Bill Davidson and Jef Poskanzer. .br \l'5i' .SH 2 Table Of Contents .LP .IP \(bu SYNOPSIS .IP \(bu DESCRIPTION .IP \(bu PARAMETERS .IP \(bu OPTIONS .IP \(bu WHAT IS GAMMA? .IP \(bu SEE ALSO .IP \(bu AUTHOR .LP