← Back to blog

Bayer Dithering: Ordered Patterns Explained

Learn how Bayer dithering uses ordered threshold matrices to simulate colors. Compare 2x2, 4x4, and 8x8 Bayer patterns and see how they differ from error diffusion.

Bayer ordered dithering pattern applied to a gradient showing the threshold matrix effect

Long before computers existed, the printing industry faced a color problem: how to print photorealistic images using only four inks (cyan, magenta, yellow, black). The solution was halftone screening, which used dot patterns to simulate color. When Bryce Bayer invented his dithering matrix in the 1970s, he was adapting that century-old idea for the digital age.

Who Was Bryce Bayer?

Bryce Bayer worked at Kodak in the 1970s. Yes, the same company that invented color photography and, yes, also the same Bayer from the Bayer filter - a color mosaic pattern used in nearly every digital camera sensor today. Bayer was interested in color reduction for early digital imaging, and he developed a specific matrix pattern that became remarkably effective.

How Bayer Dithering Works

Unlike Floyd-Steinberg's error diffusion (which spreads error across the image), Bayer dithering uses a predefined threshold matrix to decide, for each pixel, whether to round up or down in color. The decision is based entirely on the pixel's position in a grid.

The smallest version is the 2x2 Bayer matrix, with values 0, 2, 3, 1 arranged in a grid. These threshold values are used repeatedly across the entire image. A larger pattern (4x4 or 8x8) provides more gradation levels, allowing smoother tonal transitions.

The Algorithm

For each pixel at position (x, y):

  1. Get the pixel's true color value (0-255 for grayscale)
  2. Look up the threshold in the Bayer matrix at position (x mod matrix_width, y mod matrix_height)
  3. If pixel_value > threshold, use the lighter color; otherwise, use the darker color
  4. Move to the next pixel

Why These Numbers?

The Bayer matrix is constructed to minimize visual artifacts. The pattern repeats at regular intervals, which is why Bayer dithering creates those characteristic diagonal lines and checkerboard patterns. This is intentional - the pattern is less visually jarring than random noise.

Bayer vs Floyd-Steinberg

Bayer dithering: Fast (no error accumulation needed), produces visible patterns, good for halftone-style effects, works great for print.

Floyd-Steinberg: Slower, more natural-looking (errors diffuse more randomly), better for photorealistic results on screens.

Bayer's structured pattern makes it instantly recognizable, which is why it's beloved by artists seeking a retro or mechanical aesthetic.

Ready to try it? Open GlitchArt Studio and experiment with this effect.

Try this effect in GlitchArt Studio 85+ effects, real-time preview, free to use
Open Editor