Floyd-Steinberg dithering

OCTOBER 8, 2022

Floyd-Steinberg dithering

Last December, I discovered the algorithm I had been using in Photoshop to export illustrations for the Getting Simple Bytes series.

It's called Floyd-Steinberg dithering, as it was first published in 1976 by Robert W. Floyd and Louis Steinberg1.

The algorithm is available in ImageMagick for free, so I can easily apply this filter to any image with the following command-line call.

convert \
    -brightness-contrast 0x5 \
    in.jpg \
    -resize 768 \
    -background white \
    -flatten \
    -dither FloydSteinberg \
    -monochrome \
    -colors 2 \

I don't need to use Photoshop anymore, at least not to export these dithered images.

A different story is centering and adding the appropriate padding to the image. But even so, I can play with ImageMagick and web previews to adjust those parameters.

I'm thinking of making either a web script or a web app with an endpoint that uses ImageMagick in DigitalOcean to generate these illustrations. But that may be overdoing it.

Here's a full-resolution sample of the cover image as it exports. You may need to download the image to see its pixel-perfect resolution, as Chrome, for instance, rasterizes the image and you can't appreciate the individual black and white pixels.

What do you think?