-
Notifications
You must be signed in to change notification settings - Fork 0
/
iris_algilama.m
79 lines (69 loc) · 1.69 KB
/
iris_algilama.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
clear all
clc
%FaceDetect = vision.CascadeObjectDetector();bb_Face = step(FaceDetect,Image);
EyeDetect = vision.CascadeObjectDetector('RightEyeCART');
Image = imread('9.bmp');
test_size = 3;
im_size = length(size(Image));
bb_Eye = step(EyeDetect,Image);
eye_crop = imcrop(Image,bb_Eye(1,:));
if test_size == im_size
eye_crop = rgb2gray(eye_crop);
end
eye_crop = imresize(eye_crop, [30 30]);
h = bb_Eye(1,3);
w = bb_Eye(1,4);
eye = imcrop(eye_crop,[1,10,h,w]);
%imshow(eye);
%Histogram Equalization
HistEq = histeq(eye);
%figure, imshow (HistEq);
%title('Histogram Equalization');
%Binarization
% threshold
t = 16;
% find values below
ind_below = (HistEq < t);
% find values above
ind_above = (HistEq >= t);
% set values below to black
HistEq(ind_below) = 255;
% set values above to white
HistEq(ind_above) = 0;
%imshow(HistEq);
%title ('Histogram equalization');
%title('Binarization');
%Morphologic Operations (Erosion & Dilation)
filledHistEq = imfill(HistEq,'holes');
se = strel('ball',1,1);
eroded = imdilate(filledHistEq,se);
se2 = strel('ball',1,1);
dilate=imdilate(eroded,se2);
%figure, imshow(eroded);
%title('Erosion');
%figure, imshow(dilate);
%title('Dilation');
%Find iris
[L,num] = bwlabel(dilate,8);
RP = regionprops (L, 'Area');
max=0;
for i=1:num
if (RP(i).Area > max)
max = RP(i).Area;
end
end
for j=1:num
if (max == RP(j).Area)
maxx_ind = j;
end
end
%Bounding Box
RP1 = regionprops (L, 'BoundingBox');
figure
eye = imadjust(eye);
imshow(eye);
title('Iris Positioning');
hold on;
rectangle('Position',[RP1(maxx_ind).BoundingBox],'EdgeColor','r');
clear all;
%end