# Iris Detection

2,434

25

1

This project will crop the iris from an image.

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## 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);

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');

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:

for i=1:row

for j=1:column

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

end

end

end

for i=1:row

for j=1:column

end

end

end

end

Second:

[row,column]=size(Image);

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

Image(i,j)=1;

end

end

end

y = Image;