Debian Codegraph @

userguide/pnmgamma.html

raw symbols SCIP
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.3//EN">
2 <html><head><title>Pnmgamma User Manual</title></head>
3 <body>
4 <h1>pnmgamma</h1>
5 Updated: 30 June 2007
6 <br>
7 <a href="#index">Table Of Contents</a>
8
9 <h2>NAME</h2>
10 pnmgamma - perform gamma adjustment on a PNM image
11
12 <h2 id="synopsis">SYNOPSIS</h2>
13
14 <p>
15 <b>pnmgamma</b>
16 {
17 <b>-bt709tolinear</b> |
18 <b>-lineartobt709</b> |
19 <b>-bt709tosrgb</b> |
20 <b>-srgbtobt709</b>
21 }
22 [<b>-gamma=</b><i>float</i>]
23 [<b>-rgamma=</b><i>float</i>]
24 [<b>-ggamma=</b><i>float</i>]
25 [<b>-bgamma=</b><i>float</i>]
26
27 [<i>pnmfile</i>]
28
29 <p>
30 <b>pnmgamma </b>
31 [
32 <b>-bt709ramp</b> |
33 <b>-srgbramp</b>
34 ]
35 [<b>-ungamma</b>]
36 <br>
37 [{<i>gamma</i> | <i>redgamma</i> <i>greengamma</i> <i>bluegamma</i>}
38 [<i>pnmfile</i>]]
39
40
41 <h2 id="description">DESCRIPTION</h2>
42
43 <p>This program is part of <a href="index.html">Netpbm</a>.
44
45 <p><b>Pnmgamma</b> performs gamma adjustment on pseudo-PNM images.
46
47 <p>The PPM format specification specifies that certain sample values
48 in a file represent certain light intensities in an image. In
49 particular, they specify that the sample values are directly
50 proportional to luminance as defined by ITU-R Recommendation BT.709.
51 BT.709 luminance as a function of radiance is a power function
52 modified with a linear ramp near black.
53
54 <p>However, people sometimes work with approximations of PPM and PGM
55 where the sample values represent intensity in different ways:
56
57 <p>In one common variation, the sample value is directly proportional
58 to radiance (often called "linear intensity").
59
60 <p>Another popular variation is to make the samples proportional to
61 luminance as defined by the International Electrotechnical Commission
62 (IEC) SRGB standard. The SRGB gamma transfer function is like the
63 BT.709 one except with different constants in it.
64
65 <p>Note that SRGB is often spelled "sRGB". In this
66 document, we use standard English typography, though, which doesn't
67 allow for that kind of capitalization.
68
69 <p><b>pnmgamma</b> allows you to manipulate the gamma transfer
70 function, thus working with and/or creating pseudo-PPM files that are
71 useful for various things.
72
73 <p>For example, if you feed a true PPM to <kbd>pnmgamma -bt709tolinear
74 </kbd>, you get as output a file which is PPM in every respect except
75 that the sample values are radiances. If you feed such a file to
76 <kbd>pnmgamma -linearto709</kbd>, you get back a true PPM.
77
78 <p>The situation for PGM images is analogous. And <b>pnmgamma</b>
79 treats PBM images as PGM images.
80
81 <p>When you feed a radiance-proportional pseudo-PPM image to a display
82 program that expects a true PPM, the display appears darker than it
83 should, so <b>pnmgamma</b> has the effect of lightening the image.
84 When you feed a true PPM to a display program that expects
85 radiance-proportional sample values, and therefore does a gamma
86 adjustment of its own on them, the display appears lighter than it
87 should, so <b>pnmgamma</b> with a gamma value less than one (the
88 multiplicative inverse of whatever gamma value the display program
89 uses) has the effect of darkening the image.
90
91 <h2 id="parameters">PARAMETERS</h2>
92
93 <p>The form of the parameters depends on whether you're using the old
94 syntax or the new syntax. With the old syntax, the parameters are
95 a mixture of gamma values and the input file name. With the new
96 syntax, the only parameter is the input file name and you specify gamma
97 values with option.
98
99 <p>You use the old syntax if you specify <b>-bt709ramp</b> (or
100 its synonym <b>-cieramp</b>) or <b>-srgramp</b> or if you don't specify
101 any transfer function at all (and thus default to a simple exponential).
102 Otherwise, you use the new syntax.
103
104 <p>With the old syntax, you may specify a single gamma value or 3
105 separate gamma values (red, green, and blue) or no gamma values. In
106 any case, the meanings of those parameters is the same as the more
107 modern <b>-gamma</b>, <b>-rgamma</b>, <b>-ggamma</b>, and
108 <b>-bgamma</b> options described below.
109
110
111 <h2 id="options">OPTIONS</h2>
112
113 <p>In addition to the options common to all programs based on libnetpbm
114 (most notably <b>-quiet</b>, see <a href="index.html#commonoptions">
115 Common Options</a>), <b>pnmgamma</b> recognizes the following
116 command line options:
117
118 <dl compact>
119
120 <dt><b>-bt709tolinear</b>
121
122 <dd>Convert the image from BT.709 luminance to radiance. I.e. convert
123 from true PPM or PGM to a radiance-linear variation that can be used
124 with certain tools that need it.
125
126 <p>This option was new in Netpbm 10.32 (February 2006).
127
128 <dt><b>-lineartobt709</b>
129
130 <dd>Convert the image from radiance to BT.709 luminance. I.e. convert
131 to true PPM or PGM from a radiance-linear variation.
132
133 <p>You get true BT.709 (ergo true PPM or PGM) only if you use the
134 default gamma value (i.e. don't specify <b>-gamma</b>, etc.).
135
136 <p>This option was new in Netpbm 10.32 (February 2006).
137
138 <dt><b>-bt709tosrgb</b>
139
140 <dd>Convert the image from BT.709 luminance to SRGB luminance.
141 I.e. convert from true PPM or PGM to an SRGB-based variation that is
142 required by certain tools and display devices.
143
144 <p>You get true SRGB only if you use the default gamma value
145 (i.e. don't specify <b>-gamma</b>, etc.).
146
147 <p>This option was new in Netpbm 10.32 (February 2006).
148
149 <dt><b>-srgbtobt709</b>
150
151 <dd>Convert the image from SRGB luminance to BT.709 luminance.
152 I.e. convert to true PPM or PGM from an SRGB-based variation.
153
154 <p>This option was new in Netpbm 10.32 (February 2006).
155
156 <dt><b>-bt709ramp</b>
157
158 <dd>Same as <b>-lineartobt709</b>, but using the old syntax.
159
160 <p>This option was renamed in Netpbm 10.32 (February 2006). Before that,
161 its name is <b>-cieramp</b>.
162
163 <dt><b>-cieramp</b>
164
165 <dd>This is an obsolete synonym for <b>-bt709ramp</b>.
166
167 <p>The name of this option comes from a former belief that this was a
168 standard of CIE (International Commission On Illumination), but it now
169 (August 2005) looks like it never was.
170
171 <dt><b>-srgbramp </b>
172
173 <dd>Convert the image from radiance to SRGB luminance. Note that it is
174 true SRGB only if you use the default gamma value (i.e. don't specify
175 any gamma parameters).
176
177 <p>This is an old syntax option. There is no equivalent in the new
178 syntax because it really shouldn't be a function of <b>pnmgamma</b> at
179 all. It exists solely for backward compatibility. The reason it
180 shouldn't exist is that the way to do this conversion consistent with
181 the Netpbm philosophy is do a <b>-lineartobt709</b> followed by a
182 <b>-bt709tosrgb</b>. It's exactly analogous to the way you have to
183 convert from PNG to TIFF by doing a <b>pngtopam</b> followed by a
184 <b>pnmtotiff</b>. The <b>-srgbramp</b> option actually dates to
185 before there was a standard definition of what the sample values of a
186 Netpbm image measure, and <b>pnmgamma</b> considered radiance-linear
187 to be the proper intermediate format.
188
189 <dt><b>-ungamma</b>
190
191 <dd>Apply the inverse of the specified transfer function (i.e. go from
192 gamma-adjusted luminance to radiance).
193
194 <p>This is valid only with <b>-bt709ramp</b> (aka <b>-cieramp</b>),
195 <b>-srgbramp</b>, and the default exponential transfer function.
196
197 <dt><b>-gamma=</b><i>float</i>
198
199 <dd>This specifies the gamma value to use in the transfer function. All
200 of the transfer functions involve an exponent, and the gamma value is that
201 exponent.
202
203 <p>The standards specify a particular gamma value. If you use anything
204 else, you are varying from the standard.
205
206 <p>The default is the standard value. For the simple exponential transfer
207 function (which is not a standard), the default is 2.2.
208
209 <p>In the <b>-bt709tosrgb</b> and <b>-srgbtobt709</b> conversions
210 there are <em>two</em> exponents. <b>-gamma</b> affects the
211 "to" function; the "from" function always uses the
212 standard gamma value.
213
214 <p>If you specify one of the component-specific options (<b>-rgamma</b>,
215 etc.), that overrides the <b>-gamma</b> value.
216
217 <p>With the <b>-bt709ramp</b> (aka <b>-cieramp</b>), <b>-srgbramp</b>,
218 or the default exponential transfer function, you can't actually use
219 this option, but you specify the same thing with <a
220 href="#parameters">parameters.</a>
221
222 <p>This option was new in Netpbm 10.32 (February 2006).
223
224 <dt><b>-rgamma=</b><i>float</i>
225 <dt><b>-ggamma=</b><i>float</i>
226 <dt><b>-bgamma=</b><i>float</i>
227
228 <dd>These options are just like <b>-gamma</b>, except they specify the
229 value for a particular one of the color components.
230
231 <p>If you don't specify this option for a particular color component,
232 the default is the <b>-gamma</b> value (or <b>-gamma</b>'s default if
233 you didn't specify that either).
234
235 <p>With the <b>-bt709ramp</b> (aka <b>-cieramp</b>), <b>-srgbramp</b>,
236 or the default exponential transfer function, you can't actually use
237 this option, but you specify the same thing with <a
238 href="#parameters">parameters.</a>
239
240 <p>This option was new in Netpbm 10.32 (February 2006).
241
242 <dt><b>-maxval=</b><i>maxval</i>
243
244 <dd>This is the maxval of the output image. By default, the maxval of
245 the output is the same as that of the input.
246
247 <p>Because the transformation is not linear, you need a greater maxval
248 in the output in order not to lose any information from the input.
249 For example, if you convert to radiance-linear sample values with
250 <kbd>-ungamma -bt709ramp</kbd> and default gamma value, and your maxval is
251 255 on both input and output, 3 different input sample values all
252 generate output sample value 254. In order to have a different output
253 sample value for each input sample value, you would need an output
254 maxval at least 3 times the input maxval.
255
256 <p>This option was new in Netpbm 10.32 (February 2006). Before that,
257 you can achieve the same result by increasing the maxval of the input
258 or decreasing the maxval of the output using <b>pamdepth</b>.
259
260 </dl>
261
262 <h2 id="gamma">WHAT IS GAMMA?</h2>
263
264 <p>A good explanation of gamma is in Charles Poynton's Gamma FAQ at
265 <a href="http://www.poynton.com/GammaFAQ.html">
266 http://www.poynton.com/GammaFAQ.html</a> and Color FAQ at <a
267 href="http://www.poynton.com/ColorFAQ.html">
268 http://www.poynton.com/ColorFAQ.html</a>.
269
270 <p>In brief: The simplest way to code an image is by using sample
271 values that are directly proportional to the radiance of the color
272 components. Radiance is a physical quantification based on the amount
273 of power in the light; it is easily measurable in a laboratory, but
274 does not take into account what the light looks like to a person. It
275 wastes the sample space because the human eye can't discern
276 differences between low-radiance colors as well as it can between
277 high-radiance colors. So instead, we pass the radiance values
278 through a transfer function that makes it so that changing a sample
279 value by 1 causes the same level of perceived color change anywhere in
280 the sample range. We store those resulting values in the image file.
281 That transfer function is called the gamma transfer function and the
282 transformation is called gamma adjusting.
283
284 <p>The gamma-adjusted value, proportional to subjective brightness,
285 are known as the luminance of the pixel.
286
287 <p>There is no precise objective way to measure luminance, since it's
288 psychological. Also, perception of brightness varies according to a
289 variety of factors, including the surrounding in which an image is
290 viewed. Therefore, there is not just one gamma transfer function.
291
292 <p>Virtually all image formats, either specified or de facto, use
293 gamma-adjusted values for their sample values.
294
295 <p>What's really nice about gamma is that by coincidence, the inverse
296 function that you have to do to convert the gamma-adjusted values
297 back to radiance is done automatically by CRTs. You just apply a
298 voltage to the CRT's electron gun that is proportional to the
299 gamma-adjusted sample value, and the radiance of the light that comes
300 out of the screen is close to the radiance value you had before you
301 applied the gamma transfer function!
302
303 <p>And when you consider that computer video devices usually want you
304 to store in video memory a value proportional to the signal voltage
305 you want to go to the monitor, which the monitor turns into a
306 proportional drive voltage on the electron gun, it is really
307 convenient to work with gamma-adjusted sample values.
308
309 <h2 id="seealso">SEE ALSO</h2>
310
311 <b><a href="pnm.html">pnm</a></b>
312
313 <h2 id="author">AUTHOR</h2>
314
315 Copyright (C) 1991 by Bill Davidson and Jef Poskanzer.
316
317 <hr>
318 <h2 id="index">Table Of Contents</h2>
319 <ul>
320 <li><a href="#synopsis">SYNOPSIS</a>
321 <li><a href="#description">DESCRIPTION</a>
322 <li><a href="#parameters">PARAMETERS</a>
323 <li><a href="#options">OPTIONS</a>
324 <li><a href="#gamma">WHAT IS GAMMA?</a>
325 <li><a href="#seealso">SEE ALSO</a>
326 <li><a href="#author">AUTHOR</a>
327 </ul>
328 </body>
329 </html>