MATLAB: How to count the number of colored objects in a picture

color segmentationcolored objectsImage Processing ToolboxStatistics and Machine Learning Toolbox

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.

Best Answer

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.
Related Question