LinuxCommandLibrary

pnmsmooth

Smooth a portable bitmap image

TLDR

Smooth out a PNM image using a convolution matrix of size 3x3

$ pnmsmooth [path/to/input.pnm] > [path/to/output.pnm]
copy

Smooth out a PNM image using a convolution matrix of size width times height
$ pnmsmooth [[-w|-width]] [width] [[-h|-height]] [height] [path/to/input.pnm] > [path/to/output.pnm]
copy

SYNOPSIS

pnmsmooth [-filter=width] [-passes=N] [pnmfile]

PARAMETERS

-filter=width
    Specifies the width of the square boxcar filter. The default width is 3. A width of 1 means no smoothing is performed.

-passes=N
    Determines how many times the smoothing filter is applied. The default is 1 pass. N must be at least 1.

DESCRIPTION

The pnmsmooth command is a utility within the Netpbm suite designed to smooth PNM (Portable Anymap) images. It reads a PNM image from standard input or a specified file and outputs a smoothed version to standard output. The smoothing process involves replacing each pixel with the average value of itself and its surrounding neighbors. This operation is effectively a convolution with a square boxcar filter, which helps to reduce noise and blur the image. Users can control the extent of smoothing by adjusting the filter's width and specifying multiple application passes. For instance, several passes with a small filter can achieve similar results to a single pass with a larger filter, often with better computational efficiency.

INPUT AND OUTPUT

If no pnmfile is specified, pnmsmooth reads the PNM image from standard input. The smoothed PNM image is always written to standard output.

PERFORMANCE CONSIDERATION

Applying multiple passes with a smaller filter (e.g., three passes with a filter width of 3) can often achieve a smoothing effect comparable to a single pass with a larger filter (e.g., width of 7), but with significantly improved computational performance and reduced processing time.

HISTORY

Originating from the PBMPLUS package, pnmsmooth was integrated into the Netpbm suite in 1992. Significant enhancements were made in 1995 by Bryan Henderson, who added the -passes option and made the filter width configurable, significantly improving its flexibility and efficiency.

SEE ALSO

pnmconvol(1), pnmnoisereduce(1), pnm(5)

Copied to clipboard