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

6 views (last 30 days)
Alexander Dumont on 9 Feb 2023
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 + "\\" + x.name, d);
%%figure out bottom to top
y = centers (:,2);
[B,k] = sort(y);
centers = centers(k,:);
subplot(1,3,i)
imshow(I);
I = double(I);
figure
%%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
for r = 1:length(rho)
try
[x,y] = pol2cart(theta,rho(r));
x = round(x);
y = round(y);
line(r) = I(xo + x, yo + y);
catch
line(r) = 0;
end
end
line = medfilt1(line);
hold on
plot(line)
end
end
I've plotted the first few thetas to show what I mean about the results not being what I expected. 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:
Alexander Dumont on 9 Feb 2023
This helps a lot thank you!

### Categories

Find more on Object Analysis in Help Center and File Exchange

R2022b

### Community Treasure Hunt

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

Start Hunting!