A simple, beginner-friendly guide to the Floyd–Steinberg dithering algorithm. Learn how it works, why it creates that popular grainy effect, and how to use it in Python, Photoshop, and online tools to create textured, retro-style images.
If you’ve been searching things like “floyd steinberg dithering python”, “floyd steinberg dithering photoshop”, or “floyd steinberg dithering online”, you’re probably trying to get that gritty, textured, almost analog image look.
This guide keeps things simple. What it is, how it works, and how people are actually using it today.
The Floyd–Steinberg dithering algorithm is a way to reduce colors in an image without making it look flat or broken.
Normally, when you limit colors, you lose detail. You get banding. Big patches of color. It feels cheap
This algorithm fixes that by spreading the error across nearby pixels.
Simple idea:
Instead of forcing a pixel into a color and stopping there, it passes the mistake forward so the overall image still feels detailed.
This is not just a technical trick anymore. It has become a design style.
You’ll see it in:
Why people keep coming back to it:
Here’s the logic in plain terms:
The distribution pattern looks like this:
X 7/16
3/16 5/16 1/16That small detail is everything.
Instead of harsh edges, you get a soft noise that tricks your eyes into seeing more depth.
Mathematical formulation (error diffusion)
At each pixel $(x,y)$, we replace the original value with its quantized value:
where:
The local error introduced by quantization is:
Interpretation: e(x,y) is the “missing detail” removed when you force the pixel to the nearest allowed value.
Instead of discarding $e(x,y)$, Floyd–Steinberg diffuses it forward into neighboring pixels:
for neighbors (i,j) of $(x,y)$, where the weights w_{i,j} satisfy:
Key idea: the error is conserved (weights sum to 1), but it is redistributed spatially.
For left-to-right scanning, the classical stencil is:
(x,y) 7/16 → (x+1, y)
3/16 → (x-1,y+1) 5/16 → (x, y+1) 1/16 → (x+1,y+1)Equivalently, the neighbor updates are:
For a simple black/white quantizer with threshold T (often T=128 for 8-bit grayscale):
Mathematically, you are conserving the total intensity by redistributing error locally.
Instead of losing information, you are shifting it spatially.
That is why your eyes still perceive gradients and detail, even though each pixel is heavily simplified.
If you searched “floyd steinberg dithering python”, this is the core idea behind most implementations:
import numpy as np
from PIL import Image
img = Image.open("input.jpg").convert("L")
pixels = np.array(img, dtype=float)
for y in range(pixels.shape[0] - 1):
for x in range(1, pixels.shape[1] - 1):
old = pixels[y, x]
new = 255 if old > 128 else 0
pixels[y, x] = new
error = old - new
pixels[y, x+1] += error * 7/16
pixels[y+1, x-1] += error * 3/16
pixels[y+1, x] += error * 5/16
pixels[y+1, x+1] += error * 1/16
Image.fromarray(pixels.astype(np.uint8)).save("output.png")You can change thresholds, palettes, or even apply this to RGB for different styles.
If you searched “floyd steinberg dithering photoshop”, here’s the shortcut.
Photoshop does not name it directly, but it is there.
Steps:
That diffusion option is essentially this algorithm under the hood.
A lot of people search “floyd steinberg dithering online free” because they just want quick results.
Online tools usually let you:
These tools are especially useful if you are experimenting with visuals or building a certain design language without opening heavy software.
Searches like “floyd steinberg dithering shader” come from people working with real time visuals.
In shaders:
Same idea, just optimized for speed.
If you searched “floyd steinberg dithering c++”, you are probably dealing with performance or rendering systems.
C++ is used because:
Use it when you want:
Avoid it when:
Floyd Steinberg dithering sits in a weird but interesting space.
It is simple, but still powerful. Old, but still trending.
That is why people keep searching:
Once you start using it, you realize it is not just about reducing colors.
It is about adding character.
Most people come into dithering for the effect, but stay for the control.
When you can tweak:
you stop just applying a filter and start shaping a visual style.
That is where things get interesting.