pamditherbw
Dither color images to black and white
TLDR
Read a PGM image, apply dithering and save it to a file
Use the specified quantization method
Use the atkinson quantization method and the specified seed for a pseudo-random number generator
Specify the thresholding value for quantization methods that perform some sort of thresholding
SYNOPSIS
pamditherbw [options] [pam_file]
PARAMETERS
-floyd
Uses the Floyd-Steinberg dithering algorithm. This is the default if no other algorithm is specified, known for its good detail preservation.
-riemersma
Uses the Riemersma dot diffusion dithering algorithm, which produces a distinctive patterned look.
-fsriemersma
Employs a hybrid Floyd-Steinberg/Riemersma dithering algorithm, combining aspects of both methods.
-threshold
Applies simple thresholding (no dithering). Pixels brighter than 50% gray become white, darker become black, resulting in a stark conversion.
-serpentine
Traverses the image in a serpentine (back-and-forth) manner for some algorithms. This can help reduce visual artifacts like banding.
-norandom
Disables the minor random component added by default to some dithering algorithms, which can sometimes reduce subtle patterns at the cost of slightly increased artifact visibility.
-gamma
Applies gamma correction to the input image before dithering. This is useful for accurately representing luminance on displays with non-linear gamma responses.
-random
Introduces a substantial random component into the error distribution during dithering. This can make images look less patterned but potentially noisier.
-seed=N
Sets the seed for the random number generator used by options that include randomness, ensuring reproducible results for development or testing.
-verbose
Prints informational messages to standard error about the processing steps, useful for debugging or understanding the command's operation.
pam_file
The path to the input PAM or PGM file. If omitted, pamditherbw reads the image data from standard input.
DESCRIPTION
pamditherbw is a utility from the Netpbm suite that converts a grayscale image (PAM or PGM) into a black and white (PBM) image using various dithering algorithms.
Dithering is a technique used to create the illusion of color depth in images with a limited color palette (here, just black and white) by scattering pixels of different colors. This command is crucial for displaying grayscale images on monochrome displays or for preparing images for printing on black and white printers, where smooth gradients need to be simulated without actual shades of gray. Different dithering methods can produce distinct visual results, affecting the perceived detail and noise in the output.
CAVEATS
Only one dithering algorithm (e.g., -floyd, -riemersma, -threshold) can be selected at a time. If multiple are specified, the last one on the command line takes precedence.
Input must be in PAM or PGM format; other image formats are not directly supported. Output is always PBM.
INPUT/OUTPUT FORMATS
pamditherbw strictly adheres to the Netpbm ecosystem's format conventions. It expects a PAM or PGM (Portable Graymap) image as its input. Regardless of the input format, the command always produces a PBM (Portable Bitmap) image as its output. This design enables seamless piping with other Netpbm utilities.
DITHERING QUALITY AND ALGORITHMS
The choice of dithering algorithm profoundly influences the visual quality of the resulting black and white image. Floyd-Steinberg is widely preferred for its ability to preserve fine details and smooth gradients by diffusing errors to neighboring pixels, minimizing banding. Riemersma offers an alternative with a more distinct 'dot' pattern. In contrast, simple thresholding provides the fastest conversion but often results in a harsh, blocky appearance, as it makes no attempt to simulate shades of gray.
HISTORY
pamditherbw is a key component of the Netpbm project, an extensive open-source graphics utility toolkit. The Netpbm suite originated from PBMPlus, a package created by Jef Poskanzer in the late 1980s. Netpbm tools, including pamditherbw, are designed for manipulating graphic files using simple, consistent portable formats and stream-based processing. Its evolution includes the addition of support for the more flexible PAM (Portable Arbitrary Map) format, alongside the traditional PGM (Portable Graymap) format.