1Pnmgamma User Manual(0)                                Pnmgamma User Manual(0)
2
3
4

NAME

6       pnmgamma - perform gamma adjustment on a PNM image
7
8

SYNOPSIS

10       pnmgamma {
11        -bt709tolinear |
12        -lineartobt709 |
13        -bt709tosrgb |
14        -srgbtobt709    }   [-gamma=float]   [-rgamma=float]   [-ggamma=float]
15       [-bgamma=float]
16
17       [pnmfile]
18
19       pnmgamma [
20        -bt709ramp |
21        -srgbramp ] [-ungamma] [{gamma | redgamma greengamma bluegamma}  [pnm‐
22       file]]
23
24
25

DESCRIPTION

27       This program is part of Netpbm(1).
28
29       Pnmgamma performs gamma adjustment on pseudo-PNM images.
30
31       The  PPM format specification specifies that certain sample values in a
32       file represent certain light intensities in an image.   In  particular,
33       they  specify that the sample values are directly proportional to lumi‐
34       nance as defined by ITU-R Recommendation BT.709.  BT.709 luminance as a
35       function  of  radiance  is a power function modified with a linear ramp
36       near black.
37
38       However, people sometimes work with approximations of PPM and PGM where
39       the sample values represent intensity in different ways:
40
41       In  one  common variation, the sample value is directly proportional to
42       radiance (often called 'linear intensity').
43
44       Another popular variation is to make the samples proportional to  lumi‐
45       nance  as  defined by the Internation Electrotechnical Commission (IEC)
46       SRGB standard.  The SRGB gamma transfer function is like the BT.709 one
47       except with different constants in it.
48
49       Note that SRGB is often spelled 'sRGB'.  In this document, we use stan‐
50       dard English typography, though, which doesn't allow for that  kind  of
51       capitalization.
52
53       pnmgamma  allows  you  to  manipulate the gamma transfer function, thus
54       working with and/or creating pseudo-PPM files that are useful for vari‐
55       ous things.
56
57       For  example,  if  you feed a true PPM to pnmgamma -bt709tolinear , you
58       get as output a file which is PPM in every respect except that the sam‐
59       ple  values  are  radiances.  If you feed such a file to pnmgamma -lin‐
60       earto709, you get back a true PPM.
61
62       The situation for PGM images is analogous.   And  pnmgamma  treats  PBM
63       images as PGM images.
64
65       When  you  feed  a  radiance-proportional pseudo-PPM image to a display
66       program that expects a true PPM, the display  appears  darker  than  it
67       should,  so  pnmgamma has the effect of lightening the image.  When you
68       feed a true PPM to a display program that expects radiance-proportional
69       sample  values,  and  therefore  does  a gamma adjustment of its own on
70       them, the display appears lighter than it should, so  pnmgamma  with  a
71       gamma value less than one (the multiplicative inverse of whatever gamma
72       value the display program uses) has the effect of darkening the image.
73
74

PARAMETERS

76       The form of the parameters depends on whether you're using the old syn‐
77       tax  or the new syntax.  With the old syntax, the parameters are a mix‐
78       ture of gamma values and the input file name.  With the new syntax, the
79       only parameter is the input file name and you specify gamma values with
80       option.
81
82       You use the old syntax if you specify -bt709ramp (or its synonym -cier‐
83       amp)  or  -srgramp or if you don't specify any transfer function at all
84       (and thus default to a simple exponential).  Otherwise, you use the new
85       syntax.
86
87       With the old syntax, you may specify a single gamma value or 3 separate
88       gamma values (red, green, and blue) or no gamma values.  In  any  case,
89       the meanings of those parameters is the same as the more modern -gamma,
90       -rgamma, -ggamma, and -bgamma options described below.
91
92
93

OPTIONS

