how to find an eclipse in an image

2 vues (au cours des 30 derniers jours)
Nir Shwartz
Nir Shwartz le 5 Juin 2023
Réponse apportée : Shreeya le 20 Fév 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,

Réponses (1)

Shreeya
Shreeya le 20 Fév 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:

Catégories

En savoir plus sur Image Segmentation and Analysis dans Help Center et File Exchange

Produits


Version

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by