MATLAB Answers

Amit
0

listing and counting all colors in an image

Asked by Amit
on 17 Jun 2016
Latest activity Commented on by Image Analyst
on 26 Jun 2016
Hello all:
I am a matlab user, but no great experience with image analysis. Could anyone be kind to shed light on my current problem:
I have small icon sized images, on which I want to run a simple code to list and count pixels of all the colors present.
Ideal output will be a n-by-2 array, the first column can be the color code, and the second could be the number of pixels with that color, as found in the image. Sum of column two thereby be the total pixels in the image.
Apologies for sounding like I am dumping my problem on the forum. Any initiaition (or full code, smile) will be much appreciated.
Thanks in deed and regards.

  0 Comments

Sign in to comment.

1 Answer

Answer by Image Analyst
on 17 Jun 2016

See attached code.

  2 Comments

Thank you Image Analyst, this is excellent and generous.
I have now collected all the sample image signatures as img_sign = [unique_colors color_counts]; (for each image).
Each image, though pretty quite similar in colors to the eye, has different number of unique colors, between 20 and 30.
So I have a unique_colors-by-4 signature of each image.
Wondering what may be the best way to organise data... leave it spread over 60 variables that I have corresponding to samples, or somehow create one big one (but different number of rows, owing to unique colors being different is a problem).
Secondly, what is the best way to compare the input to all of the 60 signatures, in a 'nearest', or 'heuristic' way, rather than exact.
These are my current challenges, as I moved ahead making use of your file.
Best regards.
Not really sure. Maybe check the CBIR literature on how they compare colors. A guess would be to make the histograms with not too many bins, like 16 or so. Then compare the percentage in each bin for the different images. Of course it will take more than 1 number to accurately describe how the colors differ in the two images.
You haven't said what you want to do though, and that lack of context makes it hard to guess. All you've done is to ask how to do some small steps in your algorithm but I don't know what the overall goal is, and if the small steps you have asked for are indeed the best approach to achieve the overall goal.

Sign in to comment.