95       -bt709tolinear
96              Convert the image from BT.709 luminance to radiance.  I.e.  con‐
97              vert  from  true  PPM or PGM to a radiance-linear variation that
98              can be used with certain tools that need it.
99
100              This option was new in Netpbm 10.32 (February 2006).
101
102
103       -lineartobt709
104              Convert the image from radiance to BT.709 luminance.  I.e.  con‐
105              vert to true PPM or PGM from a radiance-linear variation.
106
107              You  get  true BT.709 (ergo true PPM or PGM) only if you use the
108              default gamma value (i.e. don't specify -gamma, etc.).
109
110              This option was new in Netpbm 10.32 (February 2006).
111
112
113       -bt709tosrgb
114              Convert the image from BT.709 luminance to SRGB luminance.  I.e.
115              convert  from true PPM or PGM to an SRGB-based variation that is
116              required by certain tools and display devices.
117
118              You get true SRGB only if you use the default gamma value  (i.e.
119              don't specify -gamma, etc.).
120
121              This option was new in Netpbm 10.32 (February 2006).
122
123
124       -srgbtobt709
125              Convert the image from SRGB luminance to BT.709 luminance.  I.e.
126              convert to true PPM or PGM from an SRGB-based variation.
127
128              This option was new in Netpbm 10.32 (February 2006).
129
130
131       -bt709ramp
132              Same as -lineartobt709, but using the old syntax.
133
134              This option was renamed in Netpbm 10.32 (February 2006).  Before
135              that, its name is -cieramp.
136
137
138       -cieramp
139              This is an obsolete synonym for -bt709ramp.
140
141              The name of this option comes from a former belief that this was
142              a standard of CIE (International  Commission  On  Illumination),
143              but it now (August 2005) looks like it never was.
144
145
146       -srgbramp
147              Convert the image from radiance to SRGB luminance.  Note that it
148              is true SRGB only if you use the default gamma value (i.e. don't
149              specify any gamma parameters).
150
151              This is an old syntax option.  There is no equivalent in the new
152              syntax because it really shouldn't be a function of pnmgamma  at
153              all.   It  exists solely for backward compatibility.  The reason
154              it shouldn't exist is that the way to do this conversion consis‐
155              tent  with the Netpbm philosophy is do a -lineartobt709 followed
156              by a -bt709tosrgb.  It's exactly analogous to the way  you  have
157              to  convert  from  PNG to TIFF by doing a pngtopam followed by a
158              pnmtotiff.  The -srgbramp option actually dates to before  there
159              was  a standard definition of what the sample values of a Netpbm
160              image measure, and pnmgamma considered radiance-linear to be the
161              proper intermediate format.
162
163
164       -ungamma
165              Apply  the  inverse  of the specified transfer function (i.e. go
166              from gamma-adjusted luminance to radiance).
167
168              This is valid only with -bt709ramp  (aka  -cieramp),  -srgbramp,
169              and the default exponential transfer function.
170
171
172       -gamma=float
173              This  specifies the gamma value to use in the transfer function.
174              All of the transfer functions involve an exponent, and the gamma
175              value is that exponent.
176
177              The standards specify a particular gamma value.  If you use any‐
178              thing else, you are varying from the standard.
179
180              The default is the standard value.  For the  simple  exponential
181              transfer function (which is not a standard), the default is 2.2.
182
183              In  the  -bt709tosrgb and -srgbtobt709 conversions there are two
184              exponents.  -gamma affects the 'to' function; the  'from'  func‐
185              tion always uses the standard gamma value.
186
187              If  you  specify one of the component-specific options (-rgamma,
188              etc.), that overrides the -gamma value.
189
190              With the -bt709ramp (aka -cieramp), -srgbramp,  or  the  default
191              exponential  transfer  function,  you  can't  actually  use this
192              option,  but  you  specify  the  same  thing  with   parameters.
193              ⟨#parameters⟩
194
195              This option was new in Netpbm 10.32 (February 2006).
196
197
198       -rgamma=float
199
200       -ggamma=float
201
202       -bgamma=float
203              These  options  are  just  like  -gamma, except they specify the
204              value for a particular one of the color components.
205
206              If you don't specify this option for a particular  color  compo‐
207              nent,  the  default  is the -gamma value (or -gamma's default if
208              you didn't specify that either).
209
210              With the -bt709ramp (aka -cieramp), -srgbramp,  or  the  default
211              exponential  transfer  function,  you  can't  actually  use this
212              option,  but  you  specify  the  same  thing  with   parameters.
213              ⟨#parameters⟩
214
215              This option was new in Netpbm 10.32 (February 2006).
216
217
218       -maxval=maxval
219              This  is the maxval of the output image.  By default, the maxval
220              of the output is the same as that of the input.
221
222              Because the transformation is not linear,  you  need  a  greater
223              maxval  in  the output in order not to lose any information from
224              the input.  For example, if you convert to radiance-linear  sam‐
225              ple  values  with  with  -ungamma  -bt709ramp  and default gamma
226              value, and your maxval is 255 on both input and output,  3  dif‐
227              ferent input sample values all generate output sample value 254.
228              In order to have a different output sample value for each  input
229              sample  value,  you would need an output maxval at least 3 times
230              the input maxval.
231
232              This option was new in Netpbm  10.32  (February  2006).   Before
233              that,  you  can achieve the same result by increasing the maxval
234              of the input or  decreasing  the  maxval  of  the  output  using
235              pamdepth.
236
237
238
239

WHAT IS GAMMA?

241       A  good  explanation  of  gamma  is  in Charles Poynton's Gamma FAQ at
242       http://www.poynton.com/GammaFAQ.html   (1)   and   Color   FAQ   at
243       http://www.poynton.com/ColorFAQ.html (1).
244
245       In  brief:  The simplest way to code an image is by using sample values
246       that are directly proportional to the radiance of the color components.
247       Radiance  is  a physical quantification based on the amount of power in
248       the light; it is easily measurable in a laboratory, but does  not  take
249       into account what the light looks like to a person.  It wastes the sam‐
250       ple space because the human eye can't discern differences between  low-
251       radiance  colors  as  well  as it can between high-radiance colors.  So
252       instead, we pass the radiance values through a transfer  function  that
253       makes  it so that changing a sample value by 1 causes the same level of
254       perceived color change anywhere in the sample range.   We  store  those
255       resulting  values  in the image file.  That transfer function is called
256       the gamma transfer function and  the  transformation  is  called  gamma
257       adjusting.
258
259       The  gamma-adjusted  value,  proportional to subjective brightness, are
260       known as the luminance of the pixel.
261
262       There is no precise objective way to measure luminance, since it's psy‐
263       chological.  Also, perception of brightness varies according to a vari‐
264       ety of factors, including the surrounding in which an image is  viewed.
265       Therefore, there is not just one gamma transfer function.
266
267       Virtually  all  image formats, either specified or de facto, use gamma-
268       adjusted values for their sample values.
269
270       What's really nice about gamma is  that  by  coincidence,  the  inverse
271       function  that you have to do to convert the gamma-adjusted values back
272       to radiance is done automatically by CRTs.  You just apply a voltage to
273       the  CRT's electron gun that is proportional to the gamma-adjusted sam‐
274       ple value, and the radiance of the light that comes out of  the  screen
275       is  close  to  the  radiance value you had before you applied the gamma
276       transfer function!
277
278       And when you consider that computer video devices usually want  you  to
279       store  in  video  memory a value proportional to the signal voltage you
280       want to go to the monitor, which the monitor turns into a  proportional
281       drive voltage on the electron gun, it is really convenient to work with
282       gamma-adjusted sample values.
283
284

SEE ALSO

286       pnm(1)
287
288

AUTHOR

290       Copyright (C) 1991 by Bill Davidson and Jef Poskanzer.
291
292
293
294netpbm documentation             30 June 2007          Pnmgamma User Manual(0)
Impressum