Finding a circle in an image
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Rishabh Sharma
am 23 Mai 2018
Kommentiert: Rishabh Sharma
am 24 Mai 2018
Hello
I am trying to find a circle in the attached image

Can someone help me, please?
0 Kommentare
Akzeptierte Antwort
KSSV
am 24 Mai 2018
How about this approach?
I = imread('image.png') ;
% crop the image to remove white borders around
I = imcrop(I) ;
I1 = rgb2gray(I) ;
[y,x] = find(I1) ;
%%get circle data
C = size(I1)./2 ; % center of circle
d = pdist2(C,[x y]) ;
nbins = 10 ;
[N,edges,bin] = histcounts(d,nbins) ;
figure(1)
imshow(I)
hold on
for i = 1:nbins
plot((x(bin==i)),y(bin==i),'.','color',rand(1,3)) ;
end
%
%%Circle's radii and center
Circ = cell(nbins,1) ;
for i = 1:nbins
[xc1,yc1,R] = circfit(x(bin==i),y(bin==i)) ;
Circ{i} = [xc1 yc1 R] ;
end
figure(2)
imshow(I)
hold on
th = linspace(0,2*pi) ;
for i = 1:nbins
xc = Circ{i}(1)+Circ{i}(3)*cos(th) ;
yc = Circ{i}(2)+Circ{i}(3)*sin(th) ;
plot(xc,yc,'color',rand(1,3),'linewidth',3) ;
end
Circ is cell, which centers and Radii of circles. You can download the function circfit from this link: http://matlab.wikia.com/wiki/FAQ#How_can_I_fit_a_circle_to_a_set_of_XY_data.3F
To get more information, refer this link: https://stackoverflow.com/questions/44375835/find-the-circle-on-the-experimental-image-matlab
Weitere Antworten (1)
Image Analyst
am 24 Mai 2018
Another approach is to use dbscan https://en.wikipedia.org/wiki/DBSCAN to find the dividing line and then use the faq http://matlab.wikia.com/wiki/FAQ#How_can_I_fit_a_circle_to_a_set_of_XY_data.3F to fit the dividing line to a circle.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!