LinuxCommandLibrary

ppmcolormask

Create bitmap mask from color selection

TLDR

Create mask for color

$ ppmcolormask [color] [input.ppm] > [mask.pbm]
copy
Mask for red
$ ppmcolormask red [input.ppm] > [mask.pbm]
copy
Mask for hex color
$ ppmcolormask "#ff0000" [input.ppm] > [mask.pbm]
copy
Mask for RGB value
$ ppmcolormask "rgb:ff/00/00" [input.ppm] > [mask.pbm]
copy

SYNOPSIS

ppmcolormask color [ppmfile]

DESCRIPTION

ppmcolormask creates a bitmap mask from a PPM image where matching pixels are white (1) and non-matching are black (0). Useful for selecting regions by color.
Part of Netpbm toolkit.

PARAMETERS

color

Target color (name, hex, or rgb format).

EXAMPLES

$ # Mask white pixels
ppmcolormask white image.ppm > white_mask.pbm

# Mask specific color
ppmcolormask "#00ff00" image.ppm > green_mask.pbm

# Use mask to replace color
ppmcolormask blue original.ppm > mask.pbm
pnmpaste replacement.ppm 0 0 original.ppm -and mask.pbm > result.ppm

# Chain with conversion
jpegtopnm photo.jpg | ppmcolormask red | pnmtopng > red_mask.png
copy

COLOR FORMATS

$ Named:  red, green, blue, white, black...
Hex:    #rrggbb or #rgb
RGB:    rgb:rr/gg/bb
copy

CAVEATS

Exact color match only. For range matching, use pamfunc or similar. Output is PBM bitmap.

HISTORY

ppmcolormask is part of Netpbm by Jef Poskanzer, providing color-based masking functionality.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community