PAMDITHERBW(1)
π PAMDITHERBW β bestie's guide to making your grayscale pics go black-and-white β¨
okay so real talk, this is pamditherbw from the Netpbm squad (Pamditherbw User Manual, section 1 of the general commands manual, iykyk). she's a general command, she's iconic, she eats, and by the end of this page you'll be dithering like a main character. periodt. π
πΈ NAME πΈ
pamditherbw β dither a grayscale image to black and white. that's the whole job. she does one thing and she does it gorgeously π
β¨ SYNOPSIS β¨
pamditherbw
[-floyd | -fs | -atkinson | -threshold | -hilbert | -dither8 | -d8 |
-cluster3 | -c3 | -cluster4 | -c4 | -cluster8 | -c8]
[-value val]
[-clump size]
[-randomseed=integer]
[pamfile]
All options can be abbreviated to their shortest unique prefix. so yes bestie, you can be lazy, the program will figure out what you meant π«Ά
π¦ DESCRIPTION π¦
okay so first thing: this program is part of Netpbm(1). family business, love that for us.
pamditherbw dithers a grayscale image. and what is dithering, you ask? it's turning each shade of gray into a pattern of black and white pixels that, when you step back and look from a distance, totally read as the same gray. it's giving illusion, it's giving sleight of hand, it's literally magic β¨
the input should be a PGM image or a PAM image of tuple type GRAYSCALE. BUT β and this is the important tea β pamditherbw doesn't check, so if you feed it e.g. a PPM image, it will produce arbitrary results. like, truly random nonsense. (actually, it just takes the first channel of whatever you give it and treats it as if it represented gray levels. so it's not mad, it's just not checking your homework π)
the output is a PAM with tuple type BLACKANDWHITE. if you need to turn that into a PBM (say, because you need to use it with an older program that doesn't understand PAM), just hit it with pamtopnm. easy.
now, to do the opposite of dithering? you can usually just scale the image down and then back up again with pamscale, possibly smoothing or blurring the result with pnmsmooth or pnmconvol. or use the special case program pbmtopgm. so many options, so little time π
want to dither a color image (to reduce the number of pixel colors)? that's a different girl, use ppmdither.
another way to convert a grayscale image to black and white is thresholding. thresholding is simply replacing each grayscale pixel with a black or white pixel depending on whether its brightness is above or below a threshold. and that threshold might vary, which is lowkey fancy. simple thresholding is a degenerate case of dithering, so pamditherbw does very simple thresholding with its -threshold option. but if you want the sophisticated stuff, pamthreshold does more sophisticated thresholding. know the difference, bestie π
and if all you want is to change a PGM image with maxval 1 to a PBM image? pamtopnm will do that. so simple, so slay.
π OPTIONS π
in addition to the options common to all programs based on libnetpbm (most notably -quiet, see Common Options β go look at it, bestie), pamditherbw recognizes the following command line options:
π Quantization Method π
the default quantization method is boustrophedonic Floyd-Steinberg error diffusion (-floyd or -fs). yes that's a real sentence. yes I had to double check the spelling. it's iconic, don't question it.
also available:
- simple thresholding (
-threshold) - Bayer's ordered dither (
-dither8) with a16x16matrix - Atkinson
- three different sizes of 45-degree clustered-dot dither (
-cluster3,-cluster4,-cluster8)
and there's a space filling curve halftoning method using the Hilbert curve too (-hilbert). we love a curve that fills space, main character energy fr fr π
Floyd-Steinberg or Atkinson will almost always give the best looking results; however, looking good is not always what you want. shocking, I know. for instance, you can use thresholding in a pipeline with the pnmconvol, for tasks such as edge and peak detection. and clustered-dot dithering gives a newspaper-ish look, a useful special effect. aesthetic.
Floyd-Steinberg is by far the more traditional, but some claim Atkinson works better. drama. we love a rivalry π
the Hilbert curve method is useful for processing images before display on devices that do not render individual pixels distinctly (like laser printers). this dithering method can give better results than the dithering usually done by the laser printers themselves. the -clump option alters the number of pixels in a clump. typically a PGM image will have to be scaled to fit on a laser printer page (2400 x 3000 pixels for an A4 300 dpi page), and then dithered to a PBM image before being converted to a postscript file. a printing pipeline might look something like:
pamscale -xysize 2400 3000 image.pgm | pamditherbw -hilbert | \
pamtopnm | pnmtops -scale 0.25 > image.ps
go off, pipeline π
β¨ Other Options β¨
-valueβ this option alters the thresholding value for Floyd-Steinberg, Atkinson, and simple thresholding. it should be a real number between0and1. above0.5means darker images; below0.5means lighter. pick your vibe.-clumpβ this option alters the number of pixels in a clump when the Hilbert curve method is used. this is usually an integer between2and100(default5). smaller clump sizes smear the image less and are less grainy, but seem to lose some grey scale linearity. tradeoffs babes, always tradeoffs.-randomseed=integerβ the Floyd-Steinberg and Atkinson methods use random numbers to diffuse the error. this is the seed for the random number generator. the other methods do not employ random numbers and ignore this option. use this to ensure you get the same image on separate invocations. by default,pamditherbwuses a seed derived from the time of day and process ID, which gives you fairly uncorrelated results in multiple invocations. reproducible queen β¨
this option was new in Netpbm 10.45 (December 2008).
π REFERENCES π
the only reference you need for this stuff is "Digital Halftoning" by Robert Ulichney, MIT Press, ISBN 0-262-21009-6.
the Hilbert curve space filling method is taken from "Digital Halftoning with Space Filling Curves" by Luiz Velho, Computer Graphics Volume 25, Number 4, proceedings of SIGRAPH '91, page 81. ISBN 0-89791-436-8
like, academic and slay. we stan a cited source π«Ά
π SEE ALSO π
pamtopnm(1), pgmtopgm(1), pbmtopgm(1), pamthreshold(1), pbmreduce(1), pnmconvol(1), pamscale(1), pam(1), pnm(1)
the whole friend group. go say hi π
π°οΈ HISTORY π°οΈ
pamditherbw was new in Netpbm 10.23 (July 2004), but is essentially the same program as pgmtopbm that has existed practically since the beginning. a legend reborn.
pamditherbw differs from its predecessor in that it properly adds brightnesses (using gamma transformations; pgmtopbm just adds them linearly) and that it accepts PAM input in addition to PGM and PBM and produces PAM output. glow up fr fr.
pamditherbw obsoletes pgmtopbm. rip to a real one π
-atkinson was new in Netpbm 10.38 (March 2007).
βοΈ AUTHOR βοΈ
Copyright (C) 1989 by Jef Poskanzer.
π DOCUMENT SOURCE π
this manual page was generated by the Netpbm tool 'makeman' from HTML source. the master documentation is at
http://netpbm.sourceforge.net/doc/pamditherbw.html
π‘ friendly reminder bestie: pamditherbw does not check its input type. if you feed it a PPM it will just quietly produce arbitrary results on the first channel. no warning, no drama, just chaos. be careful out there π
and that's the whole page, bestie. this was netpbm documentation, dated 10 May 2010, from the Pamditherbw User Manual(1) β you've officially read the entire thing and I'm so proud of you. go dither something gorgeous. mwah πβ¨ππ¦
π¦ where this page comes from
- debian bookworm: netpbm 2:11.01.00-2 Β· MIT
- debian trixie: netpbm 2:11.10.02-1 Β· MIT
- ubuntu noble: netpbm 2:11.05.02-1.1build1 Β· MIT
- ubuntu resolute: netpbm 2:11.10.02-1build1 Β· MIT
- ubuntu stonking: netpbm 2:11.13.03+ds-2 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms