Forums

Dthering....

Started by Piergiorgio Sartor October 10, 2003
Eric Jacobsen wrote:

> On Fri, 10 Oct 2003 11:22:16 +0200, Piergiorgio Sartor > <piergiorgio.sartor@nexgo.REMOVE.THIS.de> wrote: > > >>Hi, >> >>I've a question about dithering in the digital domain. >> >>Let's say I've to quantize a signal from 12 bits to 8 bits. >> >>1) Does it make sense to apply dithering at all? >>2) The noise (dithering) signal, must be real noise, or it >> is enough to be just an uncorrelated signal? >> >>For 2) I mean some signal with spectral properties similar >>to white noise, but not a real random signal. For example >>something like a sawtooth. >> >>Final note: the signal to be dithered is finite in time. > > > On 1): It you want to decorrelate the spurs due to the new > quantization noise, then, yes, absolutely dithering can help. Whether > or not it makes sense in your case depends on what you're doing and > what you need to get out of it. > > 2) Using a sawtooth won't be nearly as effective as a more noisy > signal, but it might help compared to no dithering. Consider that the > sawtooth signal has spectral contents that will still be present after > dithering, and if not carefully controlled the sawtooth spectrum may > add to desired signals that you'd like to preserve. The idea of > adding noise is that it completely decorrelates the spurs due to the > quantization, but has a very small and uniform effect in the frequency > domain on the remaining signal. I find it unlikely that a sawtooth > would be nearly as effective as noise. > > > Eric Jacobsen > Minister of Algorithms, Intel Corp. > My opinions may not be Intel's opinions. > http://www.ericjacobsen.org
I suspect -- another to say that I'm willing to make a wild guess -- that fraction saving will work better than a sawtooth, and it's easier to implement in the bargain. It will certainly push most of the added noise to the upper end of the spectrum, and it may minimize it. Jerry -- Engineering is the art of making what you want from things you can get. &#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
On Fri, 10 Oct 2003 18:03:41 -0400, Jerry Avins <jya@ieee.org> wrote:

>I suspect -- another to say that I'm willing to make a wild guess -- >that fraction saving will work better than a sawtooth, and it's easier >to implement in the bargain. It will certainly push most of the added >noise to the upper end of the spectrum, and it may minimize it.
Jerry, you've stumped me. What's "fraction saving"? Eric Jacobsen Minister of Algorithms, Intel Corp. My opinions may not be Intel's opinions. http://www.ericjacobsen.org
In comp.dsp, Piergiorgio Sartor
<piergiorgio.sartor@nexgo.REMOVE.THIS.de> wrote:

>Hi, > >I've a question about dithering in the digital domain. > >Let's say I've to quantize a signal from 12 bits to 8 bits. > >1) Does it make sense to apply dithering at all? >2) The noise (dithering) signal, must be real noise, or it > is enough to be just an uncorrelated signal?
What's your definition of 'real noise'? The numeric output of pseudo-random number generators (prng's), which takes very few instructions per sample, while not "truly random," works fine for dither. This is not 'expensive' as you said in a followup, though if you want to use "noise-shaping" (noise filtered for a narrow frequency range, such as above 10kHz in audio where the noise is less audible) you need a filter which may take significant amount of processing time.
>For 2) I mean some signal with spectral properties similar >to white noise, but not a real random signal. For example >something like a sawtooth.
A sawtooth is not even a "fake random signal." This (if I understand what you're thinking, adding a sawtooth with 1LSB p-p amplitude) will not decorrelate the same way random (or pseudo-random from a RNG) noise does, but will modulate the distortion components with the sawtooth frequency, making sum-and-difference frequencies between the sawtooth and the signal. This will probably make things worse, not better.
>Final note: the signal to be dithered is finite in time.
What does this mean? It lasts a short time? How many samples? How is this relevant to whether you should dither or not? An audio CD is "finite in time." It can hold over 150 million samples, and dither works fine for it. To make a good decision about what to do, you will have to learn more about dither yourself, or describe the application to us. Here's a bad, crude, "popular-science-in-the-daily-newspaper" description of dither (apologies to the authors, but dither is a little complicated, and they can't get in-depth in just "a moment"): http://amos.indiana.edu/library/scripts/dither.html Here are two better links - a National Semiconductor app note. It describes going from analog-to-digital, but it's the same as going from a large number of bits per sample to a smaller number): http://www.national.com/an/AN/AN-804.pdf One related specifically to bit reduction in audio (click on articles, then dither): http://digido.com
>Thanks, > >bye, > >-- > Piergiorgio Sartor >
In article <bm73lf$jnnov$1@ID-210375.news.uni-berlin.de>,
Jon Harris <goldentully@hotmail.com> wrote:
>"Piergiorgio Sartor" <piergiorgio.sartor@nexgo.REMOVE.THIS.de> wrote >in message news:3f86be04$0$258$4d4ebb8e@read.news.de.uu.net... >> What about using, as dithering signal, something like: >> >> -3, -2, -1, 0, 1, 2, 3, 2, 1, 0, -1, -2, -3, etc.? > >I triangular PDF is much different than a triangle wave! You want >the former, not the latter.
Although this triangle wave (known spectra) dither might work if the input signal has absolutely no frequency components in common with the dithering triangle wave specta (DC, or a single frequency lower and relatively prime to the trangle wave frequency over the window of interest), and you can post filter the triangle wave spectra out of the resultant data later. IMHO. YMMV. -- Ron Nicholson rhn AT nicholson DOT com http://www.nicholson.com/rhn/ #include <canonical.disclaimer> // only my own opinions, etc.
Eric Jacobsen wrote:

