
Show HN: Ordered Error Diffusion Dithering - vanderZwan
https://observablehq.com/@jobleonard/ordered-error-diffusion-dithering
======
vanderZwan
So as I mentioned somewhere in the wall of text, I'm fairly convinced that
combining error diffusion with ordered dithering must already exist. It feels
like such an obvious and fundamental idea to _not_ have been discovered
already at some point by one of the many, many people who have spent time
implementing and tinkering with dithering algorithms.

So part of the reason why I submitted this was that I hoped that it would
result in some feedback from people saying _" oh yeah, that's actually pretty
standard stuff, Knuth mentions it on page X"_, but maybe the topic is a bit
too niche even for HN.

~~~
svat
> _combining error diffusion with ordered dithering must already exist._

> _people saying "oh yeah, [...] Knuth mentions it on page X"_

Though the following answers your question only in a literal sense, you might
find it interesting to read Knuth's article "Fonts for Digital Halftones",
originally published in _TUGboat_ (the magazine of the TeX Users Group),
Volume 8 (1987), No. 2:
[http://mirror.tug.org/TUGboat/tb08-2/tb18knut.pdf](http://mirror.tug.org/TUGboat/tb08-2/tb18knut.pdf)
(Reprinted with revisions as Chapter 21 of _Digital Typography_.) Though it
technically mentions "ordered dither" (on the first page), it uses it in a
different sense/purpose (to get an initial patterns of dots that make up a
"font" called "odith"). It does do error diffusion though (details are in
appendix).

Ah, the next chapter of _Digital Typography_ (Knuth's paper "Digital Halftones
by Dot Diffusion") seems even more relevant. It mentions "It would be nice to
have a solution that retains both the sharpness of the Floyd-Steinberg method
[of error diffusion] and the parallelism of ordered dither" and does something
that seems to combine the two. (DOI 10.1145/35039.35040)

~~~
vanderZwan
> _Digital Halftones by Dot Diffusion_

Is that the same dot diffusion that is also mentioned here?

[http://caca.zoy.org/study/part3.html](http://caca.zoy.org/study/part3.html)

If I understand the description that page correctly, dot diffusion _visits_
pixels in Bayer order (instead of from left to right, top to bottom), and
propagates error to all surrounding pixels that have not been visited yet. So
yes, that does combine ordered dithering with error diffusion, but in a very
different fashion than I do. The output (at least on the page that I've
linked) is very half-tone ish.

~~~
svat
Haha just read the page again properly:

> Do not get fooled by Knuth’s apparent good results. They specifically target
> dot printers and do not give terribly good results on a computer screen.

But of course! Knuth, as is his wont, was obviously not targeting computer
screens or even targeting dot printers in general but a specific (Imagen)
printer that happened to be on the Stanford campus. :-)

~~~
vanderZwan
Ah, that explanation makes a lot of sense actually! :)

------
nullc
I consider this thesis one of the best works on dither and noise shaping
(error diffusion is just another name for noise shaping):
[http://uwspace.uwaterloo.ca/bitstream/10012/3867/1/thesis.pd...](http://uwspace.uwaterloo.ca/bitstream/10012/3867/1/thesis.pdf)

~~~
vanderZwan
Looks like a great resource! It seems mostly focused on one-dimensional cases,
based on a quick skim, so that would take some time to grok and "translate" to
2D images, but it looks like it's full of in-depth theory and other useful
information to make sense of what I'm experimenting with. Thanks!

~~~
nullc
The generalization to 2D is relatively straight-forward.

My own interest in the subject has mostly been 1D signals which might also
serve to explain my affection for that thesis... but it really is much easier
to understand first in 1D.

------
mnw21cam
Blank page? What's it meant to show?

~~~
vanderZwan
Observable uses JavaScript to render the page, I presume that's why it's
broken for you (I use uMatrix myself as well).

It's supposed to show an interactive notebook with canvas-based images,
describing how ordered dithering can be composed with error diffusion
dithering to create a form of hybrid dithering that is somewhere in-between.

~~~
zzo38computer
I only want a description (that I can copy, print out, or whatever); not an
interactive notebook.

~~~
vanderZwan
Really? Is half of the feedback I'm going to get here complaints that the
webpage isn't static enough?

Look, it's a simple page with text and images describing what happens. There
is a description of the algorithm.

But one of the neat things of this method is that you can combine any error
diffusion method with any threshold map, so to illustrate the point I
implemented the idea in an interactive page where you can combine 14 different
error diffusion methods with 12 threshold maps and 3 input images, for a total
of 504 possible combinations. My apologies for giving you easy tools to
experiment.

~~~
mnw21cam
If I go to a web site, and it's a blank page, that gives me zero information.
It's quite trivial to have a fallback, even if it just says "Really sorry, I
see you have Javascript off, but this web page does cool things that need
Javascript, so you won't see much here unless you switch it on. I promise not
to do evil things."

~~~
vanderZwan
Well, I suggest you either tweet at Observable, or open a feedback topic on
their forums. Either way, I'm not in charge of their website (and would not
have been able to implement this stuff in a day on any other platform, so no,
building a static site from scratch is not a realistic option for me).

[https://twitter.com/observablehq](https://twitter.com/observablehq)

[https://talk.observablehq.com/](https://talk.observablehq.com/)

