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??
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/152608/image.bmp)
댓글 수: 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);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1035240/image.png)
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!