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.

Dithering in Colour

168 pointsby surprisetalk3 months ago

19 comments

AndrewStephens2 months ago
Dithering is something of a lost art now that our displays can handle millions of colors in high definition, but it can be a striking artistic effect.<p>If anyone thinks their websites are too colorful, I made a pure JavaScript web component to dither images on client in real time, taking into account the real pixel size of the current display.<p><a href="https:&#x2F;&#x2F;sheep.horse&#x2F;2023&#x2F;1&#x2F;improved_web_component_for_pixel-accurate_atkinson.html" rel="nofollow">https:&#x2F;&#x2F;sheep.horse&#x2F;2023&#x2F;1&#x2F;improved_web_component_for_pixel-...</a>
评论 #43354236 未加载
评论 #43354866 未加载
评论 #43352900 未加载
Clamchop2 months ago
They may not want to imply that didder&#x27;s linearized rabbit is wrong, but I&#x27;m comfortable saying so. It&#x27;s not just a little dark, it&#x27;s way dark, to the point of hiding detail.<p>The linearized RGB palette is similarly awful. It clobbers a whole swath of colors, rendering them as nearly black. Purples are particularly brutalized. Yellows disappeared and became white.<p>On my phone, the middle palette doesn&#x27;t appear too bright to my eyes, either.<p>Even the linearized gradient looks worse, .<p>Maybe linear is not best for perceptual accuracy.
评论 #43352095 未加载
评论 #43325777 未加载
评论 #43351538 未加载
评论 #43352428 未加载
评论 #43351520 未加载
评论 #43354870 未加载
mattdesl2 months ago
It might be worth using a lightness estimate like OKLab, OKLrab[1], or CIE Lab instead of the RGB luminance weighting, as it should produce a more perceptually accurate result.<p>The other issue with your code right now, is that it is using euclidean distance in RGB space to choose the nearest color, but it would be probably also more accurate to use a perceptual color difference metric, a very simple choice is euclidean distance on OKLab colors.<p>I think dithering is a pretty interesting area of exploration, especially as a lot of the popular dithering algorithms are quite old and optimized for ancient compute requirements. It would be nice to see some dithering that isn&#x27;t using 8-bits for errors, is based on perceptual accuracy, and perhaps uses something like a neural net to diffuse things in the best way possible.<p>[1] <a href="https:&#x2F;&#x2F;bottosson.github.io&#x2F;posts&#x2F;colorpicker&#x2F;" rel="nofollow">https:&#x2F;&#x2F;bottosson.github.io&#x2F;posts&#x2F;colorpicker&#x2F;</a>
评论 #43352763 未加载
评论 #43356681 未加载
评论 #43354082 未加载
评论 #43354596 未加载
crazygringo2 months ago
Did the author forget to finish the blog post?<p>They show a single example of incorrect dithering, explain it&#x27;s wrong, and then don&#x27;t show a corrected version. There isn&#x27;t a <i>single</i> example of proper color dithering.<p>And they talk about the distance to the nearest color (RGB) but don&#x27;t explain how to account for black or white -- how to trade off between accuracy of hue, brightness, and saturation, for example.<p>This post doesn&#x27;t explain at all how to actually dither in color. I don&#x27;t understand why this is on the front page with over 50 votes.
评论 #43354564 未加载
vintagedave2 months ago
&gt; If the linearised version looks wrong to you, try opening it on a larger monitor in it’s original size and check your gamma settings.<p>It looks far too dark, and I’m viewing it on an iPad with a high DPI screen. I also strongly suspect I can’t change the gamma on this device, nor have I ever knowingly done so. Anyone know why it looks bad?
评论 #43357828 未加载
nikolay2 months ago
I&#x27;ve done this in the early &#x27;90s, when I implemented all published algorithms back then into a Turbo Pascal program, which was allowing me to see full-color images on poor post-Soviet color displays - it wasn&#x27;t just doing dithering, but also allowing you to pan and zoom, while switching algorithms. Give the limitations of the hardware, I had to implement the algorithms with a running buffer, optimized for panning, i.e. incrementally dithering the image. As some could guess, not a small part of these images was erotic. The program also was able to print on a matrix printer and I was improving it and had some test printouts in my bag. As I was in high school back. At one point some kids put a classroom on fire and they were doing an investigation, so, at one point they asked me to open my school bag and show them the contents. And, yes, I got into a big, big trouble. It was really tough to provide a meaningful explanation that I had only limited set of true-color images and, of course, the most popular were erotic given the post-Soviet interest in erotica and pornography. So, every time when I read something about dithering here on HN, it brings back my memory of being taken to the police station by two cops in front of the entire school for &quot;distributing pornographic materials&quot;.
spacejunkjim2 months ago
When I saw this, I immediately had flashbacks to a little project I did for my CS course when I was an undergrad! We were all assigned a computer graphics algorithm and were tasked to build an animation explaining how it works.<p>This was nearly eight years ago, but I managed to find it this morning and uploaded it to YouTube.<p>Here was the resulting animation: <a href="https:&#x2F;&#x2F;youtu.be&#x2F;FHrIQOWeerg" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;FHrIQOWeerg</a><p>I remember I used Processing to build it, and it took so long to animate as I had to export it frame-by-frame. Fun days!
kaoD2 months ago
&gt; Dithering a black-to-white gradient will be wrong without linearising first.<p>TBH both look wrong to me. If I squint, neither dithering patterns match the original gradient... but the non-linearized one looks the most similar.<p>What could be causing this?
评论 #43352182 未加载
评论 #43352517 未加载
评论 #43352369 未加载
评论 #43352192 未加载
评论 #43353499 未加载
评论 #43352059 未加载
ggambetta2 months ago
Didn&#x27;t try error diffusion, but I had good results with Bayer for the ZX Spectrum Raytracer [0]. Bayer only ever looks at the pixel it&#x27;s considering, doesn&#x27;t do math beyond comparing a value to its threshold, it was surprisingly easy to implement, and looks nice. A great choice for ridiculously underpowered devices :)<p><a href="https:&#x2F;&#x2F;gabrielgambetta.com&#x2F;zx-raytracer.html#fourth-iteration-light-just-the-one" rel="nofollow">https:&#x2F;&#x2F;gabrielgambetta.com&#x2F;zx-raytracer.html#fourth-iterati...</a>
magicalhippo2 months ago
I&#x27;ve always been curious to what degree, if any, color constancy[1] affects color dithering.<p>Seems that at some level it should, though perhaps not directly at the pixel level due to the high frequency of the per-pixel differences, but maybe at the more coarse &quot;averaged&quot; level?<p>One of those things I&#x27;ve wanted to explore but remains on my to-do list...<p>[1]: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Color_constancy" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Color_constancy</a>
danybittel2 months ago
Error diffusion dithering is kind of old fashioned. It is a great algorithm where you only need to go though the image once, pixel by pixel. But it doesn&#x27;t work well with todays hardware, especially GPUs. Would be fun to come up with new algorithms that are better parallelizable.
评论 #43353864 未加载
评论 #43355686 未加载
criddell2 months ago
The dithering work Mark Ferrari did by hand on some of the old LucasFilm games was really impressive.<p><a href="https:&#x2F;&#x2F;www.superrune.com&#x2F;tutorials&#x2F;loom_ega.php" rel="nofollow">https:&#x2F;&#x2F;www.superrune.com&#x2F;tutorials&#x2F;loom_ega.php</a>
nigeltao2 months ago
Might be relevant to your interests:<p><a href="https:&#x2F;&#x2F;nigeltao.github.io&#x2F;blog&#x2F;2022&#x2F;gamma-aware-ordered-dithering.html" rel="nofollow">https:&#x2F;&#x2F;nigeltao.github.io&#x2F;blog&#x2F;2022&#x2F;gamma-aware-ordered-dit...</a>
omoikane2 months ago
See also: &quot;Joel Yliluoma&#x27;s arbitrary-palette positional dithering algorithm&quot;<p><a href="https:&#x2F;&#x2F;bisqwit.iki.fi&#x2F;story&#x2F;howto&#x2F;dither&#x2F;jy&#x2F;" rel="nofollow">https:&#x2F;&#x2F;bisqwit.iki.fi&#x2F;story&#x2F;howto&#x2F;dither&#x2F;jy&#x2F;</a><p>This page focuses on ordered dithering, which tend to work better for animations compared to error diffusion based dithering schemes (like the linked article).
eternityforest2 months ago
I wonder what would happen if you 3D printed a dithering pattern, of either a picture or just some perlin noise, as a fuzzy skin.<p>It seems like it could have a really nice effect.
alberth2 months ago
A fun website to try out different Dithering algorithms and settings.<p><a href="https:&#x2F;&#x2F;doodad.dev&#x2F;dither-me-this&#x2F;" rel="nofollow">https:&#x2F;&#x2F;doodad.dev&#x2F;dither-me-this&#x2F;</a>
JKCalhoun2 months ago
Just a guess — perhaps Bill Atkinson dropped the two x 1&#x2F;8 as a poor-man&#x27;s contrast.
somewhereoutth2 months ago
See also FadeCandy by Micah:<p><a href="https:&#x2F;&#x2F;scanlime.org&#x2F;2013&#x2F;11&#x2F;fadecandy-easier-tastier-and-more-creative-led-art&#x2F;" rel="nofollow">https:&#x2F;&#x2F;scanlime.org&#x2F;2013&#x2F;11&#x2F;fadecandy-easier-tastier-and-mo...</a><p>&gt; Firmware that uses unique dithering and color correction algorithms to raise the bar for quality while getting out of the way of your creativity.
评论 #43357783 未加载
yapyap2 months ago
Dithering is so neat.
评论 #43351936 未加载