How detect spot white circle on image
1 次查看(过去 30 天)
显示 更早的评论
I would like detect spot white are like below image . Hope anyone help . Thanks!
采纳的回答
KSSV
2017-6-6
编辑:KSSV
2017-6-6
I = imread('Screen Shot 2017-06-06 at 3.54.58 PM.png') ;
im = imclearborder(im2bw(I));
im_fill = imfill(im, 'holes');
s = regionprops(im_fill, 'Area', 'PixelList');
[~,ind] = max([s.Area]);
pix = sub2ind(size(im), s(ind).PixelList(:,2), s(ind).PixelList(:,1));
out = zeros(size(im));
out(pix) = im(pix);
% imshow(out);
[y,x] = find(out) ;
idx = boundary(x,y) ;
% idx = convhull(x,y) ;
imshow(I)
hold on
plot(x(idx),y(idx),'r','linewidth',3)
Code taken from: https://in.mathworks.com/matlabcentral/answers/343337-how-to-remove-small-portion-in-an-image
If boundary doesn't work, use convexhull
更多回答(1 个)
Image Analyst
2017-6-6
KSSV's code finds the largest blob that is not touching the border, whereas you actually want roundish objects.
Like I said in your duplicate post, You could use my code for circularity. Or you could also look for Solidities close to 1, or get the BoundingBox and look for aspect ratios close to 1.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!