PIXMATTE(1)

NAME
pixmatte - matte (merge) two pix(5) or bw(5) images by a formula

SYNOPSIS
pixmatte [-a] [-w bytes_wide] [-glen] in1 in2 true_out false_out > output

DESCRIPTION
Given four streams of data elements, where element is of arbitrary width, typically pix(5) or bw(5) images, pixmatte outputs a stream of the same number of data elements. The value of the output stream is determined element-by-element, by comparing the first (foreground) input stream with the the second (background, or matte) input stream. If the formula holds true, the element from the true-output stream is written, otherwise, the element from the false-output stream is written. Each of these streams comes from a file, or is given as a constant. A particular file may be used to feed more than one stream, and the name '-' specifies stdin. For example, the forground file may also be the true-output file. This routine operates on an element-by-element basis, and thus is independent of the resolution of the image.

The formula can be any combination of -g (in1 greater than in2), -l (in1 less than in2), -e (in1 equal to in2), -n (in1 not equal to in2). For example, -ge specifies in1 greater than or equal to in2.

The -a flag can be used with -n or -e to specify approximately equal or approximately not equal to match dithered backgrounds. Approximate equality exists when all bytes in the elements match to within plus or minus one.

For example, -le is true when in1 is lexicaly less than or equal to in2, that is, when all bytes of the in1 element are less than or equal to the bytes of the in2 element. The -w# flag specifies the width (in bytes) of each element; the default is 3, ie pix(5) file format. A width of 1 is used for processing bw(5) files. It is unclear if other widths are useful.

A constant value is specified instead of a filename if the first character of the file name is a equal sign '='. The value is specified as a slash separated string of width decimal numbers, with no separating white space.

EXAMPLES

To compare all foreground pixels to black (all bytes zero), selecting the forground pixels when true and a background elsewhere, specify:

   pixmatte -g fg.pix =0/0/0 fg.pix bg.pix

To keep all foreground pixels greater than 20/20/20, and replace all those less than or equal to it with 200/0/200, use:

      pixmatte -g fg.pix =20/20/20 fg.pix =200/0/200

To keep all foreground pixels which are not equal to 63/0/127, and to replace those which are equal with a generated background from stdin, use the following commands. This can be useful when compositing an rt(1) generated image on top of a nicer background.

      pixbackgnd -t0 160 200 |
      pixmatte -n fg.pix =63/0/127 fg.pix - |
      pix-fb

To produce a black-and-white stencil matte file for futher processing, use:

      pixmatte -n fg.pix bg.pix =255/255/255 =0/0/0

To set to black all pixels that approximately match (by +/- 1) a given background file, use:

      pixmatte -a -e fg.pix bg.pix =0/0/0 fg.pix

SEE ALSO
brlcad(1), gencolor(1), pixbackgnd(1), pixmerge(1), pix(5), bw(5)

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