Everything2
Near Matches
Ignore Exact
Full Text
Everything2

Floyd-Steinberg Dithering Algorithm

created by ariels

(idea) by ariels (3.8 d) (print)   ?   (I like it!) 1 C! Fri Mar 24 2000 at 17:37:42

A 1 pass error diffusion dithering algorithm.

The presentation assumes pixel values are real numbers in the range [0,1]; implementations of course use integer (or byte) arithmetic. Generalising to color images is easy, and works very well in practice; the key is to use vector valued pixels, and compute and distribute an appropriate vector error. It is also possible to use several grayscale values, rather than just black and white.

To dither the input image, traverse it in raster order. For each pixel, output a black pixel if the corresponding pixel value is <0.5, else output a white pixel. An error term for the pixel can now be computed: this is simply the difference between the pixel value and 0.0 (if a black pixel was output) or the difference between the pixel value and 1.0 (if a white pixel was output; this term is negative). This term is a measure of the excess blackness or whiteness of the output pixel compared to the input pixel; we'd like the average error on areas of the picture to be small (e.g. if a region is dark, with average value 0.2, we'd like 80% of the pixels in the corresponding output region to be black).

Now distribute the error to the 4 neighboring pixels which have not yet been processed, in the following proportions:

prev   cur    7/16
3/16   5/16   1/16

Here cur is the current pixel; prev (and the pixels on the previous row) has already been processed, so cannot receive any error term. Note that the sum of the distributed errors is exactly the error term, but that the pixel to the right (which won't receive any additional error) receives a much larger proportion of the error than the other pixels. It is important to clamp pixel values to the range [0,1] - negative values should be transformed silently to 0 and positive values to 1. (When using e.g. byte arithmetic this is even more important, to prevent overflow).

Clearly, the algorithm can be performed in a single pass over the image, keeping only two rows of pixels (the current and next rows). It is even possible to scale the image and dither it in the same pass, add some gamma correction, or correct for the fact that printed black dots are larger than white ones.

Disadvantages

The Floyd-Steinberg algorithm has two main problems:
  • No clear pattern of dots is formed in places of uniform greyness. Unlike an ordered dithering algorithm, this gives images an uneven feel. Of course, the problem is worse when the dots are large.
  • "Ghosting" is often observed: a sharp line dividing two even regions of very different greyness might re-appear faintly several rows below, due to weird destructive interference of the error terms.

printable version
chaos

ordered dithering Destructive interference dithering Low-pass filter
Mach banding effect algorithm Bresenham's Algorithm isophote
The Brain Floyd's Algorithm negative A4
Permeability Acorn Archimedes neighbor grayscale
Sophie Wilson zip
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
Nodes your sibling would have liked:
London's calling, and it's calling you gay
'Ayin
B movie
Three McDonald's: The Myth of Regeneration Through Violence
Finger picking
An eyewitness account of the Nagasaki bombing
The Great Prajna Paramita Heart Sutra
Crinoline
Ronald Reagan
HOT DAMN!: Drinking, Debauchery, and Dastardly Deeds
Butter
Don't tell her she's beautiful
New York subway
New Writeups
doctor wilson
Soup, of the green variety(recipe)
Ctrl Y
cognitive dissonance(fiction)
SharQ
Gone Baby Gone(review)
halfWit
If I could, I'd title this "Freedom"(thing)
Roninspoon
Airline Hero(thing)
Ktistec
Why Women Are Always Cold(person)
doctor wilson
Drug policy reform(thing)
tejasa
Easy Raspberry Cheesecake(recipe)
Joysim
Drug policy reform(idea)
aneurin
Tyburn(place)
niruena
Boiling to death(idea)
artman2003
summer(thing)
doctor wilson
The Silver City and the Silent Sea(log)
Dreamvirus
The Silver City and the Silent Sea(poetry)
Aerobe
A nihilist's soulmate(poetry)
This affordable entertainment brought to you by The Everything Development Company