How to detect the circle-ish shape in an image
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Faraz
am 14 Jul. 2014
Kommentiert: Image Analyst
am 16 Jul. 2014
I have this image:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165666/image.jpeg)
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):
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165667/image.jpeg)
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
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 14 Jul. 2014
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 Kommentare
Image Analyst
am 16 Jul. 2014
You need to combine both criteria:
keeperIndexes = find(cicularities < 2 & allBlobAreas > 2000);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Data Workflows finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!