Count elements on image

6 次查看(过去 30 天)
Matías
Matías 2015-9-15
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 个)

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by