Skip to documentation
DocumentationAll documentsEnglish

BWSTAT(1)

NAME

bwstat - display statistics of a black and white image

On this page

SYNOPSIS

bwstat [-v] [file.bw]

DESCRIPTION

bwstat reads a bw(5) format file (or standard input) and computes statistics of its pixel intensities. These include the total number of pixels, the file dimensions (assuming the image is square), minimum and maximum values, mean, median, mode (and its pixel count), variance, standard deviation, and skew.

OPTIONS

-v

Verbose mode. After the statistics, print the full histogram of pixel values: each intensity from 0 to 255, its pixel count, and its percentage of the total.

-h, -?

Print a usage message and exit.

file.bw

Optional input file. If not provided, bwstat reads from standard input.

EXAMPLES

Example 1. Summarize the intensity distribution of an image
bwstat moss.bw

Reports the pixel count, inferred square dimensions, minimum, maximum, mode, median, mean, standard deviation, variance, and skew for the intensities in moss.bw.

Example 2. Inspect a histogram piped from another tool
pix-bw scene.pix | bwstat -v

Converts a color pix(5) image to black and white with pix-bw(1) and pipes it straight into bwstat, which prints the statistics followed by the complete 0-255 histogram without writing an intermediate file.

METHOD

Since the pixel values are quantized (have discrete values from 0 to 255), the statistics can be computed from "lump sums" after building a histogram of the input. This results in a significant savings in computation while also making a single pass over the input file sufficient.

SEE ALSO

brlcad(1), bwhist(1), pix-bw(1), pixstat(1), bw(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