alt.hn

4/28/2026 at 4:23:50 PM

Creating a Color Palette from an Image

https://amandahinton.com/blog/creating-a-color-palette-from-an-image

by evakhoury

4/30/2026 at 4:36:57 AM

Y'all have got to check out the color palette widget wizardry of David Aerne. Seriously, the guy's prolific. The first link is similar to OP's, an image color palette extractor:

https://okpalette.color.pizza

https://meodai.github.io/RYBitten

https://rybitten.space

by rezmason

4/30/2026 at 6:43:54 PM

is there source for okpalette.color.pizza? or at least the underlying algorithm, or info on how it is designed?

by adzm

4/30/2026 at 6:40:01 PM

love there resources, thanks!

by bookedkit

4/30/2026 at 4:24:46 AM

This might be the best color palette generator I’ve ever seen. I used to work in Operating Systems, and trying to get a good color palette from a photo is HARD. A lot of very smart very well paid people have dedicated years of their life to this type of thing. Really fantastic work.

If the author of the blog post ever comes across this thread/ comment, bravo and I hope you feel pride in your work and I’d go so far to say discovery.

by cududa

4/30/2026 at 6:22:11 AM

Can you talk a bit more on what makes this hard from your experience/pov, asking as someone who doesn't have much experience with this type of work

by altmanaltman

4/30/2026 at 6:47:55 AM

Agreed - I remember implementing colour quantisation in MATLAB at university and it seemed simple enough, though we only used it for some simple cases (to learn the theory more than anything). Looking at some of the example images there it looks like it's easy to hit edge cases.

by jamesfinlayson

4/30/2026 at 11:42:27 AM

Can you show the link to it? I just don't see it.

by assimpleaspossi

4/30/2026 at 6:19:25 AM

I agree with the kudos, but back when I was an interesting person and in early 2000s I stumbled on this same/similar approach of using K-means clusters with LAB color space for a painting algorithm I was using in my masters project. RGB was not effective.

by gedy

4/30/2026 at 8:59:11 AM

This is quite amazing. The quality of the created palettes is surprisingly good.

For the fourth iteration (guarding against phantom blue from shadow pixels), I wonder if it may help to also take into account how close the pixels in each cluster actually cluster together in the actual photo. (None of the heuristics used here seem to be interested in the position of the pixels at all, only in their values - as-is, it seems one could sort the photo's pixels before running the program and get the same result.) Actual objects usually form connected areas, whereas at least in the fruit image, the phantom shadows are spread across the entire photo in largely disconnected chunks.

by indigo945

4/30/2026 at 9:35:57 AM

I've been working on an adjacent problem (extracting website branding data from a URL) for the past year, and previously had to rely on procedural techniques such as these -- props to the author!

However, models are now getting to the point where we are starting to learn the bitter lesson[0] even with stuff like color-palette generation. Nano Banana 2 [gemini-3.1-flash-image-preview] especially is adept at performing arbitrary operations on images. Before then, you would have to use a model such as Gemini Flash to perform segmentation[1] and then post-analyze those segments.

Here's a prompt I used with Nano Banana 2 in AI Studio

> Derive a coherent, designer's color palette from this image alone.

> Provide 5 distinct HEX color codes as your response.

[Attachment == the picture of the car, first in the author's article] [Settings: Output .. images & text; Thinking level .. minimal]

Response:

> I have extracted five distinct hex color codes directly from the key elements in this image, representing the colorful facade and the vintage car:

> #FF96C5 (The main pink wall)

> #38C6F1 (The light blue car)

> #AEF6A5 (The green wall)

> #E51988 (The dark pink trim and railing)

> #5F432B (The dark wood of the door and windows)

And they all pretty-much check out. Not hyper-accurate, but really not far off anymore. I didn't even have to try!

[0] - https://en.wikipedia.org/wiki/Bitter_lesson [1] - https://ai.google.dev/gemini-api/docs/image-understanding#se...

by sarreph

4/30/2026 at 7:27:11 AM

Very cool. Looks very nice. I have a small utility that I made for myself and just added your algo to it: https://github.com/wkoszek/imgstat -- palette looks much better to what I had before.

by wkoszek

4/30/2026 at 3:19:59 AM

This is cool, I’m going to try write my own implementation to follow along as a learning exercise

by comradesmith

4/30/2026 at 1:02:40 PM

Was there a link to the code or app or something in there that I missed?

by anentropic

4/30/2026 at 3:24:55 AM

Interesting design choices.

Have you ever tried allrgb.com? The idea is to use every 24-bit RGB triplet once and only once. Many people naturally choose 4096x4096 as the final image size.

by firebot

4/30/2026 at 5:12:59 AM

[dead]

by dfordp11