bwthresh [-h | -?] _val_... < file.bw > output.bw
BWTHRESH(1)
NAME
bwthresh - threshold a black-and-white bw file into intensity bins
On this page
SYNOPSIS
DESCRIPTION
bwthresh reads a stream of black-and-white data in bw(5) format from standard input, quantizes each pixel value against the supplied threshold values, and writes the resulting bw(5) data to standard output.
Given n threshold values, the grayscale range 0-255 is divided evenly into
n+1 output bins. Each input pixel is compared against the thresholds in
order: the first threshold the pixel is less than selects its bin, and the
pixel is replaced by that bin’s representative intensity. Bin i (for i
from 0 to n-1) is assigned the value 256 * i / n, and the final bin is
assigned 255.
The threshold values are positional arguments. They must be integers in the range 0-255, given in strictly increasing order, and no more than 255 may be supplied.
OPTIONS
- -h, -?
-
Print a usage message and exit. Recognized only when given as the sole argument.
- val…
-
One or more threshold values. Each must be an integer between 0 and 255 inclusive, and the values must be listed in strictly increasing order.
EXAMPLES
pix-bw photo.pix | bwthresh 85 170 > poster.bw
Convert a color pix(5) image to grayscale with pix-bw(1), then collapse it to three flat intensity levels: pixels below 85 become 0 (black), pixels below 170 become 128 (mid-gray), and the rest become 255 (white). This is a quick way to produce a hard-edged, posterized mask from a continuous-tone image.
bwthresh 128 < input.bw > mask.bw
With a single threshold, every pixel below 128 becomes 0 and every pixel at or above 128 becomes 255, yielding a pure black-and-white mask.
SEE ALSO
brlcad(1), bwmod(1), bwstat(1), bwhisteq(1), pix-bw(1), bw(5)
AUTHOR
BRL-CAD Team
COPYRIGHT
This software is Copyright (c) 1991-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