# Detecting circles in noisy images with high intensity variations (must work for all cases)

1 view (last 30 days)
André on 29 Jul 2021
Commented: darova on 19 Aug 2021
Hello,
Im trying to create a pupil detector. Tue input images have the problem of being noisy and with many intensity variations, and therefore no thresholding algorithm is feasible to detect it. Im using the Canny edge detector instead (after histogram equalization).
The problem is that even this algorithm is not perfect finding circles. I find many situations where the circles are incomplete, or not fully closed.Therefore, I would like to connect all the edges of the circle.
Notice that simply conecting the nearest edges is not always the best option, because there are several other edges that may be near but not belong to the circle (the left image I present here is quite clean, but the right one is not so much). There is also the problem of specular reflection edges inside the pupil (not shown here).
I also tried to compute the euclidian distance to find the center, but as you can see from this example, the center is not always the highest euclidian distance as theres penty of larger distances, specially for small pupils. For example, euclidian distance might work with the right image, but probably not with the left one.
For me the only option is to try to compute the center and radius of curvature of each edge and then use it to fit a circle. Any suggestion of how I should do this?
This must be done in an efficient way and in real time. I also tried the Hough transform, but it didnt't work, even after using the euclidian distance method (it also seems too slow in Matlab).
Thank you darova on 29 Jul 2021
Is the circle the only figure of closed form?
A1 = im2bw(A0);
A2 = imdilate(A1,ones(10)); % close the circle
A3 = imerode(A2,ones(8)); % make it thin
[L,n] = bwlabel(~A3); % separate each region
data = regionprops(L,'Area'); % calculate area of each region
ar = cat(1,data.Area); % extract data
[~,ind] = sort(ar,'descend'); % sort area
mymap = rand(n,3);
imshow([L (L==ind(2))*ind(2)], mymap) ##### 2 CommentsShowHide 1 older comment
darova on 19 Aug 2021
Attach another images