4 ms·
I feel like k-means in in Lab color space would lend itself well here too. Either by picking a large k that you then narrow down by picking the highest contrast
by mrmaddog 14y ago
I feel like k-means in in Lab color space would lend itself well here too. Either by picking a large k that you then narrow down by picking the highest contrast colors, or instead by running k-means multiple times with different k's until you get an error threshold that is tolerable and results that have a high enough contrast. K-means is also a pretty easy algorithm to understand/implement.
- joshu 14y agothat's what i was thinking, as well. of course the problem with k-means is figuring out the number of clusters...
- dhotson 14y agoWe haven't tried clustering yet, but I'm keen to. Correct me if I'm wrong, but by using clustering you might end up with colors that didn't actually occur in the original design right? In our case we wanted to make sure we found colors that the designer actually chose. I'll have to try this..
- isani 14y agoK-means clustering gives you a set of centroids which are the calculated means of each cluster. If you only want actually occurring colors, just look up the color closest to each centroid.
- drifkin 14y agoGoogle uses k-means clustering in Chrome on their new tab page (though they use RGB). The most visited section shows a color strip below each site, with a color chosen from the site's favicon. Here's the code: http://src.chromium.org/svn/trunk/src/ui/gfx/color_analysis.cc http://src.chromium.org/svn/trunk/src/ui/gfx/color_analysis....
- drifkin 14y agoIt turns out the header file actually has a pretty nice explanation of the algorithm: http://src.chromium.org/svn/trunk/src/ui/gfx/color_analysis.h http://src.chromium.org/svn/trunk/src/ui/gfx/color_analysis....
- mixonic 14y agoI am going to straight up lift that idea into a web app I've built. Providing users a hint more context about their content makes interfaces less bland and anonymous. Thanks for raising it!