This program is part of Netpbm.
pamlevels reads a Netpbm image from pamfile or standard input, applies a "levels" transformation, and sends the result to standard output. It finds a unique transformation that maps color from1 to to1, color from2 to to2, and—if -from3 and -to3 are supplied—color from3 to to3. Transformations based on two mappings are linear in light intensity and those based on three mappings quadratic. The color-mapping options may be shortened to -f1...-f3 and -t1...-t3.
Color values have the following format: color[:scale], where color is a Netpbm color specification and scale an optional coefficient that is applied to the intensity (i.e. not gamma-adjusted) of each RGB component of color.
When the transformation is linear (i.e. uses two mappings) and preserves zero (i.e. maps black to black), it corresponds to multiplication of light intensity by a constant and preserves color integrity.
\
denotes a line continuation:
To brighten an image by setting a darker white point—
pamlevels -f1 black -t1 black \ -f2 white:0.9 -t2 white in.ppm > out.ppm
To adjust the white point—
pamlevels -f1 black -t1 black \ -f2 rgbi:0.9/0.83/0.80 -t2 white in.ppm > out.ppm
To set a lighter black point—
pamlevels -f1 white:0.06 -t1 black \ -f2 white -t2 white in.ppm > out.ppm
To increase brightness by compression—
pamlevels \ -f1 black -t1 black -f2 white -t2 white \ -f3 white:0.5 -t3 white:0.6 in.ppm > out.ppmThe latter transformation is similar to gamma-correction.
In addition to the options common to all programs based on libnetpbm (most notably -quiet, see Common Options), pamlevels recognizes the following command line options:
You must specify at least two of these pairs.
Note that the numbers in a color specification like rgbi:0.9/0.83/0.80 are brightness levels (gamma-adjusted) regardless of the input and output format.
You cannot use this with -fitbrightness because that function is not implemented.
Note that many tools other than Netpbm do the transformation this way. One use for this option is simply to demonstrate the poor result of this method.
One advantage of this transformation is that it is faster, because the input and output image formats use brightness values. The result is approximately correct.
You cannot use this with -linear because that function is not implemented.
This program was first submitted by Anton Shepelev (anton.txt@gmail.com).
pamlevels was new in Netpbm 10.83 (June 2018).