-
Notifications
You must be signed in to change notification settings - Fork 12
/
localisation2.m
88 lines (79 loc) · 1.27 KB
/
localisation2.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
80
81
82
83
84
85
86
87
88
function [out xc yc time]=localisation2(img,scale);
%for localising the iris based on black hole search.
tic;
x=0;
y=0;
scalewin=50*scale
xmin=255*scalewin;
%b=rgb2gray(img);
b=imresize(img,scale);
b=double(b);
p=size(b,1); %p's max value is 240
q=size(b,2); %q's max value is 320
for i=2:p-1
for j=1:q-scalewin
ssum=sum(b(i,j:j+scalewin));
if(xmin>ssum)
xmin=ssum;
x=i;
end
end
end
ymin=255*scalewin;
ssum=0;
for i=2:q-1
for j=2:p-scalewin
ssum=sum(b(j:j+scalewin,i));
if(ssum<ymin)
ymin=ssum;
y=i;
end
end
end
%m=1;n=1;
%error checking start
x=round((x * (1/scale)));
y=round((y * (1/scale)));
disp x;
disp y;
xc=x ;
yc=y ;
%b=rgb2gray(img);
b=(img);
p=size(b,1); %p's max value is 240
q=size(b,2); %q's max value is 320
if(x+75>p)
ux=p;
else
ux=x+75;
end
if(y+75>q)
uy=q;
else
uy=y+75;
end
if(x-75<0)
lx=1;
else
lx=abs(x-75);
end
if(y-75<0)
ly=1;
else
ly=abs(y-75);
end
%error check end
if uy<ly
temp=uy;
uy=ly;
ly=temp;
end
if ux<lx
temp=ux;
ux=lx;
lx=temp;
end
c=b(lx:ux,ly:uy);
out=c;
time=toc;
end