TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Image Dithering: Eleven Algorithms and Source Code

125 pointsby Ivoahover 7 years ago

14 comments

mark-rover 7 years ago
The article doesn&#x27;t put enough emphasis on the need for gamma correction. If you dither a pure gray area of level 128, it will become approximately 50% white and 50% black. But when you display that back on the screen, because of gamma effects it will look closer to a level of 186!<p>A few years ago there was a need for 15-bpp or 16-bpp color images on phones rather than the 24-bpp images we usually work with, and dithering was a great way of producing them. No idea how much need there is today though.
评论 #15416881 未加载
评论 #15415000 未加载
评论 #15415229 未加载
评论 #15417190 未加载
raphlinusover 7 years ago
There&#x27;s a really good technique for getting rid of the wormy or snake-like textures in Floyd-Steinberg: add another term to the threshold proportional to (some monotonic function of) the distance to the nearest preceding dot. This tends to make the dots very nicely spaced. These ideas were, among other places, used in Gutenprint.<p>A bit of description, and ancient but working GPL&#x27;ed code here: <a href="http:&#x2F;&#x2F;www.levien.com&#x2F;artofcode&#x2F;eventone&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.levien.com&#x2F;artofcode&#x2F;eventone&#x2F;</a><p>A paper containing the basic output-dependent feedback idea: <a href="http:&#x2F;&#x2F;levien.com&#x2F;output_dependent_feedback.pdf" rel="nofollow">http:&#x2F;&#x2F;levien.com&#x2F;output_dependent_feedback.pdf</a>
dreamcompilerover 7 years ago
Dithering trades sample resolution for sample frequency to convey the same information. For images, the underlying sample frequency usually doesn&#x27;t change but the <i>apparent</i> spatial sample frequency becomes lower in order to achieve more than one effective bit per (coarser) sample.<p>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&#x27;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).<p>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) <i>after</i> sampling, while audio is often sampled <i>initially</i> 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.
评论 #15414634 未加载
评论 #15417302 未加载
leni536over 7 years ago
Also a paper about halftoning on laser printers:<p><a href="http:&#x2F;&#x2F;users.eecs.northwestern.edu&#x2F;~pappas&#x2F;papers&#x2F;pappas_ist94.pdf" rel="nofollow">http:&#x2F;&#x2F;users.eecs.northwestern.edu&#x2F;~pappas&#x2F;papers&#x2F;pappas_ist...</a><p>I have never used a laser printer that did implement anything like this, the usual halftoning sucks. Once I handcrafted a file with a 600 dpi Floyd-Steinberg image (the native resolution of the printer I hadd) and it resulted in much better results, I didn&#x27;t bother calibrating the gray levels though.
评论 #15435698 未加载
hex12648430over 7 years ago
What a coincidence, I just stumbled upon this article a few hours ago while trying to find out which error diffusion algorithm is used by Photoshop out of curiosity.<p>I&#x27;ve been playing with dithering recently to create braille art[0] and this series of articles[1] by the libcaca developers has been a huge help. It also goes over model based dithering algorithms which tend to give the best results.<p>[0]: Example <a href="https:&#x2F;&#x2F;pastebin.com&#x2F;raw&#x2F;cRt4GL8j" rel="nofollow">https:&#x2F;&#x2F;pastebin.com&#x2F;raw&#x2F;cRt4GL8j</a><p>[1]: <a href="http:&#x2F;&#x2F;caca.zoy.org&#x2F;study&#x2F;index.html" rel="nofollow">http:&#x2F;&#x2F;caca.zoy.org&#x2F;study&#x2F;index.html</a>
starmoleover 7 years ago
Two modern use cases where dithering is more important than ever:<p>- Tone mapping hdr to display colors<p>- Alpha style transparency in deferred rendering<p>Also one case I heard about but don&#x27;t know much details is audio.<p>Dithering is important and powerful any time some precision is discarded.
评论 #15414870 未加载
评论 #15414399 未加载
nayukiover 7 years ago
Previous discussion: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=11886318" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=11886318</a><p>Another good page on image dithering: <a href="http:&#x2F;&#x2F;bisqwit.iki.fi&#x2F;story&#x2F;howto&#x2F;dither&#x2F;jy&#x2F;" rel="nofollow">http:&#x2F;&#x2F;bisqwit.iki.fi&#x2F;story&#x2F;howto&#x2F;dither&#x2F;jy&#x2F;</a>
temp45782over 7 years ago
The article mentions ordered dithering but fails to list void-and-cluster and similar variants thereof. Those parralelize really well (unlike error diffusion), don&#x27;t result in obvious patterns (unlike normal ordered dithering) and can be run on gpus. It&#x27;s quite useful to dither high bit depth videos to 8bit in realtime. Dithering HDR content has the benefit of not introducing banding on SDR displays.
sanquiover 7 years ago
Despite the criticism and glossing over in this article, I believe that ordered dithering gives the most aesthetically pleasing result myself.
评论 #15415418 未加载
bluedinoover 7 years ago
Seeing a dithered image really brings me back to the mid 90&#x27;s. Seeing a dithered photograph reminds me of the early web or AOL. You used to remove colors from GIFs to save space on web pages, as few as you could as long as the image was still tolerable.<p>With a 1MB SVGA card, you could pick between 16-bit color at 800x600, or 8-bit (256 colors) @ 1024x768. Did you value higher resolution, or not having to palette shift every time you switch apps?
anonfunctionover 7 years ago
I was showing coworkers an example of the Floyd Steinberg algorithm today.<p>The following images have the same amount of colors, namely black and white.<p><a href="https:&#x2F;&#x2F;i.imgur.com&#x2F;stQUl5E.gif" rel="nofollow">https:&#x2F;&#x2F;i.imgur.com&#x2F;stQUl5E.gif</a><p><a href="https:&#x2F;&#x2F;i.imgur.com&#x2F;mw8IX9N.gif" rel="nofollow">https:&#x2F;&#x2F;i.imgur.com&#x2F;mw8IX9N.gif</a><p>Source image:<p><a href="https:&#x2F;&#x2F;i.imgur.com&#x2F;diR72k2.jpg" rel="nofollow">https:&#x2F;&#x2F;i.imgur.com&#x2F;diR72k2.jpg</a>
评论 #15414787 未加载
评论 #15414621 未加载
nullcover 7 years ago
<a href="http:&#x2F;&#x2F;uwspace.uwaterloo.ca&#x2F;bitstream&#x2F;10012&#x2F;3867&#x2F;1&#x2F;thesis.pdf" rel="nofollow">http:&#x2F;&#x2F;uwspace.uwaterloo.ca&#x2F;bitstream&#x2F;10012&#x2F;3867&#x2F;1&#x2F;thesis.pd...</a> is one of the best general papers I&#x27;ve read on the subject.
afandianover 7 years ago
These images, especially the last one, bring back a tonne of nostalgia about early 90s Apple Macintoshes and my HP Deskjet 310.<p>I wonder what artifacts of the limitations of modern technology will be remembered with nostalgia by those growing up with today&#x27;s equipment.
wiz21cover 7 years ago
After having seen neural networks used to transform images, could we train a neural network to dither images ?<p>(obligatory NN comment :-))