> On Fri, 10 Oct 2003 18:03:41 -0400, Jerry Avins <jya@ieee.org> wrote: > > >>I suspect -- another to say that I'm willing to make a wild guess -- >>that fraction saving will work better than a sawtooth, and it's easier >>to implement in the bargain. It will certainly push most of the added >>noise to the upper end of the spectrum, and it may minimize it. > > > Jerry, you've stumped me. What's "fraction saving"? > > > > Eric Jacobsen > Minister of Algorithms, Intel Corp. > My opinions may not be Intel's opinions. > http://www.ericjacobsen.org
Going from, say, 12 bits to 8 amounts to truncating. Fraction saving is a way to deal with truncation. The problem has so far been looked at as quantization noise, but I'm suggesting another view. Whenever a a 12-bit number is approximated by 8 bits (whether by truncating or rounding), there is a known error (the assumption being that the 12 bits were exact). Carrying that error as unfinished business when shrinking the next sample makes the average error zero, keeping the low end of the spectrum error free. There are two samples for the highest frequency, and trying to force the error of one to offset that of the other won't make the high end worse. The process is similar to remainder saving when accumulating the results of successive divisions. We played with that one in a thread some time ago. R.B-J. described the process as a way to avoid limit cycles in IIRs, I described its use in a lossy accumulator (same thing, really), and Randy Yates provided the name. I think it should work wherever truncation is needed. Call it "noise shaping" if you like, except there's no oversampling. Jerry -- Engineering is the art of making what you want from things you can get. &#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
Ben Bradley wrote:

> What's your definition of 'real noise'? The numeric output of > pseudo-random number generators (prng's), which takes very few > instructions per sample, while not "truly random," works fine for
It's periodic, like a sawtooh or triangle signal. So, the autocorrelation it's not a dirac pulse. If I can use this kind of noise, why not to use a sawtooth? Much easier.
> A sawtooth is not even a "fake random signal." This (if I
Well symbol probability is uniform, correlation is periodic and the relationship with the original signal is completly casual, since the original signal can be considered random.
> understand what you're thinking, adding a sawtooth with 1LSB p-p > amplitude) will not decorrelate the same way random (or pseudo-random > from a RNG) noise does, but will modulate the distortion components > with the sawtooth frequency, making sum-and-difference frequencies > between the sawtooth and the signal. This will probably make things > worse, not better.
OK, that's clear.
>>Final note: the signal to be dithered is finite in time. > > What does this mean? It lasts a short time? How many samples? How
Well, I do not know if this has drawbacks or note, that's why I'm noting this.
> is this relevant to whether you should dither or not? > An audio CD is "finite in time." It can hold over 150 million > samples, and dither works fine for it.
But it can be considered an infinite stream in practice. If I have, let's say, 1024 samples?
> To make a good decision about what to do, you will have to learn > more about dither yourself, or describe the application to us.
Of course.
> Here's a bad, crude, "popular-science-in-the-daily-newspaper" > description of dither (apologies to the authors, but dither is a > little complicated, and they can't get in-depth in just "a moment"): > > http://amos.indiana.edu/library/scripts/dither.html
>
> Here are two better links - a National Semiconductor app note. It > describes going from analog-to-digital, but it's the same as going > from a large number of bits per sample to a smaller number): > > http://www.national.com/an/AN/AN-804.pdf > > One related specifically to bit reduction in audio (click on articles, > then dither): > > http://digido.com
Thanks, I'll have a look. bye, -- piergiorgio
Jon Harris wrote:
> [...] > In audio, dithering can be used to make "digital" sound more like "analog". > Consider a fading out (decaying) sine wave. When recorded on analog tape, > the signal gets progressively softer until it dips below the noise floor. > Regardless of the level, it always sounds like a sine wave + noise. With > (undithered) digital, as the number of available bits diminishes, the sine > wave starts to look more and more like a triangle or square wave. This > sounds like a distorted sine wave (often described as "grainy"), not a sine > wave + noise. Adding appropriate dither makes it again sound like a sine > wave + noise.
I would say that anyone who isn't using dither when digitizing a signal isn't doing digital "right." There is no difference between digital and analog as long as sample rate and resolution are chosen so that bandwidth and SNR are the same (or better) as the analog counterpart. -- % Randy Yates % "...the answer lies within your soul %% Fuquay-Varina, NC % 'cause no one knows which side %%% 919-577-9882 % the coin will fall." %%%% <yates@ieee.org> % 'Big Wheels', *Out of the Blue*, ELO http://home.earthlink.net/~yatescr
On Sun, 12 Oct 2003 01:12:58 -0400, Jerry Avins <jya@ieee.org> wrote:

