Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove some edges after applying edge detection?

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.

like image 917
Dennis Avatar asked Jun 04 '16 16:06

Dennis


2 Answers

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()
like image 158
Borealis Avatar answered Nov 11 '22 11:11

Borealis


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

like image 37
Mr. Mike Avatar answered Nov 11 '22 09:11

Mr. Mike