Ibw = imfill(imread('coins.png')>100,'holes');
CC = bwconncomp(Ibw);
Objsz = cellfun(@numel,CC.PixelIdxList);
[garbage, ObjszOrder] = sort(Objsz,'descend');
stats = regionprops(CC,'stuff you need to write');
for ii = 1:length(ObjszOrder)
if(iscircularenough(stats(ii)))
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.
Best Answer