4x4 vs 8x8 Bayer Matrix: Which Threshold Grid Should You Use?
A 4x4 Bayer matrix has 16 threshold levels; an 8x8 has 64. More levels smooths gradients but doubles the repeating tile. Here's which size fits your image.
01/ ARTICLE
What Is a Bayer Matrix?
A Bayer matrix is a fixed grid of threshold values, tiled across an image, that ordered dithering checks each pixel's brightness against to decide on or off. It's the deterministic counterpart to error-diffusion methods like Floyd-Steinberg. Same source, same matrix, same result every time. That's why the output reads as a crosshatch instead of noise. Still deciding between ordered and error-diffusion dithering in the first place? Ordered dithering vs Floyd-Steinberg covers that call. This piece assumes you've already picked ordered, or Bayer, and answers the next question: what size grid.
Every Bayer matrix, 2x2, 4x4, 8x8, 16x16 and up, comes from the same construction. Nobody designs a new one per size. You start with the 2x2 base and run a recursive formula one more level for each doubling. That matters because 4x4 and 8x8 aren't competing algorithms. They're two sizes of the identical thing, and the only variable you're actually choosing is threshold levels versus tile size.
The recursive construction, briefly
The formula is a Kronecker-product recurrence: each larger matrix is built from four copies of the smaller one, scaled and offset so no two adjacent cells land on close threshold values. Starting from the 2x2 base [[0,2],[3,1]], one application gets you to 4x4. Apply it again and you're at 8x8. The mechanics matter more if you're building your own matrix than if you're just picking between the two sizes below, so the full worked version comes later.
What Do the 4x4 and 8x8 Bayer Matrices Look Like?
Here's the 4x4 matrix in full, values 0 to 15, each divided by 16:
0 8 2 10
12 4 14 6
3 11 1 9
15 7 13 5
And the 8x8 matrix, values 0 to 63, each divided by 64:
0 32 8 40 2 34 10 42
48 16 56 24 50 18 58 26
12 44 4 36 14 46 6 38
60 28 52 20 62 30 54 22
3 35 11 43 1 33 9 41
51 19 59 27 49 17 57 25
15 47 7 39 13 45 5 37
63 31 55 23 61 29 53 21
Both are documented reference values, not something eyeballed off a screenshot (source). 16 distinct threshold steps at 4x4 versus 64 at 8x8: that's the entire practical difference between them. More steps means finer control over which pixels flip at a given brightness. That's what "smoother gradient" actually means here.
Reading the grid
To use either matrix, take a pixel's position, reduce it modulo the matrix size (x mod 4, y mod 4 for the small one), look up the threshold at that cell, and compare it against the pixel's brightness. Do that for every pixel and the matrix tiles itself across the whole image automatically. No extra code needed for the repeat.
4x4 vs 8x8: Which Threshold Grid Should You Use?
| Matrix size | Threshold levels | Tile size | Best for | Watch out for |
|---|---|---|---|---|
| 2x2 | 4 | 2x2 px | extreme low-fi, deliberate blockiness | almost always too coarse for photos |
| 4x4 | 16 | 4x4 px | small prints, retro grids, tight performance budgets | visible banding on smooth gradients |
| 8x8 | 64 | 8x8 px | larger source images, photographic tone | tile becomes an obvious grid up close |
| 16x16 | 256 | 16x16 px | maximum smoothness on big images | pattern can look almost random, loses the "dithered" character |
The verdict: pick 4x4 when the crosshatch is the point. A deliberate retro look, print at small size, or real-time work where every cycle counts. Pick 8x8 when your source is large enough that an 8-pixel tile disappears into the frame and you'd rather have smoother tone than a visible pattern. Neither wins outright. They're tuned for different image sizes and different intents.
For VJs choosing matrix size under motion, tile size also shapes how the pattern reads as the source moves. A smaller matrix's tile repeats more often across the frame, which can make the crosshatch feel busier at 60fps than the same effect at 8x8 on a static image.
How Does Matrix Size Affect Banding and Tile Visibility?
Matrix size interacts with your actual color reduction, beyond banding in the abstract. Going from a wide tonal range down to two colors? The matrix needs at minimum as many levels as the ratio between source and target colors, or you get visible contouring no matter how well-built the pattern is. A 4x4 matrix undersized for a large color reduction will band regardless of how carefully you picked the threshold.
The opposite failure runs the other way. Push an 8x8 matrix onto a small or close-viewed image and the repeating tile itself becomes the dominant visual, an obvious 8-pixel grid instead of a gradient. That's the real trade-off: bigger matrix, fewer banding artifacts, bigger and more visible repeat. No size dodges both failure modes at once. You're choosing which one your image can tolerate.
If neither Bayer size looks right on a given source, switch families instead of continuing to tune matrix size. Atkinson dithering trades the fixed grid for error diffusion and handles some photographic tone better, at the cost of the deterministic tile entirely.
How Do You Generate Any Bayer Matrix Size Yourself?
The construction, worked in full: start with the 2x2 base, M2 = (1/4) x [[0,2],[3,1]]. Each doubling applies the same recurrence: four scaled-and-offset copies of the previous matrix arranged into quadrants. Run it once and you get 4x4. Run it again on the 4x4 result and you get 8x8. There's no size limit to the recursion. 16x16 and 32x32 are the same process, one or two levels further.
Building this for real-time use, 60fps on a VJ rig or in a shader? Pre-scale the whole matrix into your output's integer range up front rather than normalizing per pixel. Comparing against a 0-255 integer threshold table beats a division on every pixel, every frame, and it's the pattern shader implementations reach for by default (reference).
Frequently Asked Questions
What is a Bayer matrix?
A Bayer matrix is a fixed grid of threshold values, tiled across an image, that ordered dithering compares each pixel's brightness against to decide whether that pixel is on or off. It's deterministic, so the same source always produces the same pattern, unlike error-diffusion methods.
Is 8x8 always better than 4x4?
No. 8x8 carries 64 threshold levels against 4x4's 16, so it renders smoother gradients with less banding, but its repeating tile is twice as large in each dimension, which reads as an obvious grid sooner on small or close-viewed images. 4x4 is the better choice when the pattern itself is the point: print at small size, a deliberate retro grid, or tight performance budgets. 8x8 is better for larger source images where you want the dither to disappear into the tonal range.
Can I generate a Bayer matrix of any size?
Yes. Every power-of-two size, 2x2, 4x4, 8x8, 16x16 and beyond, comes from the same recursive construction starting at the 2x2 base. There's no separately designed matrix per size, just the same formula run one more level.
Try it
Load either matrix size against your own image in kott's dither tool. 8x8 comes preloaded. Switch to 4x4 to see the tile-size trade directly on your source instead of the test grid above.
02/ OUT
Every setting described above is a real control. Open your own image and sweep it.
All journal entries