Live data from Hacker News

Ditherpunk: The article I wish I had about monochrome image dithering

surma.dev

121–130 of 203 posts

Re: Ditherpunk: The article I wish I had about monochrome image dithering

#121

Shameful tangential plug alert: My sideproject is a dithering-based image-to-pattern converter for plastic fuse beads (you know them, the ones you place on a platter and iron to fuse them together): https://www.beadifier.pro/

Omg I didn’t think of this application for dithering. Love that.

It would work great for LEGO mosaics as well

Re: Ditherpunk: The article I wish I had about monochrome image dithering

#122
iirc, back in ~99, Unreal Engine was doing dithering on the u/v coordinates (!!) for texture mapping instead of bilinear interpolation. They used fixed Bayer matrix.

This was quite faster, visually pleasant, and was adapting nicely to viewing distance.

Try freezing some close-up frames around 0:45 here: https://www.youtube.com/watch?v=aXA3360awec

Tim Sweeney called this technique "ordered texture coordinate space dither", apparently:

https://www.flipcode.com/archives/Texturing_As_In_Unreal.sht...

Re: Ditherpunk: The article I wish I had about monochrome image dithering

#123
post #62
post #56

Earlier quoted context omitted.

Donald Knuth also has two nice chapters in "Digital Typography".

I might have to look that up. It's hard for me to imagine what dithering and typography would have in common, other than they might both be used to produce a book.

IIRC he created a special font for half-toning images.

Re: Ditherpunk: The article I wish I had about monochrome image dithering

#125
If you don't mind, I'll plug a little innovation of my own: mixing ordered and error diffusion dithering. The idea behind it is actually pretty simple: technically all forms of dithering use a threshold map, we just don't tend to think of it when it's one flat threshold for the entire image. So there is nothing stopping us from decoupling the threshold map from the rest of the dithering algorithm, meaning it's trivial to combine error diffusion with more complex threshold maps:

https://observablehq.com/@jobleonard/ordered-error-diffusion...

(For the record, I picked a default example that highlighted a "hybrid" dither with a very dramatic difference from its "parents" instead of the prettiest result)

Interestingly, and perhaps not surprisingly, a variable threshold map interacts with the error diffusion itself, making it amplify local contrast and recover some fine detail in shadows and highlights (although also possibly overdoing it and crushing the image again).

What's also somewhat interesting (to me at least) that this is really simple to implement: take any error diffusion dithering kernel and make it use the threshold map from ordered dithering. In principle it should have been possible to use them on any old hardware that can handle error diffusion dithering.

Re: Ditherpunk: The article I wish I had about monochrome image dithering

#127
Easy ditherpunk video treatment:

ffmpeg -i video-input.mp4 -i palette.png -lavfi "paletteuse=dither=sierra2" video-output.mp4

You'll need to create a 16px by 16px PNG with only black and white pixels. Also, there are other dithering algos that paletteuse offers.

Re: Ditherpunk: The article I wish I had about monochrome image dithering

#129
post #5

> According to Wikipedia, “Dither is an intentionally applied form of noise used to randomize quantization error”, and is a technique not only limited to images. It is actually a technique used to this day on audio recordings […] Dithering as a digital signal processing technique is also used frequently in the digital control of physical systems. One example of this is in the control of hydraulic servo valves[1]; the…

I think the best way of thinking about dithering, is that it's the 'whitening' of quantization noise. Quantization can be modelled by taking the difference between the originally continuous signal, and the resultant quantized image as "quantization noise". The resultant noise has a spectrum that's pretty 'spiky' due to its non-continuous nature, it has significant energy in its higher-frequency harmonics. By adding some noise before sending it off to be thresholded by the quantizer, the noise's spectrum is made a lot flatter, thus making the quantized image look more like the original image, but with a higher noise floor.
Post reply on HN