Finding circle in an image

2 views (last 30 days)
Damian Wierzbicki
Damian Wierzbicki on 19 Jul 2017
Answered: Image Analyst on 19 Jul 2017
Hi guys. I have an image ( attached ) and I'm trying to find the location of the centre of the hole ( circle ) that is apparent in that image. I've been using imfindcircles ( tried different sensitivities ) with no success, probably due to that light reflection ( ? ) that is visible in the hole. Can anyone propose how to resolve that issue ? Thank you.

Answers (1)

Image Analyst
Image Analyst on 19 Jul 2017
I'd try to zero out the bright stuff, then threshold and call regionprops() and compute the circularity. Here's a start:
mask = grayImage > 200;
grayImage(mask) = 0;
binaryImage = grayImage < 50; % or whatever works.
labeledImage = bwlabel(binaryImage);
props = regionprops(labeledImage, 'Area', 'Perimeter');
allAreas = [props.Area];
allPerims = [props.Perimeter];
circularities = allPerimeters .^ 2 ./ (4 * pi * allAreas);
roundBlobIndexes = find(circularities < 2);
roundBlobs = ismember(labeledImage, roundBlobIndexes);
imshow(roundBlobs);

Community Treasure Hunt

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

Start Hunting!