Trying to figure out the roughness of a circle imfindcircles pol2cart, but not getting the results I expect

6 views (last 30 days)
Hi everyone
So this is maybe a simple question, but for some reason I'm not getting the answer I expect. I start of with an image that has circles in it. In my case, the circles are not perfect circles, and I want to get an idea of how rough te circles are. To do this, I have a 2 step process. Find the center of the circles by using imfindcircles. After I've figured out my centers, I then use pol2cart to figure out where the drop-off point in my circle for that particular theta is. Now, I say the circles are rough, but they are still supposed to be very circular, so when I run the following code, I expected to see a regular p[attern that only changes very mildy. However, this is not the case.
d = dir(directory(i) + "\\*.png");
d = arrayfun(@(x) x.folder + "\\" +, d);
I = (imread(d(1)));
[centers,radii,metric] = imfindcircles(I,[400 700],'Sensitivity',0.99);
%%figure out bottom to top
y = centers (:,2);
[B,k] = sort(y);
centers = centers(k,:);
radii = radii(k);
I = double(I);
%%for all centers, go through 360 degrees
for j = 1:size(centers,1)
xo = centers(j,1);
yo = centers(j,2);
xo = round(xo);
yo = round(yo);
for theta = 1:360
rho = 0:round(1.2*radii(j));
for r = 1:length(rho)
[x,y] = pol2cart(theta,rho(r));
x = round(x);
y = round(y);
line(r) = I(xo + x, yo + y);
line(r) = 0;
line = medfilt1(line);
hold on
I've plotted the first few thetas to show what I mean about the results not being what I expected.

Accepted Answer

Image Analyst
Image Analyst on 9 Feb 2023
What I'd do is to use bwboundaries to get the coordinates of the boundaries and then computer the MAD or RMS of the actual boundary from the fitted circle. Let me know if you can't figure it out and need code.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:

Sign in to comment.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!