Dithering

Tags: , , , ,

Testing some algorithms for dithering

From Wikipedia:

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.

I implemented the “classic” error-diffusion algorithms (i.e. Floyd-Steinberg, Atkinson, Sierra, etc.), Bayer-matrices and noise-dithering algorithms.

All of them are parallelized with numba, making the first function call quite long, but then we process images of dimensions 1000x1000px in less than 50ms. This is not real time, but pretty close.

Results

We output the input image in B&W (Of course, we can run it in RGB or grayscale, but it is way less interesting to look at). Have a big zoom on one of the below image to understand that here, “black and white” means really black and white.

Error-Diffusion

AlgorithmOutputAlgorithmOutput
Floyd-SteinbergAtkinson
SierraJarvis-Judice-Ninke

Bayer

AlgorithmOutputAlgorithmOutput
Bayer 2x2Bayer 4x4
Bayer 8x8Bayer 16x16
DotsVoid and clusters

Noise

Noise distributionOutputNoise distributionOutput
BluePink
RedViolet
WhiteCustom

At one point I’ll explain a bit what you see here…

I’ll leave the GitHub link here.

GitHub tag

Tags: , , , ,