"regionprops" function in MATLAB can be used for detecting eclipses. You can check the eccentricity of the connected component and then classify it as an eclipse/circle/line etc depending on your use case. Refer to the link below:
how to find an eclipse in an image
1 次查看(过去 30 天)
显示 更早的评论
i'm trying to find the eclipse in an image
- i first use filter over the image
function [im_new]=getfilter(im)
imm1=imgaussfilt(im,10);
imm2=medfilt2(imm1,[5,5]);
imm3=imresize(imm2,0.25);
imm4=imresize(imm3,4);
im_new= imm4;
end
2. then i try to find the eclipse but for some reason the algorithm is failing.
function[s,Thr]=findeclipse(im,itrun)
counts=hist(im(:),0:255);
Thr=otsuthresh(counts);
imm5=im2bw(im,Thr);
diskrange=1;
while 1 %iterating filtering util get the one circle
SE = strel('disk',diskrange,0);
BW2 = imerode(imm5,SE);
BW3 = imdilate(BW2,SE);
s = regionprops(BW3,{...
'Centroid',...
'MajorAxisLength',...
'MinorAxisLength',...
'Orientation'});
if (length(s)>=1)&&(length(s)<2)
break
elseif length(s)==0
error('Could not find the pattern')
break
end
diskrange= diskrange+1;
end
end
need some assist fixing the code for the attach image
thanks,
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Segmentation and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!