Ordered dithering

Ordered dithering

From Wikipedia, the free encyclopedia
In this example image ( Lenna), the photograph shown on left has been  quantizedto 16 colors and dithered using the 8x8 ordered dithering pattern.
The characteristic 15 patterns of the 4x4 ordered dithering matrix - seen clearly when used with only two colors, black and white, on top of its undithered original

Ordered dithering is an image dithering algorithm. It is commonly used by programs that need to provide continuous image of higher colors on a display of less color depth. For example, Microsoft Windows uses it in 16-color graphics modes. It is easily distinguished by its noticeable crosshatch patterns.

The algorithm achieves dithering by applying a threshold map on the pixels displayed, causing some of the pixels to be rendered at a different color, depending on how far in between the color is of available color entries.

Different sizes of threshold maps exist:

{\displaystyle {\frac {\displaystyle 1}{\displaystyle 5}}{\begin{bmatrix}1&3\\4&2\\\end{bmatrix}}} {\frac  {\displaystyle 1}{\displaystyle 5}}{\begin{bmatrix}1&3\\4&2\\\end{bmatrix}}
{\displaystyle {\frac {\displaystyle 1}{\displaystyle 10}}{\begin{bmatrix}1&8&4\\7&6&3\\5&2&9\\\end{bmatrix}}} \frac{\displaystyle 1}{\displaystyle 10}\begin{bmatrix}1 & 8 & 4 \\7 & 6 & 3 \\5 & 2 & 9 \\\end{bmatrix}
{\displaystyle {\frac {\displaystyle 1}{\displaystyle 17}}{\begin{bmatrix}1&9&3&11\\13&5&15&7\\4&12&2&10\\16&8&14&6\\\end{bmatrix}}} {\frac  {\displaystyle 1}{\displaystyle 17}}{\begin{bmatrix}1&9&3&11\\13&5&15&7\\4&12&2&10\\16&8&14&6\\\end{bmatrix}}
{\displaystyle {\frac {\displaystyle 1}{\displaystyle 65}}{\begin{bmatrix}1&49&13&61&4&52&16&64\\33&17&45&29&36&20&48&32\\9&57&5&53&12&60&8&56\\41&25&37&21&44&28&40&24\\3&51&15&63&2&50&14&62\\35&19&47&31&34&18&46&30\\11&59&7&55&10&58&6&54\\43&27&39&23&42&26&38&22\\\end{bmatrix}}} {\frac  {\displaystyle 1}{\displaystyle 65}}{\begin{bmatrix}1&49&13&61&4&52&16&64\\33&17&45&29&36&20&48&32\\9&57&5&53&12&60&8&56\\41&25&37&21&44&28&40&24\\3&51&15&63&2&50&14&62\\35&19&47&31&34&18&46&30\\11&59&7&55&10&58&6&54\\43&27&39&23&42&26&38&22\\\end{bmatrix}}

The map may be rotated or mirrored without affecting the power of the algorithm. This threshold map (for sides with length as power of two) is also known as anindex matrix or Bayer matrix.[1]

Arbitrary size threshold maps can be devised with a simple rule: First fill each slot with a successive integer starting from 1. Then reorder them such that the average distance between two successive numbers in the map is as large as possible, ensuring that the table "wraps" around at edges.[citation needed]

The algorithm renders the image normally, but for each pixel, it adds a value from the threshold map, causing the pixel's value to be quantized one step higher if it exceeds the threshold. For example, in monochrome rendering, if the value of the pixel (scaled into the 0-9 range if using a 3x3 matrix) is less than the number in the corresponding cell of the matrix, plot that pixel black, otherwise, plot it white.

A color scale shown undithered and dithered. The palette has 8 red tones, 8 green tones, and their intersections for a total of 64 colors, whereas the original image has 140 in both directions for a total of 19600 colors.

In pseudocode:

 foreach y
    foreach x
       oldpixel := pixel[x][y] + (pixel[x][y] * threshold_map_4x4[x mod 4][y mod 4])
       newpixel := find_closest_palette_color(oldpixel)
       pixel[x][y] := newpixel

The values read from the threshold map should scale into the same range as is the minimal difference between distinct colors in the target palette.

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 stays always 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 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 24bpp image to 15bpp (256 colors per channel to 32 colors per channel), the smallest map one would choose would be 4x2, for the ratio of 8 (256:32). This allows expressing each distinct tone of the input with different dithering patterns.[citation needed]

Notes[edit]

  1. Jump up^ Bayer, Bryce (June 11–13, 1973). "An optimum method for two-level rendition of continuous-tone pictures" (PDF)IEEE International Conference on Communications 1: 11–15.

References[edit]

CT image compression (a) Implement the simplified DCT compression process above for n = 2, 4, and 8 and apply it to the attached image. Show the reconstructed images for these three different cases. [3 images] Compute the PSNR values of the three reconstructed images and discuss what the PSNR value means here. (b) Use the same process in (a) with image transformed to YIQ color model and show the reconstructed image in RGB space. [3 images] Compute the PSNR values of the three reconstructed images and discuss what the PSNR value means here. Dithering 2. Dithering (30%) Convert the image cat2_gray.png to binary (black and white) image with different methods of dithering, show the results, and make some comparison with the results. (a) Apply noise (random) dithering on the provided image and show the result. [1 image] (b) Apply average dithering on the provided image and show the result. [1 image] (c) Apply error diffusion dithering (Floyd-Steinberg algorithm) on the provided image and show the result. [1 image] Image Interpolation Implement the image interpolation function to upsample an image to four times the original width and height. Implement the following two different interpolation methods and show the 4× upsampled images. (a) Apply nearest-neighbor interpolation on the low resolution image, cat3_LR.png, and compute the PSNR with the original high resolution image, cat3_HR.png. [1 image] (b) Apply bilinear interpolation on the low resolution image and compute the PSNR with the high resolution image. [1 image] (c) Apply bicubic interpolation on the low resolution image and compute the PSNR with the high resolution image. [1 image]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值