How to remove some edges after applying edge detection?
Asked Answered
R

2

5

I need to find the iris edges, the input images that I use is not a fully rounded iris, sometimes it might be covered by the eyelid. I found a summary of a journal article to find the iris even its covered by the eyelid. However, I stuck in one of the steps. Again, its because only a summary and I can't find the full text of that article.

Here's where I'm stuck, I have an image and its already implied by the Vertical Sobel Edge Detection. I have an image input, here's the picture :

Input Image

And this is the picture after applying the vertical edge detection :

enter image description here

I need to remove all the edges except the edge of the iris (red edge).

enter image description here

My expected result is should be like this :

enter image description here

Note : Some images might only have left or right edges of the pupil like the image above, but some images might have left and right edges for the pupil.

In my opinion, there's two way to get the edges.

  1. Remove the horizontal edges since the pupil edges is kinda vertical. But i don't know how to remove the horizontal edges, and its not really horizontal lines, its curvy horizontal lines.

  2. Find the longest edges in the picture (I also dont know what is the algorithm to find the longest edges).

Which one is the correct way to solve my problem? or not both options above?

If you know the method to find the not fully rounded objects especially for the iris, please tell me, it makes my project easier.

Renaissance answered 4/6, 2016 at 16:29 Comment(0)
L
4

This is a feature detection problem and, therefore, I would use the Hough Circle Transformation in the OpenCV library (tutorial). You can see from the screenshot that the method is quite robust in detecting partial circularity.


enter image description here

import cv2
import cv2.cv as cv
import numpy as np

img = cv2.imread(r'C:\path\to\eye.jpg',0)
img = cv2.medianBlur(img,5)
cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)

circles = cv2.HoughCircles(img,cv.CV_HOUGH_GRADIENT,1,20,
                            param1=150,param2=30,minRadius=20,maxRadius=100)

circles = np.uint16(np.around(circles))
for i in circles[0,:]:
    # draw the outer circle
    cv2.circle(cimg,(i[0],i[1]),i[2],(0,255,0),2)
    # draw the center of the circle
    cv2.circle(cimg,(i[0],i[1]),2,(0,0,255),3)

cv2.imshow('detected circles',cimg)
cv2.waitKey(0)
cv2.destroyAllWindows()
Luther answered 4/6, 2016 at 22:14 Comment(1)
Ah you are right, its an iris. I have asked some people who have used CIrcular Hough Transform and they said i can't use Hough Transform if the iris is covered by something, maybe they haven't tried this case. I never try Hough Transform before, but after they said it, i just find another method to solve this but still i stuck in this step. Talking about the openCV library you give to me, do you have the full theory/paper of this library? i cant just use the library for my project, because finding the iris is my main method for my last project in my college.Renaissance
D
3

I try to answer your question, i suggest you to use circle Hough Transform. I'm trying to detect the circular so you can get the radius of the circle and then you can get size of the circle.

Here the code and the result :

A = imread('eye.jpg');
A = imresize(A, 0.8);
A = rgb2gray(A);
A = edge(A, 'canny');
imshow(A);
[centers, radii, metric] = imfindcircles(A,[1 100]);
centersStrong5 = centers(1:1,:);
radiiStrong5 = radii(1:1);
metricStrong5 = metric(1:1);
viscircles(centersStrong5, radiiStrong5,'EdgeColor','b');

And the result is :

enter image description here

Hope it help your problem.

Code Reference : http://www.mathworks.com/help/images/ref/imfindcircles.html

Desmund answered 4/6, 2016 at 16:58 Comment(1)
at first i thought i can use Circular Hough Transform for my case, but i can't. In my case the image input sometimes its not a fully rounded pupil or iris. My project its about eye gaze estimation, so there will be an image input of an eye which is looking to the left side or the right side, and the pupil or the iris might be covered by something like eyelid.Renaissance

© 2022 - 2024 — McMap. All rights reserved.