Image Dithering
Introduction
Image and its parameters
An image is a two-dimensional representation of a rectilinear array of pixels. A pixel is sample point in the image that has coordinates location it. These samples are obtained from the continuous function CCD cells in a camera, photoreceptors in the eye and rays in a virtual camera. There are three types of image resolution. The first resolution is where each pixel has only the depth bits for color or intensities. The second type of resolution is the spatial resolution which involves the width and the heights of the image only. Lastly, another image resolution is the temporal resolution, and this kind does the monitoring of the image brightness at a particular frequency only.
Image dithering
Dithering is the approximation of color from a mixture of several colors by the computer program when the desired color is not available. An example if dithering is the when a certain color in the Web page for a particular browser is not supported by the other. In that case, the browser will attempt to replace the desired color by approximating two colors that it can generate. The same may or may not be accepted by the designer of graphics and may appear grainy because it is composed of varied pixel intensities instead of one intensity.
Dithering has applications in color image output and for artistic purposes as well. Secondly, dithering is used in web design for reducing images from high color counts to low color counts. It is also used in reducing file size and bandwidth without harming the quality of the image file. Moreover, the technique is used in reducing the 48 or 64bpp RAW-format digital photos for editing ("Image Dithering: Eleven Algorithms and Source Code", 2012)
The main activity in dithering is error diffusion. For example, in reducing a gray scale photograph to black and white to enable printing on a printer that can support black and white pure inks only. The first pixel of the image has a value of 96 on a scale of 0-255 and is dark gray in color. The zero is pure black, and 255 is pure white. Consider figure 1 below
Figure 1: RGB visualization ("Image Dithering: Eleven Algorithms and Source Code", 2012)
The conversion of this pixel to a black and white scenario, a simple formula is used. The question is whether the color is closer to black or white. In this case, the value of 96 is closer to zero hence it is closer to black and the pixel is made black. The standard concept will involve the movement to the next pixel and perform a similar comparison. In error diffusion, the error in each calculation is spread to the neighboring pixels. If a 96 gray pixel is found, the value is determined to be closer to 0 than to 255 and the pixel is made black. The algorithm takes the note of the error in the conversion ("Image Dithering: Eleven Algorithms and Source Code", 2012)
The process involves the addition of the error of the previous pixel to the current pixel as it moves to the next level. If it finds that the next pixel is also gray, the algorithm will add the error of 96 to the previous pixel instead of just forcing to black as in the first case. The resulting value is 192 which makes it closer to 255 and closer to white and this pixel is made white and the error is noted. The error becomes -63 since 192 is 63 less than 255. This process of algorithm continues making an alternate of black and white pixels. However, this form of error is one dimension and involves the error diffusion is one direction only. In two dimension dithering, the error diffusion is done forwards and backward to produce a quality image.
Forms of Dithering and their appropriate algorithms.
Floyd-Steinberg Dithering
This is the famous type of dithering that uses the following pattern in dithering images:
X 7
3 5 1
(1/16)
The notation ‘X’ means the present pixel and the fraction show the error divisor. In another version, the same formula can be rewritten as:
X 7/16
3/16 5/16 1/16
In the previous example, if the pixel is forced to black, an error of 96 is generated. If the same error is propagated to the neighboring pixels to by diving by 16 and multiplying by some values as shown;
X +42
+18 +30 + 6
When the error is spread to multiple pixels each having a different value, any distraction bands are minimized ("Image Dithering: Eleven Algorithms and Source Code", 2012)
Jarvis, Judics, and Ninke Dithering
This is a more powerful dithering algorithm than Floyd and Steinberg dithering technique. The method has a more complex pattern like this:
X 7 5
3 5 7 5 3
1 3 5 3 1
(1/48)
With this kind of algorithm, the errors can be distributed as many times as possible. It is three times as many pixels as in the case of Floyd and Steinberg, and this results in a much smoother and subtle output. The disadvantage of this approach is that a small speed gain is propagated by multiple times.
Stucki Dithering
This type of dithering has improved processing time than the JJNs dithering. The algorithm of error processing is seen to has an improve complexity. This is shown below
X 8 4
2 4 8 4 2
1 2 4 2 1
(1/42)
The bit-shifting can be used to derive the exact values for propagation when the divisor divides the error. The method has a slightly higher speed than the previous approach, and this is why it is preferred ("Image Dithering: Eleven Algorithms and Source Code", 2012)
References
Image Dithering: Eleven Algorithms and Source Code. (2012). Tanner Helland (dot) com. Retrieved 18 March 2016, from http://www.tannerhelland.com/4660/dithering-eleven-algorithms-source-code/