summary refs log tree commit diff
path: root/pamaltsat.html
blob: 1e4b039b69b5555f5357325b2a8745520c909b6a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.3//EN">
<html><head><title>Pamaltsat User Manual</title></head>
<body>
<h1>pamaltsat</h1>
Updated: 14 September 2018
<br>
<a href="#index">Table Of Contents</a>

<h2>NAME</h2>
pamaltsat - increase or decrease the saturation of an image using one of
several alternative methods.

<h2 id="synopsis">SYNOPSIS</h2>

<b>pamaltsat</b>
[<b>-method</b> <i>name</i>]
[<b>-strength</b> <i>number</i>]
[<b>-linear</b>]
[<i>infile</i>]

<h2 id="description">DESCRIPTION</h2>

<p>This program is part of <a href="index.html">Netpbm</a>.

<p><b>pamaltsat</b> decreases or increases the saturation of a Netpbm image by
one of various non-standard (<i>alt</i>ernative) methods.

<p>The input is a Netpbm image from Standard Input or a file named by the
arguments.  The output is a Netpbm image in the same format written to
Standard Output.

<p>The most conventional way to change the saturation of an image is what
<b>pambrighten</b> does.
  

<h2 id="examples">EXAMPLES</h2>

<p>To increase saturation by a factor of 2.1 using the
logarithmic method:

<pre>
<kbd>
     pamaltsat -method log -strength 2.1 test.ppm
</kbd>
</pre>

<p>To convert a color image to grayscale:

<pre>
<kbd>
    pamaltsat -strength 0 test.ppm
</kbd>
</pre>


<h2 id="saturation_methods">SATURATION METHODS</h2>

<p>The following saturation methods are available.

<h3>Logarithmic Method</h3>

<p>This saturation model is inspired by the concept of
<a href="http://www.c-f-systems.com/ColorIntegrity.html">color integrity</a>,
which works with color in terms of intensity ratios, where intensity is a 
value of the
<a href="https://en.wikipedia.org/wiki/Luminosity_function">luminosity
function</a>, rather than brightness, or the numerical value of the sample in
the image file.  From this viewpoint, it is natural to define the saturation
of a color as the ratio of maximum and minimum intensities of its primary
components. In order, however, to make saturation an additive value and to
endow the <b>-strength</b> parameter with the semantics of a multiplier,
it is convenient to operate on the logarithm of that ratio.  The addition of
such saturations acquires physical sense, and multiplication corresponds to
the raising of intensity to the power of the multiplier.

<p>With this method, <b>pamaltsat</b> raises the intensity of each component
to the power of the <b>strength</b> value. Since the total intensity of the
resulting color will differ from that of the original, it is necessary to
restore the intensity by multiplying the component intensities of the
saturated color by the ratio of the intensity of the original color to that of
the saturated color.

<p>Although it is always possible to decrease saturation by any given factor,
there are two cases where it cannot be increased.  When the total intensity
(or brightness) of a color is too high for the desired
saturation, <b>pamaltsat</b> applies the maximum possible saturation that
keeps the original intensity.  For example, any color with at least one
component at the maxiumum is already fully saturated.  When one of the primary
components is zero, the definition of saturation given above no longer works
because of a zero in the denominator.  <b>pamaltsat</b> offers no special
treatment of this situation because it does not create discontinuities and
therefore produces no visible defects at reasonable strength levels.  When,
however, strength approaches infinity, each color tends to its primary
component with the highest intensity.

<p>This method was invented by Anton Shepelev.
  

<h3>Spectral Method</h3>

<p>This is the default method.  It treats color as a spectrum with three
bands: one for the intensity of each primary component.  Since neutral gray
has a uniform (constant) spectrum, saturation can be measured as the
difference of the spectrum of the given color from the uniform spectrum of the
same total intensity.  The spectral method uses one of the simplest measures
of such a difference: the difference between the highest and lowest component
intensities, which is an additive value and therefore amenable to
multiplication with good physical sense.  Although a complete hue-saturation
model can be dervied from this approach, <b>pamaltsat</b> need not concern
itself with it because it always preserves both hue and total intensity.

