Skip to documentation
DocumentationAll documentsEnglish

BWRECT(1)

NAME

bwrect - extract a rectangle from a black and white bw file

On this page

SYNOPSIS

bwrect [-s squaresize] [-w width] [-n height] [-S out_squaresize] [-W out_width] [-N out_height] [-x xorig] [-y yorig] [-o out_file.bw] [file.bw] [> out_file.bw]

DESCRIPTION

bwrect extracts a rectangular region from a black and white bw(5) format file. The default input image size is 512x512. The output width and height must be explicitly specified (using -W and -N, or -S), as they default to zero.

If an input file is not specified, bwrect reads from standard input. If an output file is not specified via the -o option, bwrect writes to standard output. This allows the utility to be easily used within pipelines.

OPTIONS

-s squaresize

Set both the width and height of the input image to squaresize in pixels.

-w width

Specify the width of the input image in pixels (default is 512).

-n height

Specify the height of the input image in scanlines (default is 512).

-S out_squaresize

Set both the width and height of the extracted output rectangle to out_squaresize in pixels.

-W out_width

Specify the width of the extracted output rectangle in pixels.

-N out_height

Specify the height of the extracted output rectangle in scanlines.

-x xorig

Specify the x-coordinate of the origin for the extraction (default is 0).

-y yorig

Specify the y-coordinate of the origin for the extraction (default is 0). The origin corresponds to the lower-left corner.

-o out_file.bw

Specify the name of the output file. If standard output is also redirected or piped, bwrect writes the same output to both destinations. If -o is not provided, output is written to standard output.

EXAMPLES

Example 1. Extracting a 256x256 rectangle from a 1024x1024 image
$ bwrect -s 1024 -S 256 -x 0 -y 0 in.bw > out.bw

This command extracts a 256x256 rectangle from the lower-left corner of the 1024x1024 image in.bw and writes it to out.bw using standard output redirection.

Example 2. Extracting a 100x100 region with a specific origin and output file
$ bwrect -W 100 -N 100 -x 200 -y 200 -o out.bw in.bw

This command extracts a 100x100 rectangle starting at coordinate (200, 200) from an image of default size (512x512) and saves it directly to out.bw using the -o option.

SEE ALSO

brlcad(1), bwcrop(1), bwscale(1), pixrect(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