I haven't been to York for ages....
Back on topic. This is almost what I'm looking for. I found this class: http://www.phpclasses.org/browse/package/3370.html
, which extracts the colours from an image as hex values, in descending order of frequency.
What I want to do is this;
- find the most dominant colours in an image
- maintain a finite list of colours in the database, that people can search against (probably around 15)
So as I see it, there are several things I need to do;
(I hope the following is relatively coherent - I'm just writing down what's going on in my head!!)
1. from the list extracted, work out which ones are dominant / frequent enough to warrant being stored against the image
2. given a search colour from a limited set, work out which ones are close enough to provide a match
Now presumably, from the number of pixels in the image and the frequency of a particular colour, I can work out a percentage, then skim off the most dominant colours accordingly. Question is, what on earth should the cut-off point be? Should it be a pre-determined threshold (e.g. 25%)? Should I simply take the x (e.g. 3,4) most frequent colours?
Then of course, I need to either:
- only store the colours that provide a reasonable match to one of my searchable colours, or
- only flag a match when a colour stored against an image is close enough to the colour being searched for
It's starting to sound like I need to come up with some pre-determined, hard-coded values; e.g., a colour is relevant if it comprises more than 25% of an image, and a colour is a match if ABS(".$r."-rVal)+ABS(".$g."-gVal)+ABS(".$b."-bVal) is less than delta.
Anyone got any thoughts as to how I do this, or indeed how I go about choosing these values?