How can I count the colors used in an image and sort by frequency?
May 15, 2004 10:52 PM Subscribe
I'm trying to find the counts of various colors in an image, preferrably in order of frequency of use. I'd like to select a photo and BAM! see a list of all the colors used, in order. Can anyone recommend any software or techniques for doing this?
[snark mode on]
Here's my recommendation: learn to use google. Once again, you've posted a question you could have damn well answered without effort.
Google "count number colors image download." Pretty obvious keywords. Why what's that halfway down the page? It's your answer!
"efg's Palettes and Colors -- ShowImage Lab Report... with [Foley96, pp. 590-593].); Added a count of the number of unique RGB combinations (colors) in an image. The January 2000 ... www.efg2.com/Lab/Graphics/Colors/ShowImage.htm - 14k - Cached - Similar pages"
posted by five fresh fish at 11:40 AM on May 16, 2004
Here's my recommendation: learn to use google. Once again, you've posted a question you could have damn well answered without effort.
Google "count number colors image download." Pretty obvious keywords. Why what's that halfway down the page? It's your answer!
"efg's Palettes and Colors -- ShowImage Lab Report... with [Foley96, pp. 590-593].); Added a count of the number of unique RGB combinations (colors) in an image. The January 2000 ... www.efg2.com/Lab/Graphics/Colors/ShowImage.htm - 14k - Cached - Similar pages"
posted by five fresh fish at 11:40 AM on May 16, 2004
[snark mode maintained]
Or you might RTFM. I'll bet dimes to doughnuts that your image editing application (photoshop, corel painter, draw, paintshop, whatever) or image viewing application (ie. ifranview) would report the color count.
grrr. annoying question.
[snark off]
posted by five fresh fish at 11:43 AM on May 16, 2004
Or you might RTFM. I'll bet dimes to doughnuts that your image editing application (photoshop, corel painter, draw, paintshop, whatever) or image viewing application (ie. ifranview) would report the color count.
grrr. annoying question.
[snark off]
posted by five fresh fish at 11:43 AM on May 16, 2004
Jeez, enough already, fff.
Histogram. I think that's the magic keyword you want to add to fff's oh-so-generous advice.
posted by NortonDC at 12:05 PM on May 16, 2004
Histogram. I think that's the magic keyword you want to add to fff's oh-so-generous advice.
posted by NortonDC at 12:05 PM on May 16, 2004
I don't have personal experience with it, but imagemagick is a free download/open source application, and the information on this page leads me to believe it will do just what you want.
five fresh fish, I think you need to calm down.
posted by taz at 12:17 PM on May 16, 2004
five fresh fish, I think you need to calm down.
posted by taz at 12:17 PM on May 16, 2004
If you use photoshop's save-for-web feature and choose either png8 or gif formats, you can export the color table. Gifs are limited to 256 colors, which obviously leaves out several million if you're source image is say, a 32bit 4mega pixel image, in which case you could easily have far more than 256 shades of green. It is useful for finding the most prominent colors, though. Especially if you set it to perceptual.
posted by Grod at 12:47 PM on May 16, 2004
posted by Grod at 12:47 PM on May 16, 2004
note: Ask MetaFilter is as useful as you make it. Please limit comments to answers or help in finding an answer. Wisecracks don't help people find answers. Thanks.
ask.snarkyfilter.com, then? /me gives the not-so-fresh five fish a magic happy-fun brownie and a hug and a big wad of oobleck to play with.
"Histogram" is indeed the magic word for this. I can't remember if photoshop actually will index the counts in a human readable format or not, though. I know the histogram function will at least show a rather compressed graph of the values.
One use for histograms is to check to see if the colors in a given image are "out of gamut", or out of the acceptable range of values for a given color output device, be it color printer or color seperation engine or film output device for halftone plates and such.
posted by loquacious at 3:40 PM on May 16, 2004
ask.snarkyfilter.com, then? /me gives the not-so-fresh five fish a magic happy-fun brownie and a hug and a big wad of oobleck to play with.
"Histogram" is indeed the magic word for this. I can't remember if photoshop actually will index the counts in a human readable format or not, though. I know the histogram function will at least show a rather compressed graph of the values.
One use for histograms is to check to see if the colors in a given image are "out of gamut", or out of the acceptable range of values for a given color output device, be it color printer or color seperation engine or film output device for halftone plates and such.
posted by loquacious at 3:40 PM on May 16, 2004
A histogram is not going to be helpful. They are 1 dimensional, that is, they are pretty much only going to show you the overall brightness content of an image, or you can look at the intensity of red, green, blue, etc one at a time.
I am not sure if there is anything that does exactly what you want. It would not be difficult to write a program to do that kind of thing, if you're so inclined, but not trivial for the non-programmer.
If you're interested in some methods for writing programs to do this, let me know, I can probably lead you in the right direction. I've done image manipulation programming in perl, tcl, java and C, so I know what you want is possible in any of those.
posted by RustyBrooks at 8:48 AM on May 17, 2004
I am not sure if there is anything that does exactly what you want. It would not be difficult to write a program to do that kind of thing, if you're so inclined, but not trivial for the non-programmer.
If you're interested in some methods for writing programs to do this, let me know, I can probably lead you in the right direction. I've done image manipulation programming in perl, tcl, java and C, so I know what you want is possible in any of those.
posted by RustyBrooks at 8:48 AM on May 17, 2004
The real problem is that in most images, there are going to be thousands if not millions of colors, many of them indistinguishable to the eye but nonetheless distinct to the computer. Getting a sorted list of one occurrence each of five hundred different reds is not going to be very helpful for anything useful. You're going to need an algorithm to group the colors together in some way, and this is non-trivial. Algorithms like those used in Photoshop's color reduction (converting an image to 8-bit) focus on picking the most "important" colors (where "important" is defined in various ways depending on which method you choose) to maximize the fidelity of the color-reduced image. Your goal is probably rather different.
posted by kindall at 10:06 AM on May 17, 2004
posted by kindall at 10:06 AM on May 17, 2004
I'm not sure what you mean RustyBrooks - histograms are obviously two-dimensional (with combined or split channels - or you can try to make it 4-D with all 3 channels, though that wouldn't make much sense).
Paint Shop Pro has the following features: Image->Count image colors; and while you can't make it output a list of color values in text in order of use without writing a script, it has extended histogram and other color editing capabilities under the Adjust menu. Photoshop is banished from my computer, so can't help you there.
posted by azazello at 11:45 AM on May 17, 2004
Paint Shop Pro has the following features: Image->Count image colors; and while you can't make it output a list of color values in text in order of use without writing a script, it has extended histogram and other color editing capabilities under the Adjust menu. Photoshop is banished from my computer, so can't help you there.
posted by azazello at 11:45 AM on May 17, 2004
I would be very interested in oissubke's resolution, so, if possible. let us know, k, oissubke?
posted by taz at 5:22 AM on May 18, 2004
posted by taz at 5:22 AM on May 18, 2004
This thread is closed to new comments.
posted by fvw at 1:16 AM on May 16, 2004