Largest connected component(circular)
조회 수: 1 (최근 30일)
이전 댓글 표시
I need an algorithm to detect the largest connected component which has circular shape in an image. I hope your kind help.
Thank you.
댓글 수: 0
채택된 답변
Sean de Wolski
2011년 5월 9일
Ibw = imfill(imread('coins.png')>100,'holes'); %example binary image
CC = bwconncomp(Ibw); %connected components
Objsz = cellfun(@numel,CC.PixelIdxList); %size of blobs
[garbage, ObjszOrder] = sort(Objsz,'descend'); %descended sorting
stats = regionprops(CC,'stuff you need to write');
for ii = 1:length(ObjszOrder)
if(iscircularenough(stats(ii)))
%object ii wins!
break
end
end
I've done most of the work for you here. You have to determine what criteria you want to use to test circularity and what you need to extract from regionprops for this. The most common measurement of circularity is perimeter to area. Use wikipedia or the explanation of 'regionprops:equivdiameter' for the correct equation.
추가 답변 (0개)
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!