3

I am trying to implement a system for extracting colour palettes from an image in C++. I basically want something exactly like the way Adobe Color's 'Extract Theme' function works.

I have tried implementing a version of median cut, but the averaging of the colours ultimately produces an unpleasing selection of final colours (though I may have implemented it wrong, I'm not sure).

I have tried k-means clustering (using this header library) but it doesn't seem to pick up a good selection of colours.

For example, here are the five colours that Adobe Color picks out of an example image: Adobe Color version

And here are the five colours selected by the k-means approach: K-Means version

Does anyone have any idea what's going on for the colour selection in the Adobe Color version? I'm trying to implement this inside Unreal Engine using C++, if that makes any difference.

Thanks.

  • you should also include how you define the similarity/distance between colors. a [mcve] would be even better. – apple apple Mar 07 '22 at 17:32
  • Did you look at *"Color Thief"*? – Mark Setchell Mar 07 '22 at 19:31
  • I believe I was using the Euclidean distance to define colour distance. I’ll work on trying to get an example prepared. I did find Color Thief, and it seems great, but there’s no easy way to run JS from inside Unreal (have had a quick look today but kept hitting walls) and it’s slightly beyond me to convert JS to C++, though perhaps that’s what it will come to. I just thought there would be an easy, portable way to do this, but I’ve been trying all day with no luck… – kinkersnick Mar 07 '22 at 23:17

0 Answers0