pnmhisteq
Equalize the color histogram of a PNM image
TLDR
Increase the contrast of a PNM image using histogram equalization
Only modify grey pixels
Do not include black or white pixels in the histogram equalization
SYNOPSIS
pnmhisteq [-intensity | -value | -saturation] [-gamma G] [-uniform N | -linear N | -exponential N | -sqrt N | -cube N] [-verbose] [pnmfile]
PARAMETERS
-intensity
Default. Equalizes the intensity (luminance) component of the image. For color images, it equalizes based on luminance and reapplies to RGB.
-value
Equalizes the 'value' component (brightness) in the HSV color space.
-saturation
Equalizes the 'saturation' component in the HSV color space.
-gamma G
Applies a gamma correction of G before equalization. Values greater than 1 brighten, less than 1 darken the image.
-uniform N
Equalizes to a uniform distribution across N gray levels. N specifies the number of output gray levels.
-linear N
Equalizes to a linear distribution across N gray levels, concentrating values towards higher intensities.
-exponential N
Equalizes to an exponential distribution across N gray levels, concentrating values towards lower intensities.
-sqrt N
Equalizes to a square root distribution across N gray levels.
-cube N
Equalizes to a cubic distribution across N gray levels.
-verbose
Displays diagnostic information and progress messages during execution.
pnmfile
The input PNM image file. If omitted, pnmhisteq reads from standard input.
DESCRIPTION
pnmhisteq transforms the intensity values of an image such that its histogram (the distribution of pixel intensities) becomes more uniform or follows a specified distribution. This often enhances the contrast of images, especially those that are either too dark or too bright, by spreading out the most frequent intensity values across the entire available range. It works primarily on grayscale (PGM) and color (PPM) images, internally converting color images to grayscale for equalization based on the chosen channel (intensity, value, or saturation) and then remapping the color components. It's a powerful tool for image enhancement within the Netpbm suite.
CAVEATS
pnmhisteq does not work directly with PBM (bitmap) files; it requires PGM (grayscale) or PPM (color) input.
Aggressive equalization or a small number of output gray levels (N) can lead to posterization or banding artifacts in the output image.
While it enhances contrast, it might sometimes produce an unnatural appearance, especially on images that already have good contrast.
UNDERSTANDING DISTRIBUTIONS
The -uniform, -linear, -exponential, -sqrt, and -cube options allow users to specify the target distribution for the equalized histogram, rather than just a purely uniform one. This provides finer control over the resulting contrast and brightness characteristics, making it possible to achieve different visual effects depending on the image content and desired outcome. For instance, -linear can help brighten images, while -exponential might darken them while still enhancing contrast.
HISTORY
pnmhisteq is part of the Netpbm package, a venerable suite of graphics utilities for converting, creating, and manipulating image files.
Netpbm originated from PBMplus, developed by Jef Poskanzer in the late 1980s. Its design philosophy emphasizes small, simple command-line tools that can be piped together to perform complex tasks.
Histogram equalization, as an image processing technique, has been a fundamental method for contrast enhancement for decades. pnmhisteq provides a robust, highly configurable implementation within the Netpbm framework, making it a staple for command-line image manipulation.
SEE ALSO
pnmgamma(1), pnmsmooth(1), pnm(5), pnmtoplainpnm(1), pamarith(1)