How to count number of circles of a gray scale image?
13 次查看(过去 30 天)
显示 更早的评论
I want to count number of circles of a gray scale image. I have attached the sample image. I just want to count the number of circle of that image and fill the gaps of that circle. What should i do??
0 个评论
采纳的回答
Image Analyst
2015-12-14
How many do you see? I see two circular black discs plus a bunch of other blobs that have irregular shapes, though some parts of their perimeters are circular.
See this link to split them apart, if you want to do that. http://www.mathworks.com/help/images/examples/marker-controlled-watershed-segmentation.html
Then you can count them with bwlabel();
[~, NumBlobs] = bwlabel(binaryImage);
If you want to, you can try imfindcircles. http://www.mathworks.com/matlabcentral/fileexchange/34365-circle-finder
Another way is to use regionprops() to compute the area and perimeter of the blobs and compute the circularity and keep only blobs that are sufficiently close to being circular.
I can't do it all for you but if you have questions, attach whatever code you have.
4 个评论
Fika Umami
2022-6-17
this post is quite old but ca
n i ask here??
im looking fora solution tom problem but i haven't found it yet
i tried to calculate the circle from the canny result but the results did not match my manualy calculation, the results were too many
this my code
edge_final = handles.edge1;
cla('reset')
imshow(edge_final)
[B,L] = bwboundaries(edge_final,'noholes');
stats = regionprops(L,'All');
bw2 = zeros(size(edge_final,1),size(edge_final,2));
for k = 1:length(B)
boundary = B{k};
delta_sq = diff(boundary).^2;
perimeter = stats(k).Perimeter;
area = stats(k).Area;
metric = 4*pi*area/perimeter^2;
bbox = stats(k).BoundingBox;
eccentricity = stats(k).Eccentricity;
MajorAxisLength = stats(k).MajorAxisLength;
MinorAxisLength = stats(k).MinorAxisLength;
d = MajorAxisLength/MinorAxisLength;
position = [boundary(1,2),boundary(1,1)];
if metric > 0.9
bw2(L==k) = 1;
[handles.D handles.Num_lingkaran]=bwlabel(bw2);
set(handles.text2,'string', handles.Num_lingkaran);
end
end
guidata(hObject, handles);
can you help me to o it?
Image Analyst
2022-6-17
I'd create your own post for this. Attach your own original input image.
Also explain exactly what "calculate the circle" means because that is very vague and there could be several possible answers for that depending on exactly what that means.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!