ArticleslgStudy

science

Ordered dithering

Ordered dithering is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Ordered dithering rather than just read about it. In short: Ordered dithering is any image dithering algorithm which uses a pre-set threshold map tiled across an image. It is commonly used to display a continuous image on a display of smaller color depth.

Ordered dithering — main illustration
Ordered dithering — illustration

Key takeaways

  • Ordered dithering belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Ordered dithering to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Ordered dithering from memory before moving on to harder problems.

Reference excerpt

Ordered dithering is any image dithering algorithm which uses a pre-set threshold map tiled across an image. It is commonly used to display a continuous image on a display of smaller color depth. For example, Microsoft Windows uses it in 16-color graphics modes. With the most common "Bayer" threshold map, the algorithm is characterized by noticeable crosshatch patterns in the result.

Threshold map The algorithm reduces the number of colors by applying a threshold map M to the pixels displayed, causing some pixels to change color, depending on the distance of the original color from the available color entries in the reduced palette. The first threshold maps were designed by hand to minimise the perceptual difference between a grayscale image and its two-bit quantisation for up to a 4x4 matrix.

An optimal threshold matrix is one that for any possible quantisation of color has the minimum possible texture so that the greatest impression of the underlying feature comes from the image being quantised. It can be proven that for matrices whose side length is a power of two there is an optimal threshold matrix. The map may be rotated or mirrored without affecting the effectiveness of the algorithm.

This threshold map (for sides with length as power of two) is also known as a Bayer matrix or, when unscaled, an index matrix. For threshold maps whose dimensions are a power of two, the map can be generated recursively via:

𝐌2n=1(2n)2[4𝐌n4𝐌n+2𝐉n4𝐌n+3𝐉n4𝐌n+𝐉n]=𝐉2⊗𝐌n+1n2𝐌2⊗𝐉n, where 𝐉n are n×n matrices of ones and ⊗ is the Kronecker product. While the metric for texture that Bayer proposed could be used to find optimal matrices for sizes that are not a power of two, such matrices are uncommon as no simple formula for finding them exists, and relatively small matrix sizes frequently give excellent practical results (especially when combined with other modifications to the dithering algorithm). This function can also be expressed using only bit arithmetic:

M(i, j) = bit_reverse(bit_interleave(bitwise_xor(i, j), i)) / n ^ 2

Pre-calculated threshold maps Rather than storing the threshold map as a matrix of n×n integers from 0 to n2, depending on the exact hardware used to perform the dithering, it may be beneficial to pre-calculate the thresholds of the map into a floating point format, rather than the traditional integer matrix format shown above. For this, the following formula can be used:

Mpre(i,j) = Mint(i,j) / n^2

This generates a standard threshold matrix. for the 2×2 map:

this creates the pre-calculated map:

Additionally, normalizing the values to average out their sum to 0 (as done in the dithering algorithm shown below) can be done during pre-processing as well by subtracting 1⁄2 of the largest value from every value:

Mpre(i,j) = Mint(i,j) / n^2 – 0.5 * maxValue

creating the pre-calculated map:

Algorithm The ordered dithering algorithm renders the image normally, but for each pixel, it offsets its color value with a corresponding value from the threshold map according to its location, causing the pixel's value to be quantized to a different color if it exceeds the threshold. For most dithering purposes, it is sufficient to simply add the threshold value to every pixel (without performing normalization by subtracting 1⁄2), or equivalently, to compare the pixel's value to the threshold: if the brightness value of a pixel is less than the number in the corresponding cell of the matrix, plot that pixel black, otherwise, plot it white. This lack of normalization slightly increases the average brightness of the image, and causes almost-white pixels to not be dithered. This is not a problem when using a gray scale palette (or any palette where the relative color distances are (nearly) constant), and it is often even desired, since the human eye perceives differences in darker colors more accurately than lighter ones, however, it produces incorrect results especially when using a small or arbitrary palette, so proper normalization should be preferred.

