how to count the different dots seperately

5 views (last 30 days)
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.
Thank You

Answers (1)

Image Analyst
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);

Community Treasure Hunt

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

Start Hunting!