So I'm working on a way to extract dominant colors as perceived by humans from an image.
As an example, here's a photo: https://500px.com/photo/63897015/looking-out-for-her-kittens-by-daniel-paulsson
Most humans would think the 'dominant' color is that piercing azure of the eyes. Using standard quantization, however, that blue disappears completely when you drop below 16 colors or so. The eyes only take up 0.2% of the canvas, so going for the average doesn't work at all.
Project Details: I'm building a Rails app that will accept an uploaded photo or a specific color, and will return a bunch of other photos with similar dominant colors. The tool will be used by designers to find stock photography that matches their pre-existing color scheme. There are other cool ideas I have, too, if I can get the technical bit sorted out.
Current Research: I've spent the last 24 hours reading all about this stuff. Of all the services I've tried, TinEye is the only one that does it properly, but they're closed source. I can't provide more than 1 link, but you can google 'TinEye Color' to find it.
Tools Used: I'm using ImageMagick to do the image conversion and histogram generation.
Desired Result: When given that photo, I'd like to create a palette of 5-6 colors, with that saturated azure being one of them.
Current Method: The way I'm doing it now is I reduce it to 32 or 64 colors, and look for saturation/hue outliers. If the standard deviation is low and the outlier is significantly far away, I'll add it to the palette. Then I'll further reduce the photo to 4 colors and combine them for a 5-6 color palette.
My Question: My problem is with ImageMagick's quantization algorithm. I don't want to take the average of the colors, I want to group them by like colors and take the median, favoring saturated colors. When I reduce the cat picture to 32 colors, the eyes get turned into a desaturated grey.
So I'm asking you guys if you know of any algorithm or color principle that will let me find colors that stand out from an image, without blurring them together. I want a color that is actually in the image, not the blurred mean of 4-5 colors combined.
In a more general sense, TinEye has done a perfect job, and I'd like to figure out how they've done it.