>Eric Jacobsen wrote:
>> Jerry, you've stumped me. What's "fraction saving"?
>Going from, say, 12 bits to 8 amounts to truncating. Fraction saving is >a way to deal with truncation. The problem has so far been looked at as >quantization noise, but I'm suggesting another view. Whenever a a 12-bit >number is approximated by 8 bits (whether by truncating or rounding), >there is a known error (the assumption being that the 12 bits were >exact). Carrying that error as unfinished business when shrinking the >next sample makes the average error zero, keeping the low end of the >spectrum error free. There are two samples for the highest frequency, >and trying to force the error of one to offset that of the other won't >make the high end worse. > >The process is similar to remainder saving when accumulating the results >of successive divisions. We played with that one in a thread some time >ago. R.B-J. described the process as a way to avoid limit cycles in >IIRs, I described its use in a lossy accumulator (same thing, really), >and Randy Yates provided the name. I think it should work wherever >truncation is needed. Call it "noise shaping" if you like, except >there's no oversampling.
In practice I usually handle this by rounding after truncating, in other words, add the LSB-1 bit to the new LSB. This goes a long way toward eliminating bias, etc., and reducing truncation errors. Eric Jacobsen Minister of Algorithms, Intel Corp. My opinions may not be Intel's opinions. http://www.ericjacobsen.org
Eric Jacobsen wrote:

> >> >>The process is similar to remainder saving when accumulating the results >>of successive divisions. We played with that one in a thread some time >>ago. R.B-J. described the process as a way to avoid limit cycles in >>IIRs, I described its use in a lossy accumulator (same thing, really), >>and Randy Yates provided the name. I think it should work wherever >>truncation is needed. Call it "noise shaping" if you like, except >>there's no oversampling. > > > In practice I usually handle this by rounding after truncating, in > other words, add the LSB-1 bit to the new LSB. This goes a long way > toward eliminating bias, etc., and reducing truncation errors. > >
Don't you mean add the MSB of the truncated part to the LSB of what's left? Adding the whole remainder does the same thing, but sometimes rounds up when your way wouldn't', sometimes actually rounds down, and in general makes the average error (DC) exactly zero. You must have read http://www.dspguru.com/comp.dsp/tricks/alg/dc_block.htm Am I mistaken that it applies here? Jerry -- Engineering is the art of making what you want from things you can get. &#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
eric.jacobsen@delete.ieee.org (Eric Jacobsen) wrote in message news:<3f8b2809.432701556@news.west.earthlink.net>...
> On Sun, 12 Oct 2003 01:12:58 -0400, Jerry Avins <jya@ieee.org> wrote: > > >Eric Jacobsen wrote: > > >> Jerry, you've stumped me. What's "fraction saving"?
the way i would describe it is: 1st-order noise shaping with a zero exactly on z=1 and the quantizer is always in round-down (floor(x)) mode. as Jerry says, it is taking whatever bits your quantizer dropped, zero extending them, then feeding them back (positively) and adding them into the next sample before it is quantized.
> >The process is similar to remainder saving when accumulating the results > >of successive divisions. We played with that one in a thread some time > >ago. R.B-J. described the process as a way to avoid limit cycles in > >IIRs, I described its use in a lossy accumulator (same thing, really), > >and Randy Yates provided the name. I think it should work wherever > >truncation is needed. Call it "noise shaping" if you like, except > >there's no oversampling.
it is "noise-shaping". r b-j