We had another dithering post a few days ago and nobody answered my question... I'm reposting in case someone who comes here knows the answer:

"Does anyone know of any application/tool that can perform palette dithering? The idea is "here is a n-color palette specified in their RGB values, here is the full-color RGB image, give me the best possible dithered image using the provided palette". The tools that I've used were underwhelming and produced results full of banding and artifacts.

Basically, great dithering in color instead of B/W."

EDIT: Thank you for the answers! I'll check all links.

I left a comment [0] on the other thread, and this is irrelevant if you aren't using Photoshop, but there's a plugin called DITHERTONE Pro that gives you a lot of control over the dither algorithm used + color grade. For actual design, I tend to use this since I'm already in PS cobbling together an image, and you can tweak the results in realtime to dial it in how you want.

I also have used didder [1] a couple times for dithering via CLI / script. Its results can be pretty good too, just more for repeatable batch operations and you need to make sure your palettes and chosen algorithms will produce what you're actually looking for.

[0] https://news.ycombinator.com/item?id=45726845

[1] https://github.com/makew0rld/didder

Cole (the author of didder) also has a GUI version called Dithertime: https://makew0rld.itch.io/dithertime

This looks like what I want - thank you!

That’s going to be a tricky problem full of compromises, and entirely up to how you formalize your definition for “the best possible dithered image”.

Do you care about preserving relative brightness, contrast, edges,… etc.

Human color perception is tricky, and in the outline you give it’s entirely possible that the provided n-color palette (also, what order of magnitude n are we talking about here?) would be inadequate for a satisfactory rendering of the provided full color image.

I'd just like a subjectively "good" result that beats the manual approaches using image manipulation programs.

n would be less than 4096, but usually much smaller values (256, 16)

I responded in that post (though not to you, and probably not what you're after) with a link to my JS canvas library's "reduce palette" filter. It includes both supplying an array of colors to act as the palette, and setting the required number of colors for which the filter can calculate a "commonest colors" palette, calculating color distances in the OKLAB color space - https://scrawl-v8.rikweb.org.uk/demo/filters-027.html

If anyone wants to see the filter code, it in the GitHub repo here: https://github.com/KaliedaRik/Scrawl-canvas/blob/064469928a3...

I’m using this for making some quake inspired textures - it’s a bit clunky but works for me https://captain4lk.itch.io/slk-img2pixel

Use Google's Squoosh.app: https://squoosh.app

When editing an image you can choose the 'Reduce palette' option to bring up a way to reduce the number of images used, and the palette reduction panel will let you optionally apply dithering or not.

The dithering algorithm is not selectable but it's worth trying to see if you like it.

I don't know if it's exactly what you're looking for but I made a free tool https://app.dithermark.com . It only allows 18 colors max, but it has a lot of options, including the ability to determine what color palette to use.

This is common functionality in graphics software, but there isn't such a thing as "the best possible dithered image using the provided palette"; there are unavoidable tradeoffs between sharpness and color precision, so different ways of dithering may be better for different purposes.

The gimp can do this.

Define your palette, then via the dialog spawned through image->format menu, pick your palette from the list.

Yes, but the algorithm isn't that great... That's what I'm using now

"Positional" is a single, relatively boring hardcoded pattern, and the other options are Floyd–Steinberg error diffusion.

I do agree it would be nice to extend gimp to do all sorts of fancy dithering, and imagine it's just that nobody has put on the work yet.

Floyd–Steinberg is pretty great when your palette has reasonably-close colors.

In my own experience playing with dithering, generating a palette is often harder than the dithering itself.

Heckbert's median-cut algorithm usually does a great job. See https://web.cs.wpi.edu/~matt/courses/cs563/talks/color_quant.... There's probably something improved since then, though.

That's cool, and resembles my own approach, which I'll reevaluate and polish now :)

Delighted to help! I've never implemented it myself.

ImageMagick with `-dither` and `-remap` could also work. For remap you would need an image with your desired palette, and IIRC you could use ImageMagick to produce that image but I cannot recall the incantation required for that.