I have an image that looks like the one below:
I'm trying to find the radius (or diameter) of the circle.
I have tried using circular Hough transform (via matlab's imfindcircles(bw,[rmin rmax],'ObjectPolarity','bright')
) , and by fitting to a circle or an ellipse (home made function that works pretty well for less noisy data, see below).
I've also tried some image processing to get a clearer circle, for example, see below:
se = strel('disk', 2);
bw = imdilate(bw, se);
bw = bwareaopen(bw,100000);
bw = edge(bw);
However, when I feed the processed image to either techniques (Hough and circle\ellipse fitting) neither of them manage to detect the circle in a decent manner.
Here's a code snippet of the circle finder I wrote (matlab) [row col]=find(bw); contour = bwtraceboundary(bw, row(1), col(1)], 'N', connectivity, num_points);
x = contour(:,2);
y = contour(:,1);
% solve for parameters a, b, and c in the least-squares sense by
% using the backslash operator
abc = [x y ones(length(x),1)] \ -(x.^2+y.^2);
a = abc(1); b = abc(2); c = abc(3);
% calculate the location of the center and the radius
xc = -a/2;
yc = -b/2;
radius = sqrt((xc^2+yc^2)-c);
Alternative approaches will be appreciated...