U-BW(1)
π U-BW(1) β the BRL-CAD glow-up where shorts become bytes β¨
okay so bestie, welcome to u-bw, straight out of the BRL-CAD fam π«Ά this is the page for the little tool that takes your chunky 16-bit numbers and serves them as cute lil 8-bit bytes. let's get into it π
β¨ NAME β¨
u-bw β convert unsigned shorts to unsigned chars, aka 8-bit bw data π
π¦ SYNOPSIS π¦
u-bw [-l] < u_shorts > bwfile
πΈ DESCRIPTION πΈ
So here's the vibe: u-bw reads a stream of 16-bit unsigned short integers from standard input and writes a stream of 8-bit unsigned chars to standard output π and what comes out is perfect for using as a bw(5) black and white image, or honestly any other unsigned char data stream you feel like feeding it π
By default, each unsigned short gets squished down to a single byte by taking the high-order byte β that's a right shift of 8 bits, bestie β which scales the full 0-65535 range down to 0-255. iconic behaviour, no notes π₯
But if you pass -l, the low-order byte is the one that survives instead, which is effectively taking each value modulo 256. different byte, same energy β¨
π¨ real talk: both standard input and standard output must be redirected. if either one is a terminal, u-bw prints a usage message and exits. no terminal shenanigans allowed, periodt π
Data is processed in blocks of 512 values, so the byte ordering of the shorts is that of the host machine π₯οΈ (yes, that means endianness of your machine is the main character here, iykyk).
π OPTIONS π
-lβ keep the low-order (least significant) byte of each unsigned short instead of the default high-order byte π₯° this is equivalent to taking each input value modulo256.
π EXAMPLES π
β Example 1. Down-scale 16-bit samples to an 8-bit bw image
u-bw < heightfield.shorts > heightfield.bw
pix-fb -F /dev/X heightfield.bw
Convert a file of unsigned shorts (like, say, a 16-bit elevation or sensor grid π) into 8-bit bw(5) data by taking the high byte of each sample β and then show it off on a framebuffer with pix-fb(1). main character energy, honestly π
β Example 2. Keep the low byte to inspect fine detail
u-bw -l < data.shorts > low.bw
Retain the least significant byte of each short instead of the high byte β lowkey useful for examining the low-order bits of the source values ππ
π§ SEE ALSO π§
brlcad(1), u-a(1), u-d(1), u-f(1), bw-d(1), bw(5)
π AUTHOR π
BRL-CAD Team π
π COPYRIGHT π
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 π (they're literally waiting to hear from you, bestie).
okay that's the whole page, mwah π β this was U-BW(1) from BRL-CAD, and that's the whole sign-off from me, your favorite manual-writing bestie πΈπ¦ (page label's still U-BW(1) at the bottom too, don't worry, we keep the branding consistent π
).
π¦ where this page comes from
- nixpkgs unstable: brlcad 7.44.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms