pgmenhance
Improve contrast of PGM image files
TLDR
Edge-enhance a PGM image
Specify the level of enhancement
SYNOPSIS
pgmenhance [pgmfile]
PARAMETERS
pgmfile
The path to the portable graymap (PGM) image file to be enhanced. If this argument is omitted, pgmenhance reads the PGM image data from standard input (stdin).
DESCRIPTION
pgmenhance is a utility from the Netpbm toolkit designed to improve the visual quality of portable graymap (PGM) images. It reads a PGM image, typically from a specified file or standard input, and applies an enhancement algorithm. This enhancement usually involves linearly scaling the pixel values to utilize the full dynamic range available in the PGM format, effectively increasing the contrast and brightness of the image. The goal is to make dull or low-contrast grayscale images more distinct and vibrant. The processed image is then written to standard output. This command is particularly useful in shell scripting for basic image manipulation pipelines.
CAVEATS
The enhancement performed by pgmenhance is a simple linear scaling of pixel values. For more advanced or non-linear image adjustments (e.g., histogram equalization, gamma correction, or adaptive contrast), other specialized tools or libraries would be more appropriate.
This command is specifically designed for PGM (grayscale) images. It does not work directly with color images (PPM); they would first need to be converted to PGM format.
STANDARD INPUT AND OUTPUT
pgmenhance is designed to operate seamlessly within Unix-like pipelines. It reads its input PGM image from pgmfile or, if no file is specified, from standard input (stdin). The enhanced PGM image is always written to standard output (stdout). This allows for easy chaining with other Netpbm commands or redirection to a file.
Example: cat input.pgm | pgmenhance > output.pgm
HISTORY
pgmenhance is part of the Netpbm project, a long-standing and widely used collection of graphics file format converters and image processing utilities. The Netpbm package originated from the `pbmplus` toolkit in the early 1990s. Its development has focused on providing simple, robust, and pipe-friendly tools for handling standard bitmap formats, making it a foundational component for many image-related scripting and batch processing tasks in Unix-like environments.