Dither Pattern Generator
Generate dither patterns from images using Floyd-Steinberg, Bayer, Atkinson, and halftone algorithms. Export pixel-perfect PNG results.
About
Dithering is a controlled injection of quantization noise that tricks the human visual system into perceiving more tonal gradations than the output palette actually contains. The technique dates to newspaper halftone printing and became critical in early computer graphics where displays were limited to 2 - 16 colors. Getting it wrong produces banding artifacts, moiré interference, or muddy detail loss - problems that no amount of post-processing can fix. This tool implements seven production algorithms: threshold, ordered (Bayer matrices up to 16×16), Floyd-Steinberg, Atkinson, Stucki, random noise, and radial halftone. Each operates on actual pixel data via the Canvas API; no server round-trip, no simulation.
Palette quantization uses a median-cut partitioning of the RGB cube, or you can select historically accurate palettes (Game Boy 4-color, CGA 4-color, Commodore 64 16-color). Note: error-diffusion algorithms assume a left-to-right, top-to-bottom scanline order. Serpentine scanning is not implemented, which may produce slight directional bias on high-frequency textures. All processing runs in a Web Worker; images up to roughly 4000×4000 pixels are practical before memory pressure becomes a factor.
Formulas
Ordered dithering constructs a Bayer threshold matrix recursively. For a matrix of size 2n:
where M1 = 0231. A pixel at position (x, y) is set to the nearest palette color if its luminance exceeds the normalized threshold M[x mod n][y mod n].
Floyd-Steinberg error diffusion distributes quantization error e = old − new to four neighbors:
pixel(x−1, y+1) += e × 316
pixel(x, y+1) += e × 516
pixel(x+1, y+1) += e × 116
Atkinson uses the same principle but spreads only 68 of the error (18 to each of 6 neighbors), deliberately discarding 25% of error. This produces the characteristically sharp, high-contrast look seen in original Macintosh screenshots.
Luminance for grayscale conversion uses ITU-R BT.601 coefficients:
where R, G, B are channel values in the range [0, 255]. Palette matching uses Euclidean distance in RGB space: d = √(r1 − r2)2 + (g1 − g2)2 + (b1 − b2)2.
Reference Data
| Algorithm | Type | Error Spread | Neighbors | Character | Best For |
|---|---|---|---|---|---|
| Threshold | Point | None | 0 | Hard, high contrast | Logos, line art |
| Random Noise | Point | None | 0 | Film grain texture | Photographic feel |
| Bayer 2×2 | Ordered | None (threshold map) | 0 | Coarse cross-hatch | Retro pixel art |
| Bayer 4×4 | Ordered | None (threshold map) | 0 | Classic dither grid | Game Boy style |
| Bayer 8×8 | Ordered | None (threshold map) | 0 | Fine ordered pattern | General purpose |
| Bayer 16×16 | Ordered | None (threshold map) | 0 | Smooth gradient ramps | Large tonal range |
| Floyd-Steinberg | Error Diffusion | 100% | 4 | Natural, organic noise | Photographs |
| Atkinson | Error Diffusion | 75% | 6 | Sharp, high contrast | Mac Classic style |
| Stucki | Error Diffusion | 100% | 12 | Smooth, wide spread | Large prints |
| Halftone | Amplitude Modulation | None (radial map) | 0 | Newspaper dot pattern | Print reproduction |
| Reference Palettes | |||||
| Monochrome | Black & White | 2 colors: #000, #FFF | |||
| Game Boy | 4-shade green | #0F380F, #306230, #8BAC0F, #9BBC0F | |||
| CGA Mode 4 Hi | 4 colors | #000, #55FFFF, #FF55FF, #FFF | |||
| Commodore 64 | 16 colors | Full C64 palette (MOS 6567/6569 VIC-II) | |||
| EGA | 16 colors | Standard IBM EGA 64-color subset (16 default) | |||
| Grayscale 4 | 4 shades | #000, #555, #AAA, #FFF | |||
| Grayscale 8 | 8 shades | Linear 0 - 255 in 8 steps | |||
| Custom N | Median-cut | User-defined 2 - 64 colors from source image | |||