pnmnorm

Updated: 17 May 2005
Table Of Contents  

NAME

pnmnorm - normalize the contrast in a Netbpm image  

SYNOPSIS

pnmnorm [-bpercent N | -bvalue N] [-wpercent N | -wvalue N] [-keephues] [-colorvalue] [ppmfile]

All options can be abbreviated to their shortest unique prefix. You may use two hyphens instead of one to designate an option. You may use either white space or an equals sign between an option name and its value.  

DESCRIPTION

This program is part of Netpbm.

pnmnorm reads a PNM image (PBM, PGM, or PPM). Normalizes the contrast by forcing the brightest pixels to white, the darkest pixels to black, and linearly rescaling the ones in between; and produces the same kind of file as output. This is pretty useless for a PBM image.

The program first determines a mapping of old brightness to new brightness. For each possible brightness of a pixel, the program determines a corresponding brightness for the output image.

Then for each pixel in the image, the program computes a color which has the desired output brightness and puts that in the output. With a color image, it is not always possible to compute such a color and retain any semblance of the original hue, so the brightest and dimmest pixels may only approximate the desired brightness.

Note that for a PPM image, this is different from separately normalizing the individual color components.

An alternative way to spread out the intensities in an image is pnmhisteq. pnmhisteq stretches the brightest pixels to white and the darkest pixels to black, but rather than linearly adjusting the ones in between, it adjusts them so that there are an equal number of pixels of each intensity throughout the range. This gives you more contrast than pnmnorm does, but can considerably change the picture in exchange.  

OPTIONS

By default, the darkest 2 percent of all pixels are mapped to black, and the brightest 1 percent are mapped to white. You can override these percentages by using the -bpercent and -wpercent flags, or you can specify the exact pixel values to be mapped by using the -bvalue and -wvalue flags. You can get appropriate numbers for the flags from ppmhist. If you just want to enhance the contrast, then choose values at elbows in the histogram; e.g. if value 29 represents 3% of the image but value 30 represents 20%, choose 30 for bvalue. If you want to brighten the image, then set bvalue to 0 and just fiddle with wvalue; similarly, to darken the image, set wvalue to maxval and play with bvalue.

If you specify both -bvalue and -bpercent, pnmnorm uses the one that produces the minimal change. The same goes for -wvalue and -wpercent.

If you want to maximize the change instead of minimizing it, just cascade two runs of pnmnorm, specifying values for the first and percentages for the second.

Before Netpbm 10.26 (December 2004), it was not valid to specify both -bvalue and -bpercent or -wvalue and -wpercent.

The -keephues option says to keep each pixel the same hue as it is in the input; just adjust its intensity. By default, pnmnorm normalizes contrast in each component independently (except that the meaning of the -wpercent and -bpercent options are based on the overall intensities of the colors, not each component taken separately). So if you have a color which is intensely red but dimly green, pnmnorm would make the red more intense and the green less intense, so you end up with a different hue than you started with.

If you specify -keephues, pnmnorm would likely leave this pixel alone, since its overall intensity is medium.

-keephues can cause clipping, because a certain color may be below a target intensity while one of its components is saturated. Where that's the case, pnmnorm uses the maximum representable intensity for the saturated component and the pixel ends up with less overall intensity, and a different hue, than it is supposed to have.

This option is meaningless on grayscale images.

Before Netpbm 9.25 (March 2002), there was no -keephues option.

The -colorvalue option says to use the color value (i.e. the "V" in the HSV color space) as the pixel's brightness. The color value is the intensity of the most intense RGB component. By default, pnmnorm uses the luminosity of the pixel as its brightness.

This option is meaningless on grayscale images.

Before Netpbm 10.28 (August 2005), there was no -colorvalue option.  

SEE ALSO

pnmhisteq, ppmhist, pgmhist, pnmgamma, ppmbrighten, ppmdim, pnm
 

Table Of Contents