imfindcircles doesn't work
Ältere Kommentare anzeigen
The image looks normal with range from 0 to 4096:

[x,y] = size(AA1); % output x and y both 512
Obviously radius range is [x/4 x/2].
However, both of below:
[centers, radii, metric] = imfindcircles(AA1,[fix(x/4) fix(x/2)],'ObjectPolarity','bright')
[centers, radii, metric] = imfindcircles(AA1,[fix(x/4) fix(x/2)])
output:
centers = []
radii = []
metric = []
changed to [x/6 x/2] doesn't help.
Thank you for finding the issue!
3 Kommentare
Image Analyst
am 29 Jun. 2025
Are you trying to find the mask, which would be the overall circle, or circles inside the circular area? Please indicate what circles you expect to find. Obviously the overall mask could be found by thresholding:
maskBoundary = bwboundaries(AA1 > 0);
If you want circles within that, your data is too blurry and indistinct to find with imfindcircles. You'll have to use a different method to find whatever it is you expect to find in that blurry image.
Also, size() returns [rows, columns] and it's convention to have x be horizontal - the opposite of what you have. You have x as rows (vertical) and y as columns (horizontal dimension) which is the opposite of convention though in this case since they're both 512 it doesn't make any different. Nonetheless, to be less confusing, you should choose descriptive variable names, like
[rows, columns, numberOfColorChannels] = size(grayImage);
John
am 29 Jun. 2025
Image Analyst
am 30 Jun. 2025
If you have any more questions, then attach your image and code to read it in with the paperclip icon after you read this:
Akzeptierte Antwort
Weitere Antworten (1)
Matt J
am 30 Jun. 2025
Verschoben: Image Analyst
am 4 Jul. 2025
I can't reproduce the problem you claim to have with a binarized disk. That case is pretty well-handled by imfindcircles:
n=300;
[x,y]=deal(1:n);
mask=hypot(x-mean(x),y'-mean(y))<=n/3;
[centers,radii]=imfindcircles(mask,[n/4,n/2])
imshow(mask,[])
viscircles(centers,radii);
Kategorien
Mehr zu Just for fun finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


