Skip to documentation
DocumentationAll documentsEnglish

PIXELSWAP(1)

NAME

pixelswap - interchange two pixel colors in a pix image

On this page

SYNOPSIS

pixelswap [-d _pixeldepth_] _r_ _g_ _b_ _R_ _G_ _B_ < input.pix > output.pix

DESCRIPTION

pixelswap reads a stream of RGB pix(5) data from standard input and exchanges two specific colors named on the command line. Any pixel matching the first color (r g b) is rewritten as the second color (R G B), and any pixel matching the second color is rewritten as the first. All other pixels are passed through to standard output unchanged.

Each of the six color components is an integer in the range 0-255. Both standard input and standard output must be redirected; pixelswap refuses to run if either is a terminal.

Although a pixel depth may be specified with -d, the current implementation always processes 3-byte RGB pixels and ignores the requested depth.

OPTIONS

-d pixeldepth

Number of bytes per pixel (must be a positive integer). Accepted for forward compatibility but currently ignored; pixels are always treated as 3-byte RGB.

-h, -?

Print a usage message and exit.

EXAMPLES

Example 1. Recolor a rendered frame
rt -o frame.pix scene.g region > /dev/null
pixelswap 255 0 0 0 0 255 < frame.pix > swapped.pix

Ray traces a model with rt(1), then swaps every pure-red pixel for pure-blue and every pure-blue pixel for pure-red, producing swapped.pix. This is a quick way to re-key flat region colors without re-rendering the scene.

SEE ALSO

brlcad(1), pix-png(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