LinuxCommandLibrary

pnmarith

Perform pixel arithmetic on PNM images

TLDR

Add two images

$ pnmarith -add [image1.pnm] [image2.pnm] > [result.pnm]
copy
Subtract images
$ pnmarith -subtract [image1.pnm] [image2.pnm] > [result.pnm]
copy
Multiply images
$ pnmarith -multiply [image1.pnm] [image2.pnm] > [result.pnm]
copy
Take minimum values
$ pnmarith -minimum [image1.pnm] [image2.pnm] > [result.pnm]
copy

SYNOPSIS

pnmarith operation pnmfile1 pnmfile2

DESCRIPTION

pnmarith performs arithmetic operations on two PNM images pixel by pixel. Images must have same dimensions. Useful for compositing, masking, and image comparison.
Superseded by pamarith in modern Netpbm.

PARAMETERS

-add

Add pixel values.
-subtract
Subtract pixel values.
-multiply
Multiply pixel values.
-difference
Absolute difference.
-minimum
Minimum of pixels.
-maximum
Maximum of pixels.
-mean
Average of pixels.

EXAMPLES

$ # Add two images (blend)
pnmarith -add image1.ppm image2.ppm > blended.ppm

# Create difference image
pnmarith -difference frame1.ppm frame2.ppm > diff.ppm

# Multiply (darken with mask)
pnmarith -multiply image.ppm mask.pgm > masked.ppm

# Find minimum
pnmarith -minimum img1.ppm img2.ppm > min.ppm
copy

CAVEATS

Images must be same dimensions. Results clamped to valid range. Use pamarith for more options.

HISTORY

pnmarith is part of Netpbm by Jef Poskanzer, providing basic image arithmetic operations.

SEE ALSO

pamarith(1), pnmcat(1), pnmcomp(1), netpbm(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community