In other words, the algorithm performs the following transformation on each color c of every pixel: c′=nearest_palette_color(c+r×(M(xmodn,ymodn)−1/2)) where M(i, j) is the threshold map on the i-th row and j-th column, c′ is the transformed color, and r is the amount of spread in color space. Assuming an RGB palette with 23N evenly distanced colors where each color (a triple of red, green and blue values) is represented by an octet from 0 to 255, one would typically choose r≈255N. (1⁄2 is again the normalizing term.) Because the algorithm operates on single pixels and has no conditional statements, it is very fast and suitable for real-time transformations. Additionally, because the location of the dithering patterns always stays the same relative to the display frame, it is less prone to jitter than error-diffusion methods, making it suitable for animations. Because the patterns are more repetitive than error-diffusion method, an image with ordered dithering compresses better. Ordered dithering is more suitable for line-art graphics as it will result in straighter lines and fewer anomalies. The values read from the threshold map should preferably scale into the same range as the minimal difference between distinct colors in the target palette. Equivalently, the size of the map selected should be equal to or larger than the ratio of source colors to target colors. For example, when quantizing a 24 bpp image to 15 bpp (256 colors per channel to 32 colors per channel), the smallest map one would choose would be 4×2, for the ratio of 8 (256:32). This allows expressing each distinct tone of the input with different dithering patterns.

A variable palette: pattern dithering

Non-Bayer approaches The above thresholding matrix approach describes the Bayer family of ordered dithering algorithms. A number of other algorithms are also known; they generally involve changes in the threshold matrix, which changes the distribution of the "noise" introduced by all kinds of dithering (the difference between the original image and the dithered image).

Halftone Halftone dithering performs a form of clustered dithering, creating a look similar to halftone patterns, using a specially crafted matrix.

… excerpt ends here. Continue reading the full article.

Illustrations

Ordered dithering: In this example, the original photograph is shown on left.  The version on the right shows the effect of quantizing it to 16 colors and dithering using the 8×8 ordered dithering pattern.
In this example, the original photograph is shown on left. The version on the right shows the effect of quantizing it to 16 colors and dithering using the 8×8 ordered dithering pattern.
Ordered dithering: The characteristic 17 patterns of the 4×4 ordered dithering matrix can be seen clearly when used with only two colors, black and white.  Each pattern is shown above the corresponding undithered shade.
The characteristic 17 patterns of the 4×4 ordered dithering matrix can be seen clearly when used with only two colors, black and white. Each pattern is shown above the corresponding undithered shade.
Ordered dithering: Two images mimicking a gradient of 140 × 140 = 19600 different colors. Both images use the same 64 colors. The image on the right has been dithered. The dithering was done using a non-normalizing dithering algorithm, causing the image to have a slight over-representation of bright pixels.
Two images mimicking a gradient of 140 × 140 = 19600 different colors. Both images use the same 64 colors. The image on the right has been dithered. The dithering was done using a non-normalizing dithering algorithm, causing the image to have a slight over-representation of bright pixels.

Worked examples

Example 1 — a first encounter with Ordered dithering

Start with the simplest possible case. Write down what Ordered dithering claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Ordered dithering before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Ordered dithering ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Ordered dithering

In research
Ordered dithering appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Ordered dithering in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Ordered dithering is common in secondary-school and first-year university syllabi. It links to neighbouring topics Image processing, so understanding it makes those chapters shorter.
In everyday life
Look for Ordered dithering outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Ordered dithering” →

How to study Ordered dithering in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Ordered dithering means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Ordered dithering out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Ordered dithering in simple terms?

Ordered dithering is any image dithering algorithm which uses a pre-set threshold map tiled across an image. It is commonly used to display a continuous image on a display of smaller color depth.

Why does Ordered dithering matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Ordered dithering?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Ordered dithering.

Tags

  • Image processing

Keep exploring