How do I detect a circle in an image?
    5 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
I have a sequence of images (that's why the code is in a loop) which I have taken of an oscillating bubble on a needle. the images are quite noisy so I first tried to reduce the grainy spots with moderate results. I have turned the image into a binary image and I am still not able to detect the white ring which would be the bubble. Does anyone have an idea how I could detect the center and the area of the bubbles. The bubbles are not always perfectly round, so I don't know if that poses a problem in detecting them in the images.I have attached an original image.
Essentially, I have implemented two methods for detecting the circle, however the first method which is in the main loop gives out garbage and the second method which is in the second for loop just doesn't detect the ring. 
for i=1:1
   imname=sprintf('B00%02d.png', i);% reading the sequence of names of the images
   image=imread((fullfile(path, imname)));
   ima=rgb2gray(image);%grayscayling images
   Kmedian = wiener2(ima,[2 2]);%adding filter
   im{i}= bwareaopen(imbinarize(Kmedian),10);% binary image and removing noise
   se = strel('disk',4);
   im{i} = imclose(im{i},se);%connecting the existig dots
   %imshow(im{i})
   clear image ima
  %%%%First method%%%%
[L,num] = bwlabeln(im{i},8) ;  % num gives you closed region 
m = regionprops(L) ;   % measurements of regions, gives centers of the regions
for j = 1:num
    c = m(j).Centroid ;
    imshow(im{i})
    hold on
    plot(c(1),c(2),'*r') ;
end
end
%%%%second method%%%%
 for i=1:1
    imshow(im{i})
    d = drawline
    pos = d.Position;
    diffPos = diff(pos);
    diameter = hypot(diffPos(1),diffPos(2))
    [centers,radii] = imfindcircles(ima,[800 950],'ObjectPolarity','bright', 'Sensitivity', 0.1)
    viscircles(centers, radii,'Color','b');
 end
0 comentarios
Respuestas (1)
  Pratheek Punchathody
    
 el 17 de Nov. de 2020
        For this specific use case, you can try out "active contour" based segmentation technique. The following documentation link has the description of the function and an example for the same : Activecontour 
Hope this helps 
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

