2

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 question which is an abstraction of one approach at "Most “thorough” distribution of points around a circle".

Community
  • 1
  • 1
hippietrail
  • 15,848
  • 18
  • 99
  • 158

4 Answers4

2

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.

Nicolas Repiquet
  • 9,097
  • 2
  • 31
  • 53
  • 2
    This approach would weight colours occuring only in a single pixel the same as half the image being the same colour. Perhaps I should reword to "most complete and even"? – hippietrail Jan 10 '11 at 07:44
  • Ok, so maybe you can find the mean R, G and B value of your set of pixel. Then, for each pixel, you compute the the R, G and B distance from mean value and add it to an R, G, and B accumulator. Divide accumulators by the number of pixels, and rate the image by the volume of the RGB cube. – Nicolas Repiquet Jan 10 '11 at 08:00
1

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.

StuartLC
  • 104,537
  • 17
  • 209
  • 285
  • doesn't matter the color space of the image, because the saturation and value channels are part of the whole spectrum. The subsample is a great idea. – Eric Fortis Jan 10 '11 at 07:44
  • I was thinking something that sought the most even distribution of values for H in HSV space, but wasn't sure how to measure "most even". – hippietrail Jan 10 '11 at 07:50
0

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.

Eric Fortis
  • 16,372
  • 6
  • 41
  • 62
0

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.

martineau
  • 119,623
  • 25
  • 170
  • 301