Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  BWMOD (1)

.ds Aq ’


bwmod - arithmetically modify pixel values in black and white bw file



bwmod [-c] [-a add -s sub -m mult -d div -A -e exp -r root...] . <


Bwmod will perform a series of arithmetic operations on each 8-bit pixel of its input/output stream. This is a bw(5) file format. The pixel values range from 0 to 255 and are internally operated on in floating point form (unless the -c option has been specified) so that dynamic range, truncation, and sign, are not a problem. On output they are converted back to 8-bit unsigned values clipping to 0 and 255 if necessary. The number of pixels clipped high and low, if any, are reported to standard error on completion.

If the -c option is specified, then intermediate results are stored as signed characters, though the command line arguments remain in floating point format. This is useful when one wishes to take advantage of wrap-around characteristics of binary mathematics.

Any number of operations can be given and they are applied in order. The choices are:

-a val to add a value.

-s val to subtract a value.

-m val to multiply by a value.

-d val to divide by a value.

-A to take to absolute value of each pixel.

-e val to exponentiate, i.e. raise each pixel to the power val.

-r val to take the val root of each pixel.

All arguments can be floating point values. Note that this command can be applied to color pix(5) files also, but no distinction can be made between color planes.


The command

bwmod -m-1 -a255 < > will produce the negative of a file by first multiplying by minus one, and then adding 255 to shift the pixels back into the 0->255 range.

One can apply a gamma factor to a file as follows:

bwmod -d255 -r2.2 -m255 < > which will first normalize the pixel values, then take the 2.2 root of each pixel, and finally scale it back to 0->255. [Note however that applying gammas this way is not recommended since a function call per pixel results!]

Suppose you ran bwstat on a file and found min=80, max=210, mean=100. If you wish to expand the range of intensities, while still preserving the mean, this can be done by: bwmod -s100 -m1.409 -a100 < > Where 1.409 results from (255-100)/(210-100) which is what one would use by boost the max value (210) to full scale (255) after subtracting the mean (100). Subtracting and adding 100 make the multiply occur "about that point", i.e value less than 100 will get smaller; those above, higher.


brlcad(1), pix(5), bw(5)




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


Reports of bugs or problems should be submitted via electronic mail to <>.

Search for    or go to Top of page |  Section 1 |  Main Index

BRL-CAD BWMOD (1) 04/04/2016

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.