How to detect the circle-ish shape in an image

조회 수: 2 (최근 30일)
Faraz
Faraz 2014년 7월 14일
댓글: Image Analyst 2014년 7월 16일
I have this image:
And I wanted to detect the circle shape from it. So simple enough I used regionprops and area
CC = im2bw(temp);
L = bwlabel(CC);
props = regionprops(L, 'Area');
idx = find( [props.Area] == max([props.Area]));
BW2 = ismember(L,idx);
The above produced image BW2 singled out the circle perfectly, but it does not work every time.
When I applied the same code to this image(which is another sample in my dataset):
It picked up not the circle but the big blob connected component in the middle. Which makes sense as it has the biggest area.
Judging by this I found that area is not the best option.
How can I single out the circle type shape in my images?
Thank you

채택된 답변

Image Analyst
Image Analyst 2014년 7월 14일
Compute the circularities:
labeledImage = bwlabel(binaryImage);
measurements = regionprops(labeledImage, 'Area', 'Perimeter');
allAreas = [measurements.Area];
allPerims = [measurements.Perimeter];
circularities = allPerims .^ 2 ./ (4*pi*allAreas);
Look at my Image Segmentation Tutorial to find out how to use ismember() to extract out round blobs. Round blobs will have a circularity less than about 2 or 3 or so.
  댓글 수: 4
Faraz
Faraz 2014년 7월 16일
Yes sorry that was a stupid typo. But circularities does not seem to solve this. It is also detecting small circles. I only want to single out the large circle ish shape.
For example from this:
..
I am given this with circularities < 2 (even with < 3 does not work) .. ..
..
Image Analyst
Image Analyst 2014년 7월 16일
You need to combine both criteria:
keeperIndexes = find(cicularities < 2 & allBlobAreas > 2000);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by