Dither
Dither or dithering is an intentionally applied form of noise used to randomize quantization error, preventing large-scale patterns such as color banding in images. Dither is routinely used in processing of both digital audio and video data, and is often one of the last stages of mastering audio to a CD.
A common use of dither is converting a grayscale image to black and white, so that the density of black dots in the new image approximates the average gray level in the original.
Etymology
The term dither was published in books on analog computation and hydraulically controlled guns shortly after World War II. Though he did not use the term dither, the concept of dithering to reduce quantization patterns was first applied by Lawrence G. Roberts in his 1961 MIT master's thesis and 1962 article. By 1964 dither was being used in the modern sense described in this article. The technique was in use at least as early as 1915, though not under the name dither.In digital processing and waveform analysis
Dither is utilized in many different fields where digital processing and analysis are used. These uses include systems using digital signal processing, such as digital audio, digital video, digital photography, seismology, radar and weather forecasting systems.Quantization yields error. If that error is correlated to the signal, the result is potentially cyclical or predictable. In some fields, especially where the receptor is sensitive to such artifacts, cyclical errors yield undesirable artifacts. In these fields, introducing dither converts the error to random noise. The field of audio is a primary example of this. The human ear functions much like a Fourier transform, wherein it hears individual frequencies. The ear is therefore very sensitive to distortion, or additional frequency content, but far less sensitive to additional random noise at all frequencies such as found in a dithered signal.
Digital audio
In an analog system, the signal is continuous, but in a PCM digital system, the amplitude of the signal out of the digital system is limited to one of a set of fixed values or numbers. This process is called quantization. Each coded value is a discrete step... if a signal is quantized without using dither, there will be quantization distortion related to the original input signal... In order to prevent this, the signal is "dithered", a process that mathematically removes the harmonics or other highly undesirable distortions entirely, and that replaces it with a constant, fixed noise level.
The final version of audio that goes onto a compact disc contains only 16 bits per sample, but throughout the production process, a greater number of bits are typically used to represent the sample. This must be reduced to 16 bits to make the CD. There are multiple ways to do this. One can, for example, simply discard the excess bits – called truncation. One can also round the excess bits to the nearest value. Each of these methods, however, results in determinable errors. Using dither replaces these errors with a constant noise level.
Examples
Take, for example, a waveform that consists of the following values:1 2 3 4 5 6 7 8
If the waveform is reduced by 20%, then the following are the new values:
0.8 1.6 2.4 3.2 4.0 4.8 5.6 6.4
If these values are truncated, it results in the following data:
0 1 2 3 4 4 5 6
If these values are rounded instead, it results in the following data:
1 2 2 3 4 5 6 6
For any original waveform, the process of reducing the waveform amplitude by 20% results in regular errors. Take, for example, a sine wave that, for some portion, matches the values above. Every time the sine wave's value hit 3.2, the truncated result would be off by 0.2, as in the sample data above. Every time the sine wave's value hit 4.0, there would be no error since the truncated result would be off by 0.0, also shown above. The magnitude of this error changes regularly and repeatedly throughout the sine wave's cycle. It is precisely this error that manifests itself as distortion. What the ear hears as distortion is the additional content at discrete frequencies created by the regular and repeated quantization error.
A plausible solution would be to take the 2-digit number and round it one direction or the other. For example, it could be rounded to 5 one time and then 4 the next time. This would make the long-term average 4.5 instead of 4, so that over the long term, the value is closer to its actual value. However, this still results in determinable error. Every other time the value 4.8 comes up, the result is an error of 0.2, and the other times it is −0.8. This still results in a repeating, quantifiable error.
Another plausible solution would be to take 4.8 and round it so that the first four times out of five it is rounded up to 5, and the fifth time it is rounded to 4. This would average out to exactly 4.8 over the long term. Unfortunately, however, it still results in repeatable and determinable errors, and those errors still manifest themselves as distortion to the ear.
This leads to the dither solution. Rather than predictably rounding up or down in a repeating pattern, it is possible to round up or down in a random pattern. If a series of random numbers between 0.0 and 0.9 is generated and added to the 4.8, two times out of ten the result will truncate back to 4 and eight times out of ten it will truncate to 5. Each given situation has a random 20% chance of rounding to 4 or 80% chance of rounding to 5. Over the long haul, these results will average to 4.8 and their quantization error will be random noise. This noise is less offensive to the ear than the determinable distortion that other solutions would produce.
Usage
Dither is added before any quantization or re-quantization process, in order to decorrelate the quantization noise from the input signal and to prevent non-linear behavior. Quantization with lesser bit depth requires higher amounts of dither. The result of the process still yields distortion, but the distortion is of a random nature so the resulting noise is, effectively, decorrelated from the intended signal.In a seminal paper published in the AES Journal, Lipshitz and Vanderkooy pointed out that different noise types, with different probability density functions behave differently when used as dither signals, and suggested optimal levels of dither signal for audio. Gaussian noise requires a higher level of added noise for full elimination of audible distortion than noise with rectangular or triangular distribution. Triangular distributed noise also minimizes noise modulationaudible changes in the volume level of residual noise behind quiet music that draw attention to the noise.
Dither can be useful to break up periodic limit cycles, which are a common problem in digital filters. Random noise is typically less objectionable than the harmonic tones produced by limit cycles.
Noise distributions
Rectangular probability density function dither noise has a uniform distribution; any value in the specified range has the same probability of occurring.Triangular probability density function dither noise has a triangular distribution; values in the center of the range have a higher probability of occurring. Triangular distribution can be achieved by adding two independent RPDF sources.
Gaussian PDF has a normal distribution. The relationship of probabilities of results follows a bell-shaped, or Gaussian curve, typical of dither generated by analog sources such as microphone preamplifiers. If the bit depth of a recording is sufficiently great, that preamplifier noise will be sufficient to dither the recording.
Noise shaping is a filtering process that shapes the spectral energy of quantization error, typically to either de-emphasize frequencies to which the ear is most sensitive or separate the signal and noise bands completely. If dither is used, its final spectrum depends on whether it is added inside or outside the feedback loop of the noise shaper. If inside, the dither is treated as part of the error signal and shaped along with actual quantization error. If outside, the dither is treated as part of the original signal and linearizes quantization without being shaped itself. In this case, the final noise floor is the sum of the flat dither spectrum and the shaped quantization noise. While real-world noise shaping usually includes in-loop dithering, it is also possible to use it without adding dither at all, in which case quantization error is evident at low signal levels.
Colored dither is sometimes mentioned as dither that has been filtered to be different from white noise. Noise shaping is one such application.
Which noise distribution to use
If the signal being dithered is to undergo further processing, then it should be processed with a triangular-type dither that has an amplitude of two quantization steps so that the dither values computed range from, for example, −1 to +1, or 0 to 2. This is the lowest power ideal dither, in that it does not introduce noise modulation, and eliminates the harmonic distortion from quantization. If a colored dither is used instead at these intermediate processing stages, then frequency content may bleed into other frequency ranges that are more noticeable and become distractingly audible.If the signal being dithered is to undergo no further processing – if it is being dithered to its final result for distribution – then a colored dither or noise shaping is appropriate. This can effectively lower the audible noise level by putting most of that noise in a frequency range where it is less critical.
Digital photography and image processing
Dithering is used in computer graphics to create the illusion of color depth in images on systems with a limited color palette. In a dithered image, colors that are not available in the palette are approximated by a diffusion of colored pixels from within the available palette. The human eye perceives the diffusion as a mixture of the colors within it. Dithered images, particularly those using palettes with relatively few colors, can often be distinguished by a characteristic graininess or speckled appearance.Dithering introduces noise or a pattern into an image, and often the patterning is visible. In these circumstances, it has been shown that dither generated from blue noise is the least unsightly and distracting. The error diffusion techniques were some of the first methods to generate blue-noise dithering patterns. However, other techniques such as ordered dithering can also generate blue-noise dithering without the tendency to degenerate into areas with artifacts.