how to find an eclipse in an image

3 次查看(过去 30 天)
i'm trying to find the eclipse in an image
  1. 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,

回答(1 个)

Shreeya
Shreeya 2024-2-20
"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:

类别

Help CenterFile Exchange 中查找有关 Image Processing and Computer Vision 的更多信息

产品


版本

R2016a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by