how to count the different dots seperately
3 views (last 30 days)
Show older comments
I have an image with red dots ,green dots and yellow dots. some dots are touching eachother. (2 pixels) and some dots are alone (1pixel) I would like to have a count of red dots, green dots, yellow dots and the number of touching dots. Can someone tell me how this can be achieved. I am attaching the image here.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165080/image.png)
Thank You
0 Comments
Answers (1)
Image Analyst
on 1 Jul 2014
Extract the color channels
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
Then threshold and label
redDots = redChannel > 100; % or whatever
[!, numberOfRedDots] = bwlabel(redDots);
greenDots = greenChannel > 100; % or whatever
[!, numberOfgreenDots] = bwlabel(greenDots);
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!