Count elements on image
6 views (last 30 days)
Show older comments
Hi all,
I had two problems when I used the next code for counting circles on the attached images (erodedBW is the image input)
subplot(2, 2, 1);imshow(A);
fontSize = 20;
binaryImage = erodedBW(:,:,1) < 200;
title('Original', 'FontSize', fontSize);
subplot(2, 2, 2);imshow(A);
title('Binary Image with Centroids', 'FontSize', fontSize);
hold on;
format longg;
format compact;
measurements = regionprops(erodedBW, 'Centroid', 'Area');
numberOfCircles = length(measurements);
allAreas = [measurements.Area]
for k = 1 : numberOfCircles
centroid = [measurements(k).Centroid];
xCenter = centroid(1);
yCenter = centroid(2);
plot(xCenter, yCenter, 'b+');
[counts values] = hist(allAreas);
subplot(2, 2, 3);imshow(erodedBW);
title('Eroded', 'FontSize', fontSize);
message = sprintf('The number of circles is %d', numberOfCircles);
msgbox(message);
The first problem is that the algorithm counts a circle in the center. And the other is that counts more than one circle on the same element.

I need detect two elements (the two blobs)

I need detect two blobs on the left.
Thanks
0 Comments
Answers (0)
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!