How to count the number of colored objects in a picture?

9 次查看(过去 30 天)
Hi Everyone I am just starting image processing with matlab, I need to find how many colored pins in the picture attached and how many of each color and then find and count individual colors, then detect the white and transparent pins can someone help please and keep in mind I never did any image processing before what so ever.
  2 个评论
dusi jayasree
dusi jayasree 2017-8-28
i m a newbie..and wanted to know if we can count the colors in as image directly by any process or count the colors present in image by segmentation....is it possible to count colors after an image segmentation..???plz help me wit th is question
Image Analyst
Image Analyst 2017-8-28
编辑:Image Analyst 2017-8-28
I'd probably convert to HSV color space and threshold on saturation. Then I'd convert to lab colorspace with rgb2lab() and get the lab mean for each blob (pushpin). Any blobs that are within a certain distance (Delta E color difference) of each other, I'd consider them to be the same color pushpin. Then count the number of clusters you have after this merging operation. This should work for most colored pushpins, though the white and clear ones will be problematic and might have to be detected by a different algorithm.

请先登录,再进行评论。

采纳的回答

Carl
Carl 2017-2-6
编辑:Carl 2017-2-6
It looks like you'd like to perform some standard image segmentation. See the following page for an example on doing Color-based Segmentation:
https://www.mathworks.com/help/images/examples/color-based-segmentation-using-k-means-clustering.html?prodcode=IP&language=en
You should also take a look at the following tutorial on image segmentation:
In general, you could convert your image to a L*a*b* colorspace, classify each color with clustering, label your original image, and then count each component or manipulate your image as necessary.

更多回答(1 个)

Image Analyst
Image Analyst 2017-2-6
See my Color segmentation demos in my File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
As far as determining how many colors there are you'll have to use some unsupervised clustering methods in the Statistics and Machine Learning Toolbox. Since you don't know how many colors in advance, you can't use easy methods like kmeans or k-nearest neighbor. See http://www.mathworks.com/help/stats/cluster-analysis.html At one extreme, you could consider that every pixel in the image is a different color, so you probably have literally thousands of unique colors, but you don't want that so you have to do cluster analysis.
  1 个评论
NASADUDE
NASADUDE 2017-2-7
Hi Image Analyst I am trying all this but again I am very new and this is way over my head, anyway I can have some direct contact to you for questions ?

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by