<p>In order to change saturation, <b>pamaltsat</b> first multiplies the
intensity of each component by the desired strength.  The saturation of the
result is the strength times the saturation of the original, and likewise the
total intensity, but it is then restored by subtraction of the neutral gray
with a suitable intensity.

<p>The effect of this method on each component intensity may be expressed in
the following equation:
<pre>
<span style="font-family: monospace">
    sat = orig * strength - Iorig * (strength - 1)
</span>
</pre>
where <span style="font-family: monospace">sat</span> is the saturated
sample, <span style="font-family: monospace">orig</span> the original sample,
and <span style="font-family: monospace">Iorig</span> the total intensity of
the original color.

<p>The method is also related to color integrity because both its operations
are part of that concept: multiplication of component intensities by the same
quotient is an important operation because changes brightness but keeps color
balance, and subtraction of a constant from all component intensities is
described by the inventor of color integrity as &quot;subtraction of
white.&quot;

<p>This procedure may produce both negative and over-unity component
intensities.  For such samples, <b>pamaltsat</b> decreases the strength to the
highest value that keeps the resulting color in range.

<p>This method was invented by Anton Shepelev.


<h2 id="options">OPTIONS</h2>

<p>In addition to the options common to all programs based on libnetpbm
(most notably <b>-quiet</b>, see <a href="index.html#commonoptions">
Common Options</a>), <b>pamaltsat</b> recognizes the following
command line options:

<dl>
<dt><b>-method</b> <i>method</i>
<dd>specifies the saturation method to use:
<table>
<tr><th>method name</th><th>option value</th></tr>
<tr><td>Logarithmic</td><td><kbd>log </kbd></td></tr>
<tr><td>Spectral   </td><td><kbd>spectrum</kbd></td></tr>
</table>

<p>The default is <b>spectrum</b>

<dt><b>-strength</b> <i>strength</i>

<dd>This specifies a real nonnegative factor whereby to modify saturation.  A
value greater than unity will increase saturation, whereas a value less than
unity will decrease it. Unity will leave the image unchanged, and zero will
produce greyscale output according to Rec 709.
  
<b>pamaltsat</b> preserves the total intensity of each pixel and never
affects neutral gray pixels.

<p>This option is mandatory.

<dt><b>-linear</b>

<dd>This tells <b>pamaltsat</b> that the input is the intensity-linear
variation of a Netpbm image forat, in which the samples are proportional to
light intensity rather than to brightness, as they are in true&mdash;or
gamma-adjusted&mdash; Netpbm image formats.
</dl>

<h2 id="usage_notes">USAGE NOTES</h2>

<p>Since <b>pamaltsat</b> does not affect neutral colors, you should adjust
the color balance before saturation. You can do this with <b>pamlevels</b>.

  
<h2 id="extensibility">EXTENSIBILITY</h2>

<b>pamaltsat</b> is written with an eye to extending it with new saturation
methods, which programmers are welcome to contribute.  The only requirement is
that every new method depend on a single strength parameter with the semantics
described under the <b>-strength</b> command-line option.


<h2 id="seealso">SEE ALSO</h2>

<p>
<a href="pambrighten.html">pambrighten</a>,
<a href="ppmflash.html">ppmflash</a>, 


<h2 id="author">AUTHOR</h2>

<p>This program was first submitted by Anton Shepelev
(<a href="mailto:anton.txt@gmail.com">anton.txt@gmail.com</a>).

<h2 id="history">HISTORY</h2>

<p><b>pamaltsat</b> was new in Netpbm 10.84 (September 2018).
  

<h2 id="index">Table Of Contents</h2>
<ul>
<li><a href="#synopsis">SYNOPSIS</a>
<li><a href="#description">DESCRIPTION</a>
<li><a href="#examples">EXAMPLES</a>
<li><a href="#saturation_methods">SATURATION METHODS</a>
<li><a href="#options">OPTIONS</a>
<li><a href="#usage_notes">USAGE NOTES</a>
<li><a href="#extensibility">EXTENSIBILITY</a>
<li><a href="#seealso">SEE ALSO</a>
<li><a href="#author">AUTHOR</a>
<li><a href="#history">HISTORY</a>
</ul>


</body>
</html>