listing and counting all colors in an image

조회 수: 1 (최근 30일)
Amit
Amit 2016년 6월 17일
댓글: Image Analyst 2016년 6월 26일
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.

답변 (1개)

Image Analyst
Image Analyst 2016년 6월 17일
See attached code.
  댓글 수: 2
Amit
Amit 2016년 6월 18일
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.
Image Analyst
Image Analyst 2016년 6월 26일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by