Introduction: Iris Detection

This project will crop the iris from an image.

Step 1: Add a Video With an Eye Image

Add "From Multimedia File" block in Simulink and convert it to double type.

Step 2: Find Pupil

Add in Simulink diagram 3 "Interpreted Matlab Function" Blocks.

The first one will find the x coordinate of the centre of pupil.

function [ center1] = findCentre1( gray_image )
[centers1, radii1] = imfindcircles(gray_image,[35 45],'ObjectPolarity','dark', ... 'Sensitivity',1);

center1=centers1(1,1);

end

The second block will find the y coordinate of the centre of pupil.

function [center2] = findCentre2( gray_image )
[centers1, radii1] = imfindcircles(gray_image,[35 45],'ObjectPolarity','dark', ... 'Sensitivity',1);

center2=centers1(1,2);

end

The last block will find the radius of pupil.

function [radii1 ] = findRadii1( gray_image )
[centers1, radii1] = imfindcircles(gray_image,[35 45],'ObjectPolarity','dark', ... 'Sensitivity',1);

radii1=radii1(1);

end

Then, add a mux block with 3 entries and a "Draw shapes " block (select circle as shape in block parameters). View the image with a "Video Viewer" block.

Step 3: Find Iris

Add a user-defined system block. Here we will create a sobel edge detector .

Add in Simulink diagram 3 "Interpreted Matlab Function" Blocks.

The first one will find the x coordinate of the centre of iris.

function [ center3] = findCentre3( gray_image )
[centers2, radii2] = imfindcircles(gray_image,[99 110], 'ObjectPolarity','dark', ... 'Sensitivity',1,'Method','twostage');

center3=centers2(1,1);

end

The second block will find the y coordinate of the centre of iris.

function [ center4] = findCentre4( gray_image )
[centers2, radii2] = imfindcircles(gray_image,[99 110], 'ObjectPolarity','dark', ... 'Sensitivity',1,'Method','twostage');

center4=centers2(1,2);

end

The last block will find the radius of iris.

function [radii2 ] = findRadii2( gray_image )

[centers2, radii2] = imfindcircles(gray_image,[99 110], 'ObjectPolarity','dark', ... 'Sensitivity',1,'Method','twostage');

radii2=radii2(1); end

Then, add a mux block with 3 entries and a "Draw shapes " block (select circle as shape in block parameters). View the image with a "Video Viewer" block.

Step 4: Create a Mask for Eyelid

Copy the user-define subsystem and paste it in the diagram. Change the constant to 3.

Convert the image to double type.

Step 5: Crop Iris

Add 2 Matlab Function Blocks.

First:

function [Mask_row,Mask_column]= fcn(Mask,centre_x1,centre_y1,r1)
[row,column]=size(Mask);

row_mask=1;

column_mask=1;

Mask_r=zeros(row,column);

Mask_c=zeros(row,column);

for i=1:row

for j=1:column

if (centre_x1-i)^2+(centre_y1-j)^2-(r1+10)^2<=0

Mask(i,j)=1;

end

end

end

for i=1:row

for j=1:column

if Mask(i,j)==0;

Mask_r(row_mask)=i;

Mask_c(column_mask)=j;

row_mask=row_mask+1;

column_mask=column_mask+1;

end

end

end

Mask_row=Mask_r;

Mask_column=Mask_c;

end

Second:

function y = crop_iris(Image,centre_x1,centre_y1,r1,centre_x2,centre_y2,r2,Mask_row,Mask_column)
[row,column]=size(Image);

row_mask=1;

column_mask=1;

max_row=(max(max(Mask_row))+min(min(Mask_row)))*0.66;

for i=1:row

for j=1:column

if (centre_x1-i)^2+(centre_y1-j)^2-r1^2>=0

Image(i,j)=1;

end

if (centre_x2-i)^2+(centre_y2-j)^2-r2^2<=0

Image(i,j)=1;

end

if i==Mask_row(row_mask) && j==Mask_column(column_mask)

Image(i,j)=1;

row_mask=row_mask+1;

column_mask=column_mask+1;

end

end

end

y = Image;