Find the most colourful image in a collection of images
Given a set of images what would be a way to rate them in order of which ones have the most complete coverage of the full colour spectrum?
UPDATE I've posted a sister questi开发者_如何学编程on which is an abstraction of one approach at "Most “thorough” distribution of points around a circle".
Imagine pixels as a set of 3D points in an RGB space. Rate the images by the volume of the 3d convex hull of their pixels.
Recommend converting the image from RGB values into HSV values.
Then the more discrete Hues the image has, the more colourful it can be considered.
For performance, you you can probably just take a subsample of the image, and / or reduce the number of Hue 'silos' or quanta.
Wiki is your friend
Edit 'Evenness':
Well, I guess you could use standard deviation approach to this by assuming that the ideal 'mean' would be an 'even' distribution of pixels across the Hue bins (i.e. mean = Total #Pixels divided by Total number of discrete Hue bins). Standard deviation would then be the square of the difference between the actual count and this mean. There are some caveats with this approach, as the squaring would heavily penalise any Hue bins with very low or very high counts (you might want to 'cap' the histogram range). You would also need to standardise the number of pixels (for counting) and the number of Hue bins across images to normalise the comparisons.
Another issue is that for a high number of Hue bins, that equal weighting is given to all hues, irrespective of the 'distance' of light wavelength between them (e.g. an image with just lots of different blue hues would count equally to an image with a few discrete shades of red green and blue - this is where volume approaches mentioned by other posters may be preferable.
run a histogram per channel and as Nicolas said rate them.
Edit:
Well the histogram will provide you with discrete values and the frequency.
You need to consider the discrete values e.g. if equal to 0 fq that means your image has no info on that channel and value. You can't directly multiply the value by the fq because that will mess the calculation for rating, since e.g. a whole black image can have a single discrete value with a very high fq.
so you need to consider the most colorful image as the less containing zero fq discrete values.
If by "complete coverage of the full colour spectrum" you mean having every discrete colour value possible in a given colorspace at least once, then you could just count all the unique colours in each image and the one with the highest value could be called the most colourful.
If, by spectrum, you mean number of hues, then you could convert each pixel's colour to HSV or HSL, tallying the number of unique hue values an image has, and again consider the one with the highest number of them the most colourful.
If, by complete, you mean something like in your other question about points around a circle, I think it might be useful to define some sort of linear density metric -- although I'm not exactly how best to apply to the data at hand...or even if that's what you mean.
精彩评论