D-BW(1)
π d-bw π
okay so bestie, welcome to d-bw from the BRL-CAD manual set β yes, that BRL-CAD, the iconic one π. this page is gonna walk you through converting double-precision binary numbers into unsigned bytes, and honestly? it's giving pipeline-glamour. let's go β¨
πΈ NAME πΈ
d-bw β convert double-precision binary numbers to unsigned bytes. that's the whole vibe. no cap π«Ά
β¨ SYNOPSIS β¨
d-bw [-n | scale] < doubles > unsigned_chars
like, you feed it doubles on stdin and it hands you unsigned chars on stdout. main character pipeline energy π
π¦ DESCRIPTION π¦
okay so picture this: d-bw reads a stream of machine-native double-precision (8-byte) binary floating point values from standard input, multiplies each one by a scale factor, and writes the result out as a stream of unsigned bytes (one 8-bit value each) to standard output. literally that's it, that's the whole job π
and why would you do this? because it's typically used to turn a floating point signal or a single-channel image into raw 8-bit pixel data suitable for bw(5) imagery. so it's the glow-up pipeline from "floaty science data" to "pixels you can actually look at" π₯
here's the part where you gotta pay attention though, bestie π β each scaled value gets clamped to the range 0 through 255. values above 255.0 are written as 255, and values below 0.0 are written as 0. no wraparound nonsense, no drama, just clamp. when any clamping occurs, the count of high and low clips is reported on standard error β so it tells you when it had to yank something back into range, which is honestly so considerate of it π
the scale factor defaults to 1.0. supplying a numeric scale argument multiplies every input value by that factor before conversion. and the -n flag? that's shorthand for a scale of 255.0, which maps normalized data in the range 0.0 to 1.0 onto the full 0 to 255 byte range. it's giving "one-flag wonder" π
and because the input is raw binary, d-bw refuses to run when standard input is a terminal. makes sense β imagine typing binary floats at your keyboard, that would be a nightmare fr fr π the inverse conversion, from unsigned bytes back to binary doubles, is performed by u-d(1). so they're a matching set, iykyk π«Ά
π¨ deprecation alert, bestie π¨ β this command is deprecated and is scheduled for removal. it prints a deprecation warning on startup. so like, it still slays, but it's on its way out. use it, love it, but don't build your whole life around it π
π OPTIONS π
-nβ normalize the data by using a scale factor of255.0, mapping input values in the range0.0to1.0onto the output range0to255. the easy-mode flag for normalized data β¨scaleβ a numeric scale factor by which each input value is multiplied before being clamped and written as a byte. defaults to1.0. mutually exclusive with-nβ pick one, bestie, you can't have both π
π EXAMPLES π
Example 1. Convert a normalized double stream to a bw image
d-bw -n < ramp.d > ramp.bw
reads doubles in the range 0.0 to 1.0 from ramp.d and writes a single-channel 8-bit bw(5) image, scaling each value across the full 0 to 255 range so it can be viewed with bw-pix(1) or pix-fb(1). literally the classic use case, iconic behavior π
Example 2. Apply a custom gain
dmod -m 100 < signal.d | d-bw 2.5 > signal.bw
processes a double-precision signal with dmod(1), then scales each sample by 2.5 while converting to bytes, brightening the result and reporting on standard error how many samples were clipped. it's a whole two-tool combo and it ate π₯
π SEE ALSO π
brlcad(1), u-d(1), bw-d(1), dmod(1), dconv(1), bw(5)
go read those too, bestie, they're all part of the same friend group π«Ά
πΈ 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
don't be shy, they're nice, and finding a bug is basically a gift π
π okay that's the whole page, bestie β go convert some doubles and slay π
and that's the sign-off! this whole thing came to you from the BRL-CAD manual, page D-BW(1) β you're welcome, mwah ππ
π¦ 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