Largest connected component(circular)

2 ビュー (過去 30 日間)
nayomi ranamuka
nayomi ranamuka 2011 年 5 月 9 日
I need an algorithm to detect the largest connected component which has circular shape in an image. I hope your kind help.
Thank you.

採用された回答

Sean de Wolski
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.
  1 件のコメント
nayomi ranamuka
nayomi ranamuka 2011 年 5 月 11 日
metric = 4*pi*area/perimeter^2.
This metric is equal to one only for a circle and it is less than one for any other shape. So I used this property to determine whether a component of image is circular or not. Thanks for your help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Image Processing Toolbox についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by