Skip to documentation
DocumentationAll documentsEnglish

PIXSUBST(1)

NAME

pixsubst - substitute one color for another in a pix image

On this page

SYNOPSIS

pixsubst [_R_in_ _G_in_ _B_in_] _R_out_ _G_out_ _B_out_ < pixfile_in > pixfile_out

DESCRIPTION

pixsubst reads a pix(5) format image on standard input and writes it to standard output, replacing every pixel whose color matches the input color {R_in G_in B_in} with the output color {R_out G_out B_out}. All six values are integers in the range 0 to 255.

If the input color {R_in G_in B_in} is omitted (only three values are given), the color of the very first pixel in the input stream is taken as the color to be replaced. That first pixel is itself substituted as well, so a fully uniform background can be recolored without knowing its exact value.

Pixels that do not match the input color are passed through unchanged.

EXAMPLES

Example 1. Replace a known background color
pixsubst 0 0 0 255 255 255 < scene.pix > scene-white-bg.pix

Every pure-black pixel ({0 0 0}) in scene.pix is changed to white ({255 255 255}); all other pixels are left alone. This is handy for swapping a black background for a white one before compositing.

Example 2. Recolor the background using the first pixel as a key
pixsubst 18 52 86 < input.pix | pix-fb -F /dev/X

Omitting the input color makes pixsubst sample the first pixel of input.pix as the color to replace, substituting it with {18 52 86}. The result is piped to pix-fb(1) for display, which is useful when the exact background value is unknown but is known to be the top-left pixel.

SEE ALSO

brlcad(1), pix-fb(1), pixfilter(1), pixmatte(1), pix(5)

AUTHOR

BRL-CAD Team

This software is Copyright (c) 1989-2026 by the United States Government as represented by U.S. Army Research Laboratory.

BUG REPORTS

Reports of bugs or problems should be submitted via electronic mail to devs@brlcad.org