how to find an eclipse in an image
2 views (last 30 days)
Show older comments
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 Comments
Answers (1)
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:
0 Comments
See Also
Categories
Find more on Image Segmentation and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!