pixmerge — merge two pix(5) or bw(5) images by a formula
pixmerge Given two streams of data, typically pix(5) or bw(5) images, generate an output stream of the same size, where the value of the output is determined by a formula involving the first (foreground) stream and a constant, or the value of the second (background) stream. This routine operates on a pixel-by-pixel basis, and thus is independent of the resolution of the image. More sophisticated processing can be performed by the pixmatte program.
The formula can be any combination of
-g
(fg greater than bg),
-l
(fg less than bg),
-e
(fg equal to bg),
-n
(fg not equal to bg).
For example,
-le
selects a foreground pixel when it
is lexically less than or equal to the background pixel,
that is, when all bytes of the foreground pixel are less than
or equal to the background pixel.
The
-w#
flag specifies the width (in bytes) of each "pixel"; the default is
3, i.e.
pix(5)
file format. A width of 1 is used for processing
bw(5)
files. It is unclear if other widths are useful.
If the
-C r/g/b
option is specified, then the constant color specified by r/g/b
is used in place of the appropriate background pixel values.
It is expected that there will be up to
width
slash-separated constants given as a single parameter here.
If no formula is specified, the default is to take all foreground pixels greater than black (all bytes zero), which can be specified as: pixmerge -g -C 0/0/0 fg.pix bg.pix
gencolor 200 0 200 | pixmerge -g -C 20/20/20 fg.pix - > out.pix
pixbackgnd -t0 160 200 | pixmerge -n -C 63/0/127 fg.pix - | pix-fb The second example is used to composite an rt(1) generated image on top of a shaded background.