pbmnoise
Add random noise to PBM image
TLDR
Generate a PGM image containing white noise
Specify the seed for the pseudo-random number generator
Specify the desired rate of white to black pixels
SYNOPSIS
pbmnoise [-randomseed=N] [-density=F] width height
PARAMETERS
-randomseed=N
Specifies an integer N to use as the seed for the pseudo-random number generator. Providing a fixed seed ensures that the output image is identical every time the command is run with the same parameters. If this option is omitted, a seed based on the current time and process ID is used, resulting in a different image each time.
-density=F
Sets the probability that any given pixel in the output image will be black (represented as 1 in the PBM format). F must be a floating-point number between 0.0 and 1.0, inclusive. A value of 0.5 (the default) produces an image with roughly half black and half white pixels. A value of 0.0 results in an entirely white image, while 1.0 results in an entirely black image.
width
The desired width of the output PBM image, specified in pixels. This is a mandatory argument.
height
The desired height of the output PBM image, specified in pixels. This is a mandatory argument.
DESCRIPTION
pbmnoise is a utility from the Netpbm tools suite designed to create a Portable BitMap (PBM) image filled with pseudo-random noise. The PBM format is a simple monochrome (black and white) image format. This command allows users to specify the exact width and height of the output image in pixels.
Furthermore, it provides control over the 'density' or 'randomness' of the noise, which translates to the probability of a pixel being black. This feature enables the generation of images ranging from sparse speckles to dense patterns. pbmnoise is particularly useful for testing image processing algorithms, generating random patterns for various applications, or as a fundamental source image to be further transformed by other Netpbm utilities. Like most Netpbm commands, its output is directed to standard output, making it highly composable via pipes.
CAVEATS
The random numbers generated by pbmnoise are pseudo-random, not cryptographically secure. While suitable for visual noise, they should not be used for security-sensitive applications.
Generating very large images with pbmnoise can consume significant system resources (memory and disk space) if the output is redirected to a file. Users should be mindful of potential resource limitations.
STANDARD I/O USAGE
Consistent with the Netpbm design philosophy, pbmnoise writes its generated PBM image data to standard output. This makes it highly flexible and composable, allowing its output to be seamlessly piped as input to other Netpbm commands (e.g., pbmtopgm for grayscale conversion, pbmscale for resizing) or redirected to a file for storage (e.g., pbmnoise 100 100 > noise.pbm
).
OUTPUT FORMAT
The command exclusively outputs images in the PBM (Portable BitMap) format. This is the simplest of the Netpbm formats, supporting only two colors: black and white. In PBM files, pixels are typically represented by 0 for white and 1 for black, making it ideal for monochrome binary patterns like noise.
HISTORY
pbmnoise is a longstanding component of the Netpbm package, which itself originated from Pbmplus created by Jef Poskanzer in the late 1980s. The Netpbm suite has been continuously developed and maintained, with Bryan Henderson leading much of its recent stewardship. Commands like pbmnoise embody the Netpbm philosophy of providing simple, specialized tools that can be easily combined to perform complex image manipulations, a design principle that has remained consistent throughout its history.