You are on page 1of 7

Pupil Detection ( Center And Radius )

To detect the pupil center first we apply threshold on the


image. Let the input image is stored in a matrix name INPUT and
then we write BINARY = INPUT<30 which means BINARY is a
matrix which store 1 for the intensity which are less than 30 and 0
for intensities which are greater than 30. After apply this
command we can see the result below

INPUT ( Original Image)

BINARY ( INPUT<30 )
But we can see there are some black holes in the pupil which will
affect our output ( in BINARY matrix ). We can see these black
holes which are inside the pupil are surrounded by intensities
values equal to 1. We can use this to fill these holes. We run a
matrix loop of size 31*31 to 3*3 (just hit and try) in the whole
BINARY matrix whose boundaries intensity values are 1. Like you
can see below

It is for 5*5 and so on for other


And give the condition that if sum of multiplication (elements by
elements) of kernel matrix 3*3 (boundary elements are 1) and
one by one of all 3*3 square matrix of BINARY matrix is equal to
8 (only for 3*3) it will different for 4*4, 5*5 etc. Then fill that
3*3, 4*4, .n*n of BINARY matrix with all elements equal to 1.
In this way we fill all the holes which are inside in the pupil.

And the output will look like

Now we run a loop of matrix of size 3*3 to 99*99 whose all


elements are equal to 1. And give a condition that if sum of
multiplication (elements by elements) of kernel matrix 3*3 ( all
elements are 1) and one by one of all 3*3 square matrix of
BINARY matrix is equal to 9 ( For 4*4 equal to 16 and so on for
99*99 ) then write 3 at the center of that kernel matrix in a new
matrix h. Let see in the example

After that we get a matrix with intensities values 3 to 99 there will


be a matrix which will fit perfectly in the pupil. And that will be
the matrix which will help us to calculate the radius and the

center of the pupil. For that we will find the maximum value in the
new matrix h with command find let that value is n. Then we will
find the coordinate for that value n. Then calculate the mean for
both x and y coordinate and that will the final center for pupil and
radius will be n/
2. Let consider upper example in which
maximum length of matrix is 5 then radius will be 5/2 and center
will be (5, 4).

Iris Detection
Now consider the BINARY matrix from right side we run a loop
which will only find the first 1 in every row and find there
distances from the center same as from the left side and store all
the distances in a new matrix name distance. Then find the
value in matrix distance which will repeated more times. And
that will be the radius of the iris. Now we know radius for both
pupil and iris and we can now easily separate the iris part. Form
the whole eye image. And we store the final iris segmentation
image in a new matrix name irisseg which look like

Circular To Rectangular Conversion


In this conversion there are two main points that all the pixels of
iris should come in the rectangle and value at all angle 1 to 360

degree. First we take a reference from where we measure the


angle. See in the figure

Find angle for all pixels which are in iris w.r.t. center. Let the
coordinate of center are ( x, y ) and coordinate of any pixel in iris
region is ( i, j ) then the angle will be theta = atan ( abs( (j-y )/ (ix) ) ) now there will be several conditions like if ( j-y ) > 0 and ( i-x
)<0 then new theta will be (-theta) so on. Then we take a new
matrix DATA which store of theta and coordinate for all pixels
which are in the iris. Like see below

We can see that in the table some angles are repeating itself
thats why we will find the angle which repeats maximum times
and that maximum value will be the width of our rectangle and
length will from 1 to 360 that will same in all cases. And we know
coordinate of all pixels than we can easy fill the intensity of these
pixels in the rectangle. And the final rectangle will look like this

You might also like