← 返回命令列表

Linux command

ppmcolormask 命令

文本

涉及管道、覆盖或删除,执行前请先确认路径和参数。

常用示例

Mask a single color

ppmcolormask -color=[red] [input.ppm] > [mask.pbm]

Mask several colors at once

ppmcolormask -color=[red,pink,salmon] [input.ppm] > [mask.pbm]

Use a hex/RGB color

ppmcolormask -color=[rgb:ff/00/00] [input.ppm] > [mask.pbm]

Use Berlin-Kay fuzzy color matching

ppmcolormask -color=[bk:red,bk:orange] [input.ppm] > [mask.pbm]

Obsolete positional form

ppmcolormask [red] [input.ppm] > [mask.pbm]

Feed a non-PPM image via pipe

jpegtopnm [photo.jpg] | ppmcolormask -color=[white] > [mask.pbm]

说明

ppmcolormask reads a PPM image and writes a PBM bitmap of the same dimensions. In the output, pixels matching any color in the -color list are black; all other pixels are white. The resulting mask is meant to be fed to programs such as pamcomp (as an alpha channel) or used with pnmpaste for region replacement. The Berlin-Kay (`bk:`) form applies a Sugeno-type fuzzy inference over HSV values, so related shades of a named color all match. The positional (non-`-color`) form is retained only for backwards compatibility and supports just one exact color. If _ppmfile_ is omitted, input is read from standard input; output is always written to standard output.

参数

-color=_color_list_
Mandatory. Comma-separated list of colors to mask. Each color may be a named color (`red`), a hex/rgb specifier (`rgb:ff/00/00`, `#ff0000`), or a Berlin-Kay fuzzy match prefixed with `bk:`.
-quiet
Common libnetpbm option: suppress informational messages on stderr.

FAQ

What is the ppmcolormask command used for?

ppmcolormask reads a PPM image and writes a PBM bitmap of the same dimensions. In the output, pixels matching any color in the -color list are black; all other pixels are white. The resulting mask is meant to be fed to programs such as pamcomp (as an alpha channel) or used with pnmpaste for region replacement. The Berlin-Kay (`bk:`) form applies a Sugeno-type fuzzy inference over HSV values, so related shades of a named color all match. The positional (non-`-color`) form is retained only for backwards compatibility and supports just one exact color. If _ppmfile_ is omitted, input is read from standard input; output is always written to standard output.

How do I run a basic ppmcolormask example?

Run `ppmcolormask -color=[red] [input.ppm] > [mask.pbm]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -color=_color_list_ do in ppmcolormask?

Mandatory. Comma-separated list of colors to mask. Each color may be a named color (`red`), a hex/rgb specifier (`rgb:ff/00/00`, `#ff0000`), or a Berlin-Kay fuzzy match prefixed with `bk:`.