Partilhar via


Always dither before you quantize

Quantization adds noise.  Taking a nice continuous signal and expressing it as distinct integers will introduce a round-off error, which means you've added random fluctuations to the signal, which is the definiton of noise.  Remember that noise is inevitable, so we just have to manage it (such as using enough bits per sample).  The problem is that round-off errors aren't random - just ask any banker.  Whether you round up or down can be strongly correlated with the signal - down at the peak of the continuous wave and up at the trough, for example.  We have a word for signal-correlated noise, and that's distortion.  Distortion is much more difficult for the ear to separate from signal, which makes it much worse, from an audio perspective.  Fortunately, there's a solution.  Ironically, it's to add more noise.

Dithering is the technique of adding white noise to a continuous signal before quantizing it.  This noise effectively cancels the distortion introduced by rounding because the noise is no longer correlated to the signal.  The noise floor of the quantized signal is higher (reducing dynamic range), but it is white noise which is much easier on the ear than the distortion it's covering up.

One common type of dithering is Triangular Probability Dithering(TPD).  With TPD, you generate two random numbers x and y in the range [0, 1] (uniform distribution) for each sample.  Add (x-y)/2 to the sample, and then round to the nearest integer.  This is gives the quantized signal a white noise floor 3dB over the undithered sample, but clears any distortion artifacts due to rounding.

Quantization noise is usually not considered a big problem in signals, because the solution is as simple as adding more bits to your samples.  Remember that quantization noise is determined by the theoretical maximum dynamic range for your sample size.  The quantization noise floor for 16-bit samples will be 96dB below the full-scale level.  If you use TPD, your noise floor goes to 93dB below full scale.  This is only a problem, though, if your input continuous signal has more than 93dB of dynamic range, and if it does, you just add enough bits to push the quantization noise below the noise of your original samples. 

The add-more-bits approach does not, however, remove the need to dither.  Spectral (pure sine wave) components in the distortion caused by round-off can be quite noticable even when the overall quantization noise is below the signal's floor.  Dithering smooths this distortion into white noise, spreading it across all bands, and ensuring no component is too high.

If you ever have to convert from continuous real number samples to integers, keep in mind this simple rule of thumb.  Always dither before you quantize.

Comments

  • Anonymous
    October 23, 2006
    Partly true. Dithering decorrelates quantization noise from the signal, which is a good thing, if in fact the quantization noise is the limiting factor. However, in most practical applications the noise floor is not determined by quantization but by the electronic hardware and signal chain in front of the A/D. In these cases, dithering just adds more noise.Another good application for dither are coherent measurments. Noise reduction by averaging only works if the noise is decorrelated. Adding a dither allows to make measurement that have higher resolution than the A/D . But again, in most practical cases, quantization noise is the smallest problem
  • Anonymous
    October 25, 2006
    When the signal chain noise floor is the limiting factor, dithering noise is generally not very significant.  Noise adds in power linearly.  If, for example, you have a signal path noise floor of -85dB (pretty good for a PC), and you dither before converting with a 16-bit DAC, your combined noise floor after dithering is:10*log10(10(-85/10.0) + 10(-96/10.0)) = -84.7dB, which means you've lost 0.3dB.In exchange for raising the noise floor by a third of a decibel, you now have a better representation of the actual captured signal (usually just a better representation of the analog signal path noise, but this is still more desirable than signal correlated quantization noise)You should always dither before quantizing.  In the cases where it doesn't help that much, it also doesn't hurt that much, and it still helps more than it hurts.