pnminterp
Interpolate between two PNM image files
TLDR
View documentation for the current command
SYNOPSIS
pnminterp [-x_mult=N] [-y_mult=N] [pnmfile]
PARAMETERS
-x_mult=N
Specifies the horizontal (width) multiplication factor. The output image will have a width that is N times the input width. The default value is 2.
-y_mult=N
Specifies the vertical (height) multiplication factor. The output image will have a height that is N times the input height. The default value is 2.
pnmfile
The name of the input PGM file. If this argument is omitted, pnminterp reads the PGM image from standard input.
DESCRIPTION
The pnminterp command is a utility from the Netpbm suite designed to increase the resolution of a grayscale (PGM) image. It achieves this by applying a bilinear interpolation algorithm, which calculates new pixel values based on the weighted average of surrounding pixels. This process smooths out the image, making it appear less blocky when scaled up, especially useful for photographic images.
It takes a PGM image as input, either from a specified file or from standard input, and outputs the higher-resolution PGM image to standard output. Users can specify the horizontal and vertical multiplication factors to control the degree of resolution increase.
CAVEATS
pnminterp is specifically designed for grayscale (PGM) images. While Netpbm tools can often convert other formats to PGM (e.g., using pnmtopgm), the interpolation itself operates only on the PGM data. It uses bilinear interpolation, which is a common but not the most advanced interpolation method; for very high-quality upscaling, other algorithms (e.g., bicubic, Lanczos) might be preferred by specialized image processing software.
USAGE NOTES
pnminterp is typically used in a pipeline with other Netpbm commands. For instance, to interpolate a JPEG image, one would first convert it to PGM (e.g., djpeg | pnmtopgm), then pipe it to pnminterp, and finally convert the output back to a desired format (e.g., pnmtojpeg).
Example:
djpeg image.jpg | pnmtopgm | pnminterp -x_mult=4 -y_mult=4 | pnmtojpeg > interpolated_image.jpg
This command chain converts 'image.jpg' to a PGM, interpolates its resolution by a factor of 4 in both dimensions, and then converts the result back to a JPEG file named 'interpolated_image.jpg'.
HISTORY
pnminterp is part of the Netpbm project, a toolkit for manipulating graphic images. Netpbm has a long history, originating from the PBM (Portable BitMap) utilities created by Jef Poskanzer in 1988. Over time, it expanded to include PGM (Portable GrayscaleMap) and PPM (Portable PixMap) formats, evolving into the comprehensive Netpbm suite. pnminterp was developed to provide a standard way to scale images up while attempting to preserve image quality, a common requirement in image processing workflows.