Ordered dithering
≈ 4 min read
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
it to 16 colors and dithering using the 8×8 ordered dithering pattern. 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.
it to 16 colors and dithering using the 8×8 ordered dithering pattern.]] 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. \mathbf M_{2 n} = \frac{1}{(2n)^2} \begin{bmatrix} 4 \mathbf M_n & 4 \mathbf M_n + 2 \mathbf J_n \\ 4 \mathbf M_n + 3 \mathbf J_n & 4 \mathbf M_n + \mathbf J_n \end{bmatrix} = \mathbf J_2 \otimes \mathbf M_n + \frac{1}{n^2} \mathbf M_2 \otimes \mathbf J_n, where \mathbf J_n are n \times n matrices of ones and \otimes 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 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 of the largest value from every value: Mpre(i,j) = Mint(i,j) / n^2 – 0.5 * maxValue creating the pre-calculated map: c' = \mathrm{nearest\_palette\_color}\mathopen{}\left(c + r \times \left(M(x \bmod n, y \bmod n) - 1/2\right)\mathclose{}\right) where is the threshold map on the -th row and -th column, is the transformed color, and is the amount of spread in color space. Assuming an RGB palette with 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 \approx \frac{255}{N} . ( 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.
Text derived from https://en.wikipedia.org/w/index.php?oldid=1378655371 under CC BY-SA 4.0; modifications have been made.