Matlab imfindcircles shows weird behaviour when defining radius

1 Ansicht (letzte 30 Tage)
Urs Hofmann
Urs Hofmann am 7 Okt. 2020
Beantwortet: Shashank Gupta am 13 Okt. 2020
If I run the below script, the first circle finding algorithm finds the exact centerpoint adn radius, the second one does not detect the circle even when specifying the exact radius determined by the first circle finding algorithm, why?
nX = 1200;
nY = 1000;
xCenter = 300;
yCenter = 400;
radCirc = 20;
radRange = [5, 50];
xVec = (1:nX) - xCenter;
yVec = (1:nY) - yCenter;
xVec2 = xVec.^2;
yVec2 = yVec.^2;
radMat = sqrt(xVec2' + yVec2);
radMat01 = (radMat < radCirc);
radMat01 = double(radMat01) + 0.1 * rand(nX, nY);
imagesc(radMat01);
axis image;
[centers, radius] = imfindcircles(radMat01, radRange, ...
'ObjectPolarity', 'bright');
[centersExact, radiusNew] = imfindcircles(radMat01, radius, ...
'ObjectPolarity', 'bright');

Antworten (1)

Shashank Gupta
Shashank Gupta am 13 Okt. 2020
The algorithm itself is little bit tricky when we pass the approximate value for radius. I have a workaround for such scenerios, you may need to increase the sensitivity when you pass the approximate radius in the function. Although it does increases the chance of getting false positive. But it is the better way to get the centers and radius.
Try out this.
[centersExact, radiusNew] = imfindcircles(radMat01, radius, ...
'ObjectPolarity', 'bright','Sensitivity',0.99);
There must be other ways to get what you intent, but as of now I can think of this much only. If I find something interesting, I will share with you.
Cheers

Community Treasure Hunt

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

Start Hunting!

Translated by