U-BW(1)

πŸ“¦ version 7.44.0, in nixpkgs unstable

πŸ’… 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 modulo 256.

🌈 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 πŸ’œ


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