how to find an eclipse in an image

2 views (last 30 days)
Nir Shwartz
Nir Shwartz on 5 Jun 2023
Answered: Shreeya on 20 Feb 2024
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,

Answers (1)

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

Products


Release

R2016a

Community Treasure Hunt

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

Start Hunting!