How to convert the estimated radius of a circle to its actual range?

Viewed 143

I generate a random number between 1 and 2 as a radius for my circle. Then I plot my circle and saves it as a png. Also, several data points are generated both inside and outside the circle to make it noisy. Then I will use Hough Transform to estimate the radius for the circle but, the number which it returns is more than 100. Although they are the same circles(I plotted to make sure).

I have tried to use polyfit function to map these two numbers but, the estimated radius seems to be smaller than the real one in some examples. After mapping It returns the same number. For example, a random radius is 1.2 and Hough estimates it 110 however it seems that it should be near 1.(Because I plot it and it is clear that is it smaller). Also, for Hough Transform I am using this code https://www.mathworks.com/matlabcentral/fileexchange/35223-circle-detection-using-hough-transforms I tried the predefined Matlab function (imfindcircles) but it returns null for all my circles.

r1 = 1 + abs((1)*randn(1,1));  %radius of inner circle
r1 = abs(r1);
r2 = (1.2)*r1;   %radius of outercircle
k  =  500;      %number of random numbers 

% circle coordinate points 
t  = 0:2*pi/59:2*pi;
xv = cos(t)';
yv = sin(t)';

%%%%%%%%random points

xq = 2*randn(k,1)-1;
yq = 2*randn(k,1)-1;     %distribution 1
xq1 = 2*(rand(k,1))-1;   %distribution 2
yq1 = 2*(rand(k,1))-1;
in = inpolygon(xq1,yq1,r1*xv,r1*yv);    %number of points inside the geometry 
in1= inpolygon(xq,yq,r2*xv,r2*yv);      %points inside outer circle
in2 = xor(in,in1);                      %points between circle
in3= inpolygon(xq1,yq1,r2*xv,r2*yv);    %points inside outer circle
fig = figure(22);hold on;


% Random points
 plot(xq(in2),yq(in2),'bo','MarkerFaceColor','r','MarkerSize',5,'Marker','o','MarkerEdgeColor','none');
axis equal;
    plot(xq1(~in2),yq1(~in2),'bo','MarkerFaceColor','r','MarkerSize',5,'Marker','o','MarkerEdgeColor','none');
 axis equal;

img= getframe(fig);
figure;
 imshow(img.cdata)
 hold on;
   [r,c,rad] = circlefinder(img.cdata);
   [m I] = max(rad);
       %ploting the bigest estimated circle
    angle = 2*pi*randn(k,1);
    haffpointX = rad(I).*cos(angle)+ c(I);
    haffpointY = rad(I).*sin(angle)+ r(I);

   scatter(haffpointX,haffpointY,'g');
   axis equal

I expect that for different random circles with noisy data Hough Transform estimates its circle with the number between the range of 1 and 2 so, I can use its results.

Thank you in advance

0 Answers
Related