LinuxCommandLibrary

pbmnoise

Add random noise to PBM image

TLDR

Generate a PGM image containing white noise

$ pbmnoise [width] [height] > [path/to/output.pbm]
copy

Specify the seed for the pseudo-random number generator
$ pbmnoise [width] [height] -randomseed [value] > [path/to/output.pbm]
copy

Specify the desired rate of white to black pixels
$ pbmnoise [width] [height] -ratio [1/3] > [path/to/output.pbm]
copy

SYNOPSIS

pbmnoise [-randomseed=N] [width [height]]

PARAMETERS

-randomseed=N
    Integer N seeds the pseudo-random number generator for reproducible noise (default: time-based)

width
    Output image width in pixels (default: 128)

height
    Output image height in pixels (default: 128 if unspecified)

DESCRIPTION

pbmnoise is a simple command from the Netpbm graphics toolkit that produces a portable bitmap (PBM) image filled with binary noise. Each pixel is independently set to black with probability 0.5 (Bernoulli distribution), creating uniform random speckle.

Default output dimensions are 128x128 pixels. Custom sizes can be specified, and randomness is controlled via a seed for reproducible results. The tool reads no input and writes raw PBM to standard output, suitable for piping into other Netpbm filters like pnmscale or pnmtopng.

Ideal for generating test patterns in image processing, synthetic data for algorithms, or textured backgrounds. The pseudo-random generator uses a linear congruential method, ensuring fast generation but not cryptographic quality.

CAVEATS

Pseudo-random only; same seed yields identical output. Large dimensions may consume significant memory/output size. No color or grayscale variants (use pgmnoise or ppmnoise).

EXAMPLE USAGE

pbmnoise -randomseed=42 256 256 | pnmtopng > noise.png
pbmnoise 512 | pnmscale -xscale=2 -yscale=2 > large_noise.pbm

OUTPUT NOTES

Always plain PBM format (P1 header); use pnmquant or viewers for display.

HISTORY

Introduced in early Netpbm releases (~1991) by Jef Poskanzer; stable in modern versions for PBM noise generation.

SEE ALSO

pgmnoise(1), ppmnoise(1), pbmmake(1), pbm(5)

Copied to clipboard