⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 虹膜识别程序.txt

📁 虹膜识别的程序
💻 TXT
字号:
clear all;
close all;
i = 1;
j = 0;
sumx = 0;
sumy = 0;
sumr = 0;
lll= imread('e:/001_1_3.bmp');
%%lll = imcrop(l,[60,0,250,280]);%
disp('iris detection');
tic;
[count, x] = imhist(lll);
for k = 1:256
    if count(k) >4000
        break;
    end
end
a1 = im2bw(lll, k/255);%归一化处理
a2 =  ~a1;%对a1取反
[y,x] = find(a2 ==1);%找到所有=1的点
d = size(x);
while i < d(1)/2%少循环次数
x1 = x(i);
y1 = y(i);  
while  x1 == x(i)%%循环过的值进行比较
    i = i+1;
end
y2 = y(i-1);%
x3 = x(i);%
y3 = y(i);%
% circle center
j = j+1;
cx(j) = (y3-y1)*(y2-y3)/2/(x1-x3)+(x1+x3)/2;%
sumx = sumx + cx(j);%
cy(j) = (y1+y2)/2;%
sumy = sumy + cy(j);%
cr(j) = ((cx(j)-x1)*(cx(j)-x1)+(cy(j)-y1)*(cy(j)-y1))^(1/2);%
sumr = sumr + cr(j);%
end

%get the average value of(x,y) and radias
averagex = sumx/j;
averagey = sumy/j;
averager = sumr/j;
% draw profile of iris

figure, imshow(lll);
hold on;
 alpha=0:pi/50:2*pi;
 x=averager*cos(alpha)+averagex;
 y=averager*sin(alpha)+averagey;
 plot(x,y,'-')
 axis equal;
toc;
hold off;
2.	基于直径检测的瞳孔定位程序
   clear all;
lll= imread('e:\001_1_3.bmp');
%lll = imcrop(l,[60,0,250,280]);
tic;
[count, x] = imhist(lll);
for k = 1:256
    if count(k) >4000
        break;
    end
end
a1 = im2bw(lll, k/255);
a2 =  ~a1;
j = 1;
k = 1;

[y,x] = find(a2 ==1);%from [y,x],u can find that some x has the same value, the max num of x is dimension
d = size(x);
%find the highest piont and lowest piont
line = sort(y);
linemin = line(1);
linemax = line(d(1));
%find the leftest piont and rightest piont
row = sort(x);
rowmin = row(1);
rowmax = row(d(1));

pupily = (linemin+linemax)/2;
pupilx = (rowmin+rowmax)/2;

raidmax = (linemax-linemin)/2;
figure,imshow(lll);
hold on;
 alpha=0:pi/100:2*pi;
 x=raidmax*cos(alpha)+pupilx;%move the origin to corresponding piont
 y=raidmax*sin(alpha)+pupily;
 plot(x,y,'-')
 axis equal;
toc;
hold off;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -