News for hackers. Stuff that matters.
Re:Image Dithering: Eleven Algorithms and Source Code by dreamcompiler on Friday October 06, 2017 @12:51AM (#15414509)
Dithering trades sample resolution for sample frequency to convey the same information. For images, the underlying sample frequency usually doesn't change but the apparent spatial sample frequency becomes lower in order to achieve more than one effective bit per (coarser) sample.

For one-dimensional signals like audio, the underlying sample frequency is usually increased while decreasing the sample resolution (often to 1 bit per sample). This keeps the effective Nyquist frequency where it needs to be while pushing noise much higher in frequency where it's very easy to remove with an analog filter. Delta-sigma modulation is perhaps the most common method of audio dithering (although the delta-sigma literature rarely uses the D word).

The reason images and audio usually use dithering in opposite ways is that images are usually post-processed for lower true sample resolution (and higher effective sample resolution) after sampling, while audio is often sampled initially at much higher than the Nyquist frequency because dithering is a planned part of the audio processing chain. But not always! Those are merely common use cases.

Re:Image Dithering: Eleven Algorithms and Source Code by starmole on Friday October 06, 2017 @01:34AM (#15414634)
I'm not sure I follow. To me dithering comes from quantization. I don't think you should think of dithering in frequency space.

https://bjango.com/images/articles/gradients/dithering-extre...

Illustrates the same signal dithered or not. No sampling rate involved.

And please correct me if i'm wrong, but you can not trade sample accuracy for sampling rate.

Re:Image Dithering: Eleven Algorithms and Source Code by gugagore on Friday October 06, 2017 @08:10AM (#15416134)
You can trade sample accuracy for sample rate. This is how I directly interpret ordered dithering. The following line on the wikipedia article communicates (maybe) this:

"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."

Same idea applies to 1D signals (from https://www.wikiwand.com/en/Delta-sigma_modulation : " used to convert high bit-count, low-frequency digital signals into lower bit-count, higher-frequency digital signals")

same idea: https://www.wikiwand.com/en/Class-D_amplifier https://www.wikiwand.com/en/Pulse-density_modulation

Re:Image Dithering: Eleven Algorithms and Source Code by HelloNurse on Friday October 06, 2017 @09:09AM (#15416477)
Dithering noise, i.e. the difference between the original signal and the dithered signal, needs to be considered in "frequency space" like any other kind of noise.

Dithering noise has the special feature of depending very strongly on the sampling rate and (statistically) very weakly on the input signal being dithered.

Dithering allows replacing high-accuracy sampling (typically constrained by computer word lengths) with high-sample rate sampling (typically cheap): without using more accurate arithmetic, analog and often completely free lowpass filtering (such as looking at a dithered image from far enough) makes N samples, with M bits of accuracy each, equivalent to one sample with M+log N bits of accuracy.

Re:Image Dithering: Eleven Algorithms and Source Code by dreamcompiler on Friday October 06, 2017 @09:47AM (#15416722)
You can indeed trade sample accuracy for sample rate as long as information is not lost -- and in dithering, information is preserved by diffusing the quantization error spatially.

Look at the image you posted; on the right, the effective "pixels" have become larger while each has acquired more gray levels. That's a lower sample frequency traded for higher quantization resolution.

Re:Image Dithering: Eleven Algorithms and Source Code by dahart on Friday October 06, 2017 @11:03AM (#15417302)
You're thinking of error diffusion, not the dithering itself, they are two separate things. Error diffusion is what spreads samples out spatially.

Audio and image dithering are the same thing, they only become different when you add error diffusion.

The modern image dithering that you use when going from an HDR image down to an 8-bits per pixel PNG or JPG uses exactly the same (very simple) algorithm you'd use to dither an audio file during mastering.

Re:Image Dithering: Eleven Algorithms and Source Code by dreamcompiler on Friday October 06, 2017 @12:24PM (#15418019)
Fair enough. I forgot about noise dithering, which only preserves error information statistically rather than exactly.

I don't understand your point about audio and image dithering being different when error diffusion is present. You can use error diffusion on both; in delta-sigma audio modulation, the error is diffused in only one dimension but it's still error diffusion.

Re:Image Dithering: Eleven Algorithms and Source Code by dahart on Friday October 06, 2017 @12:35PM (#15418116)
> You can use error diffusion on both

Yes, absolutely right. Just making clear the distinction between dither and diffuse. Dither is always a local operation on a sample, diffuse is the spatial spreading to make the neighborhood more pleasant for humans.

I was reacting to the statement "images and audio usually use dithering in opposite ways". The article here is about error diffusion, but it's pretty hard to say whether adding error diffusion to the dither process is the 'usual' choice, for either images or audio. It's very very common to not use error diffusion in both cases.

Diffuse is more much important when the destination resolution is well above human perceptible just-noticeable differences. For example, going from 8 bits per channel to 1 bit per pixel, or for audio when going from 16 bit samples down to 8 bit samples.

Re:Image Dithering: Eleven Algorithms and Source Code by dreamcompiler on Friday October 06, 2017 @05:49PM (#15420735)
Agreed. I understand your point now. Thanks.