Program to analyze image
May 25, 2008 9:20 PM Subscribe
Looking for a program that will take an image as the input and gives back a chart/graph/number with the amount of colours as the output.
Is there such software that will do this? Need a program as such for web design so that the dominate colour of an image can be used as the background-color.
Is there such software that will do this? Need a program as such for web design so that the dominate colour of an image can be used as the background-color.
Best answer: The thing you're apparently looking for is a Color Histogram, and this PHP script says it will create one. I haven't tested it.
posted by AmbroseChapel at 9:53 PM on May 25, 2008
posted by AmbroseChapel at 9:53 PM on May 25, 2008
If you're on a Linux system with ImageMagick installed (fairly typical), you can run "identify -verbose foo.jpg" and get a whole bunch of info. One of the bits of information is the number of colors.
posted by knave at 9:53 PM on May 25, 2008
posted by knave at 9:53 PM on May 25, 2008
Oh, I see you're looking for the dominant color, not the color count. In that case, the command I wrote still works, but you'll need to look at the histogram it outputs. You can scroll through it and find the value with the highest number of appearances, i.e.:
posted by knave at 9:55 PM on May 25, 2008
Histogram: 16: (254,253,255) #FEFDFF 40: (255,253,255) #FFFDFF 1: (255,252,255) #FFFCFF 13: (255,254,253) #FFFEFD 963: (255,255,253) #FFFFFD 42: (255,254,252) #FFFEFC 141: (254,254,252) #FEFEFC 149: (254,255,253) #FEFFFD 18532: (255,255,255) white 634: (254,255,255) #FEFFFF 685: (255,254,255) #FFFEFFWhite is the dominant color in that image, with 18,532 appearances.
posted by knave at 9:55 PM on May 25, 2008
Best answer: If you're working with a rich RGB image, the individual color that owns the most pixels may not be the "dominant color" from the point of view of the human eye. The "dominant color" might be a range of colors which are closely related, which collectively own the largest number of pixels.
In photographs, large areas which we think of as "a single color" often are not. A good example of that would be an outdoor shot which includes a large section of blue sky. It may not look it, but nearly always sky shades gradually from one end to the other -- and based on a pure pixel count, no single shade of blue might be the plurality color, even though most of the image is sky.
I would say the best way to figure that out would be to use an image editor to reduce the number of bitplanes, from 24 down to maybe 4. Use something like octree, and then pick the color that clearly dominates the image.
(One problem here is that it isn't exactly clear just how you'd define "dominant color" when it comes to a 24-bit image.)
posted by Class Goat at 10:36 PM on May 25, 2008
In photographs, large areas which we think of as "a single color" often are not. A good example of that would be an outdoor shot which includes a large section of blue sky. It may not look it, but nearly always sky shades gradually from one end to the other -- and based on a pure pixel count, no single shade of blue might be the plurality color, even though most of the image is sky.
I would say the best way to figure that out would be to use an image editor to reduce the number of bitplanes, from 24 down to maybe 4. Use something like octree, and then pick the color that clearly dominates the image.
(One problem here is that it isn't exactly clear just how you'd define "dominant color" when it comes to a 24-bit image.)
posted by Class Goat at 10:36 PM on May 25, 2008
You might already have a tool that does this. In Photoshop or the GIMP, you can convert an image from full RGB to indexed color. This is similar to what Class Goat was talking about with reducing the number of bitplanes.
Essentially, what you want to do is a color reduction, merging colors into a small number of bins. Now, I'm not as sure about the capabilities of Photoshop, but in the GIMP you can change the color mode to indexed color, and tell it to chose an optimal palette. If you tell it to make a palette of only a few colors (say 4-12), it will try to judge what colors are the most applicable to a wide range of pixels in the image. I'm not sure of the exact algorithm, but it should give you a short list of colors that you can use.
Now, if you want to make a program to automate this sort of thing, my recommendation would be to change to HSV color space, median filter the image and take a quantized histogram. But the optimized GIF palette feature will work in a pinch.
posted by demiurge at 10:16 AM on May 26, 2008
Essentially, what you want to do is a color reduction, merging colors into a small number of bins. Now, I'm not as sure about the capabilities of Photoshop, but in the GIMP you can change the color mode to indexed color, and tell it to chose an optimal palette. If you tell it to make a palette of only a few colors (say 4-12), it will try to judge what colors are the most applicable to a wide range of pixels in the image. I'm not sure of the exact algorithm, but it should give you a short list of colors that you can use.
Now, if you want to make a program to automate this sort of thing, my recommendation would be to change to HSV color space, median filter the image and take a quantized histogram. But the optimized GIF palette feature will work in a pinch.
posted by demiurge at 10:16 AM on May 26, 2008
Response by poster: That Whatsitscolor site rocks, thanks!
posted by querty at 6:26 PM on May 26, 2008
posted by querty at 6:26 PM on May 26, 2008
This thread is closed to new comments.
On Paint Shop Pro (version 8.1) under the "Image" menu, one of the choices is "count image colors". I think if you look around, there will be something like that in any modern image editor.
posted by Class Goat at 9:46 PM on May 25, 2008