指纹识别算法
更新时间:2023-10-21 06:13:02 阅读量: 综合文库 文档下载
function fpextractdemo(action, varargin) %
FPEXTRACTDEMO 指纹特征提取演示程序
% Modified by PRTsinghua@hotmail.com %
% 输入图像必须是256×256的灰度图 % 8-bit灰度级的图像 @ 500 dpi.
% 如果这些条件不满足,一些函数中的参数必须做相应的改变 % % % 选项:
% - Centralize: 二值化图像,计算中心点 % - Crop: 图像修剪 % - Sectorize: 可视化扇形 % - Normalize: 归一化输入图像 % - Gabor filters: 可视化Gabor滤波器
% - Convolute: 计算输入图像和Gabor滤波器的convolution % - Features: 特征可视化
% - FingerCode: 在数据库中加入该指纹 % - Check: 指纹匹配 % %
% 指纹识别中一个至关重要的步骤就是中心点的确定。如果剪切指纹图像时出现了任何
% 错误,你可以使用辅助的m文件\:它使得输入指纹可视化并计算指纹
% 中心,借助于m函数 \。
%
% 在MATLAB的命令行提示中输入 \运行程序
%-------------------------------------------------------------------------- if nargin<1,
action='InitializeFPEXTRACTDEMO'; end;
feval(action,varargin{:}) return; %%%
%%% 子函数 - InitializeFPEXTRACTDEMO %%%
function InitializeFPEXTRACTDEMO()
% 如果 fpextractdemo 已经在运行,将之转到前台
h = findobj(allchild(0), 'tag', 'Extracting FingerPrint Features Demo ( Modified by PRTsinghua@hotmail.com v) '); if ~isempty(h) figure(h(1)) return end
screenD = get(0, 'ScreenDepth'); if screenD>8 grayres=256; else
grayres=128; end
FpextractDemoFig = figure( ...
'Name','指纹特征提取演示程序 Modified by PRTsinghua@hotmail.com', ... 'NumberTitle','off', 'HandleVisibility', 'on', ... 'tag', '指纹特征提取演示程序', ... 'Visible','off', 'Resize', 'off',...
'BusyAction','Queue','Interruptible','off', ... 'Color', [.8 .8 .8], ... 'IntegerHandle', 'off', ... 'Colormap', gray(grayres));
figpos = get(FpextractDemoFig, 'position'); figpos(3:4) = [1024 525];
% Adjust the size of the figure window horizDecorations = 10; % 调整大小. vertDecorations = 45; % 标题栏. screenSize = get(0,'ScreenSize');
dx = screenSize(3) - figpos(1) - figpos(3) - horizDecorations; dy = screenSize(4) - figpos(2) - figpos(4) - vertDecorations; if (dx < 0)
figpos(1) = max(5,figpos(1) + dx); end if (dy < 0)
figpos(2) = max(5,figpos(2) + dy); end
set(FpextractDemoFig, 'position', figpos);
rows = figpos(4); cols = figpos(3); % Colors
bgcolor = [0.45 0.45 0.45]; % 背景颜色 wdcolor = [.8 .8 .8]; fgcolor = [1 1 1];
hs = (cols-(6*175)) / 5; vs = (rows)/8;
%==================================== % 所有菜单和按钮的参数
Std.Interruptible = 'off'; Std.BusyAction = 'queue';
% Defaults for image axes Ax = Std; Ax.Units = 'Pixels';
Ax.Parent = FpextractDemoFig; Ax.ydir = 'reverse'; Ax.XLim = [.5 128.5]; Ax.YLim = [.5 128.5]; Ax.CLim = [0 1]; Ax.XTick = [];
% 水平间隔
% 垂直间隔
% Window 颜色
% 文本
Ax.YTick = [];
Img = Std; Img.CData = []; Img.Xdata = [1 128]; Img.Ydata = [1 128]; Img.CDataMapping = 'Scaled'; Img.Erasemode = 'none';
Ctl = Std; Ctl.Units = 'Pixels';
Ctl.Parent = FpextractDemoFig;
Btn = Ctl;
Btn.Style = 'pushbutton'; Btn.Enable = 'off';
Edit = Ctl; Edit.Style = 'edit';
Edit.HorizontalAlignment = 'right'; Edit.BackgroundColor = 'white'; Edit.ForegroundColor = 'black';
Menu = Ctl;
Menu.Style = 'Popupmenu';
Text = Ctl; Text.Style = 'text';
Text.HorizontalAlignment = 'left'; Text.BackgroundColor = bgcolor;
LoadNewImage(FpextractDemoFig); SelectExtractingStep(FpextractDemoFig); return
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%
%%% 子函数 - LoadNewImage %%%
function LoadNewImage(DemoFig) % 加载新图像
if nargin<1 DemoFig = gcbf; end
set(DemoFig,'Pointer','watch'); ud=get(DemoFig,'Userdata');
v = get(ud.hImgPop,{'value','String'}); name = deblank(v{2}(v{1},:)); drawnow
switch name case 'Right loop', namefile='37_7.bmp'; [img,map]=imread(namefile); case 'Whorl',
namefile='19_7.bmp'; [img,map]=imread(namefile); case 'Left loop',
namefile='37_3.bmp'; [img,map]=imread(namefile); case 'Twin loop',
namefile='37_5_2.bmp'; [img,map]=imread(namefile); case 'Other image',
[namefile,pathname]=uigetfile('*.bmp','请选择一个256×256的灰度位图'); if namefile~=0
[img,map]=imread(strcat(pathname,namefile)); else
disp(' Chose a file! '); [img,map]=imread('37_7.bmp'); end otherwise
error('fpextractdemo: Unknown Image Option!'); end
% 如果图像大小 N x M 且 mod(N,8)~=0 或者 mod(M,8)~=0 % 则改变图像大小 imgN=size(img,1); imgM=size(img,2); modN=mod(imgN,8); modM=mod(imgM,8);
%---------------------------------------- % 将信息保存在 informations.dat if isa(img,'uint8')
graylevmax=2^8-1; end
if isa(img,'uint16') graylevmax=2^16-1; end
if isa(img,'uint32') graylevmax=2^32-1; end
save('informations.dat','graylevmax','img'); %----------------------------------------- % 改变图像大小
%----------------------------------------- img=img(modN+1:imgN,modM+1:imgM); %----------------------------------------- img = double(img)/graylevmax;
set(get(ud.hOriginalAxes, 'title'), 'string', '原始指纹图像'); set(get(ud.hComponent1Axes, 'title'), 'string', '0 度组成'); set(get(ud.hComponent6Axes, 'title'), 'string', '112.5 度组成'); set(ud.hOriginalImage, 'Cdata', img); set(DemoFig,'Pointer','arrow');
setstatus(DemoFig,'Please select a step to process...'); return;
%======================================== %%%
%%% 子函数 - SelectExtractingStep %%%
function SelectExtractingStep(DemoFig)
% Load a step
if nargin<1 DemoFig = gcbf; end
set(DemoFig,'Pointer','watch'); ud=get(DemoFig,'Userdata');
v = get(ud.hSelectStepPop,{'value','String'}); name = deblank(v{2}(v{1},:)); drawnow
switch name case 'Centralize', Centralize(DemoFig); case 'Crop', Crop(DemoFig); case 'Sectorize', Sectorize(DemoFig); case 'Normalize', Normalize(DemoFig); case 'Gabor filters', Gaborfilter(DemoFig); case 'Convolute', Convolute(DemoFig); case 'Features', Features(DemoFig); case 'FingerCode', Fingercode(DemoFig); case 'Check',
Check(DemoFig); otherwise
error('fpextractdemo: Unknown Image Option!'); end return;
%========================================================================== %%%
%%% 子函数 - Centralize %%%
function Centralize(DemoFig)
load 'informations.dat' -mat
if nargin<1 DemoFig = gcbf; end
set(DemoFig,'Pointer','watch');
setstatus(DemoFig,'正在计算中心,请等待......'); ud=get(DemoFig,'Userdata');
fingerprint = getimage(ud.hOriginalImage); fingerprint = fingerprint*graylevmax;
[BinarizedPrint,XofCenter,YofCenter] = centralizing(fingerprint,0);
set(get(ud.hComponent8Axes, 'title'), 'string', '二值化图像'); set(ud.hComponent8Image, 'Cdata', BinarizedPrint);
set(get(ud.hComponent4Axes, 'title'), 'string', '67.5 度 gabor'); set(ud.hComponent4Image, 'Cdata', gabor); case (angle==4),
set(get(ud.hComponent5Axes, 'title'), 'string', '90 度 gabor'); set(ud.hComponent5Image, 'Cdata', gabor); case (angle==5),
set(get(ud.hComponent6Axes, 'title'), 'string', '112.5 度 gabor'); set(ud.hComponent6Image, 'Cdata', gabor); case (angle==6),
set(get(ud.hComponent7Axes, 'title'), 'string', '135 度 gabor'); set(ud.hComponent7Image, 'Cdata', gabor); case (angle==7),
set(get(ud.hComponent8Axes, 'title'), 'string', '157.5 度 gabor'); set(ud.hComponent8Image, 'Cdata', gabor); otherwise
error('Nothing !'); end end
set(DemoFig,'Pointer','arrow');
setstatus(DemoFig,'Gabor Filters were shown'); ud.OriginalImageIsStale = 0; set(DemoFig, 'UserData', ud); drawnow
%========================================================================== %%%
%%% 子函数 - Convolute %%%
function Convolute(DemoFig) %
load 'informations.dat' -mat
if nargin<1 DemoFig = gcbf; end
set(DemoFig,'Pointer','watch');
setstatus(DemoFig,'正在处理8个Gabor滤波器,旋转......'); ud=get(DemoFig,'Userdata');
fingerprint = getimage(ud.hOriginalImage);
load 'informations.dat' -mat
fingerprint = fingerprint*graylevmax; N=175; num_disk=8;
[BinarizedPrint,XofCenter,YofCenter]=centralizing(fingerprint,0); [CroppedPrint]=cropping(XofCenter,YofCenter,fingerprint); [NormalizedPrint,vector]=sector_norm(CroppedPrint,0,1); for (angle=0:1:num_disk-1)
gabor=gabor2d_sub(angle,num_disk); z2=gabor;
z1=NormalizedPrint;
z1x=size(z1,1); z1y=size(z1,2); z2x=size(z2,1); z2y=size(z2,2);
ComponentPrint=real(ifft2(fft2(z1,z1x+z2x-1,z1y+z2y-1).*fft2(z2,z1x+z2x-1,z1y+z2y-1)));
px=((z2x-1)+mod((z2x-1),2))/2; py=((z2y-1)+mod((z2y-1),2))/2;
ComponentPrint=ComponentPrint(px+1:px+z1x,py+1:py+z1y);
[disk,vector]=sector_norm(ComponentPrint,1,0); img = double(ComponentPrint)/graylevmax;
switch angle<8 case (angle==0),
set(get(ud.hComponent1Axes, 'title'), 'string', '0 度组成'); set(ud.hComponent1Image, 'Cdata', img); case (angle==1),
set(get(ud.hComponent2Axes, 'title'), 'string', '22.5 度组成'); set(ud.hComponent2Image, 'Cdata', img); case (angle==2),
set(get(ud.hComponent3Axes, 'title'), 'string', '45 度组成'); set(ud.hComponent3Image, 'Cdata', img); case (angle==3),
set(get(ud.hComponent4Axes, 'title'), 'string', '67.5 度组成'); set(ud.hComponent4Image, 'Cdata', img); case (angle==4),
set(get(ud.hComponent5Axes, 'title'), 'string', '90 度组成');
set(ud.hComponent5Image, 'Cdata', img); case (angle==5),
set(get(ud.hComponent6Axes, 'title'), 'string', '112.5 度组成'); set(ud.hComponent6Image, 'Cdata', img); case (angle==6),
set(get(ud.hComponent7Axes, 'title'), 'string', '135 度组成'); set(ud.hComponent7Image, 'Cdata', img); case (angle==7),
set(get(ud.hComponent8Axes, 'title'), 'string', '157.5 度组成'); set(ud.hComponent8Image, 'Cdata', img); otherwise
error('Nothing !'); end end
set(DemoFig,'Pointer','arrow'); setstatus(DemoFig,'旋转结束'); set(DemoFig, 'UserData', ud); drawnow
%========================================================================== %%%
%%% 子函数 - Features %%%
function Features(DemoFig) %
load 'informations.dat' -mat
if nargin<1 DemoFig = gcbf; end
set(DemoFig,'Pointer','watch');
setstatus(DemoFig,'正在处理8个Gabor滤波器,旋转......'); ud=get(DemoFig,'Userdata');
fingerprint = getimage(ud.hOriginalImage);
fingerprint = fingerprint*graylevmax; N=175; num_disk=8;
[BinarizedPrint,XofCenter,YofCenter]=centralizing(fingerprint,0); [CroppedPrint]=cropping(XofCenter,YofCenter,fingerprint); [NormalizedPrint,vector]=sector_norm(CroppedPrint,0,1);
for (angle=0:1:num_disk-1)
gabor=gabor2d_sub(angle,num_disk); z2=gabor;
z1=NormalizedPrint; z1x=size(z1,1); z1y=size(z1,2); z2x=size(z2,1); z2y=size(z2,2);
ComponentPrint=real(ifft2(fft2(z1,z1x+z2x-1,z1y+z2y-1).*fft2(z2,z1x+z2x-1,z1y+z2y-1)));
%========================================================================== %%%
%%% 子函数 - Check %%%
function Check(DemoFig) %
load 'informations.dat' -mat
if nargin<1 DemoFig = gcbf; end
set(DemoFig,'Pointer','watch');
setstatus(DemoFig,'正在搜索数据库......'); ud=get(DemoFig,'Userdata');
fingerprint = getimage(ud.hOriginalImage);
fingerprint = fingerprint*graylevmax; N=175; num_disk=8;
[BinarizedPrint,XofCenter,YofCenter]=centralizing(fingerprint,0); [CroppedPrint]=cropping(XofCenter,YofCenter,fingerprint); [NormalizedPrint,vector]=sector_norm(CroppedPrint,0,1);
for (angle=0:1:num_disk-1)
gabor=gabor2d_sub(angle,num_disk); z2=gabor;
z1=NormalizedPrint; z1x=size(z1,1); z1y=size(z1,2); z2x=size(z2,1); z2y=size(z2,2);
ComponentPrint=real(ifft2(fft2(z1,z1x+z2x-1,z1y+z2y-1).*fft2(z2,z1x+z2x-1,z1y+z2y-1)));
px=((z2x-1)+mod((z2x-1),2))/2; py=((z2y-1)+mod((z2y-1),2))/2;
ComponentPrint=ComponentPrint(px+1:px+z1x,py+1:py+z1y); [disk,vector]=sector_norm(ComponentPrint,1,0); %img = double(ComponentPrint)/graylevmax; %img1 = double(disk)/51200; finger_code{angle+1}=vector(1:36); end
% 输入指纹的编码已经计算,检查数据库 if (exist('fp_database.dat')==2) load('fp_database.dat','-mat');
%---- 申请内存 ----------------------------------- ruoto1=zeros(36,1); ruoto2=zeros(36,1); vettore_d1=zeros(12,1); vettore_d2=zeros(12,1);
best_matching=zeros(fp_number,1);
% 开始检查 --------------------------------------- for scanning=1:fp_number fcode1=data{scanning,1}; fcode2=data{scanning,2}; for rotazione=0:1:11 d1=0; d2=0; for disco=1:8 f1=fcode1{disco}; f2=fcode2{disco};
% ora ruoto f1 ed f2 della rotazione ciclica ---------- for old_pos=1:12
new_pos=mod(old_pos+rotazione,12); if (new_pos==0) new_pos=12; end
ruoto1(new_pos)=f1(old_pos); ruoto1(new_pos+12)=f1(old_pos+12); ruoto1(new_pos+24)=f1(old_pos+24); ruoto2(new_pos)=f2(old_pos); ruoto2(new_pos+12)=f2(old_pos+12); ruoto2(new_pos+24)=f2(old_pos+24); end
%------------------------------------------------------- d1=d1+norm(finger_code{disco}-ruoto1);
d2=d2+norm(finger_code{disco}-ruoto2); end
vettore_d1(rotazione+1)=d1; vettore_d2(rotazione+1)=d2; end
[min_d1,pos_min_d1]=min(vettore_d1); [min_d2,pos_min_d2]=min(vettore_d2); if min_d1 minimo=min_d2; end best_matching(scanning)=minimo; end [distanza_minima,posizione_minimo]=min(best_matching); beep; message=strcat('数据库中与输入指纹最匹配的是:',num2str(posizione_minimo),... ' 其距离为: ',num2str(distanza_minima)); msgbox(message,'数据库信息','帮助'); %------------------------------------------------------- else message='数据库为空,无法检查'; msgbox(message,'指纹编码数据库错误','警告'); end set(DemoFig,'Pointer','arrow'); setstatus(DemoFig,'数据库搜索完毕'); set(DemoFig, 'UserData', ud); drawnow %========================================================================== 指纹文件夹
正在阅读:
指纹识别算法10-21
年产10万吨煤制乙醇生产工艺设计05-06
写事阅读训练 含答案11-02
理论力学考研题库 - 图文11-14
江苏省卫生厅申报卫生外事工作先进集体材料12-26
大脑ESP超能力02-13
合肥工业大学2013年攻读硕士学位研究生招生专业目录10-20
第一节 职业生活中的道德与法律10-26
南昌大学机械设计课程设计说明书 - 图文03-12
- 多层物业服务方案
- (审判实务)习惯法与少数民族地区民间纠纷解决问题(孙 潋)
- 人教版新课标六年级下册语文全册教案
- 词语打卡
- photoshop实习报告
- 钢结构设计原理综合测试2
- 2014年期末练习题
- 高中数学中的逆向思维解题方法探讨
- 名师原创 全国通用2014-2015学年高二寒假作业 政治(一)Word版
- 北航《建筑结构检测鉴定与加固》在线作业三
- XX县卫生监督所工程建设项目可行性研究报告
- 小学四年级观察作文经典评语
- 浅谈110KV变电站电气一次设计-程泉焱(1)
- 安全员考试题库
- 国家电网公司变电运维管理规定(试行)
- 义务教育课程标准稿征求意见提纲
- 教学秘书面试技巧
- 钢结构工程施工组织设计
- 水利工程概论论文
- 09届九年级数学第四次模拟试卷
- 指纹识别
- 算法
- 邱兴华的犯罪心理学分析
- 高级英语2 翻译
- 护理三基试题和答案
- h第八章 主要组织相容性复合体
- Delphi异常机制与SEH
- 化工思考题实验答案
- 中国移动基站设备工程竣工资料模版 - 图文
- 村庄规划制图统一标准
- 环境生态学试卷1
- 劳动经济学知识点总结
- 电工培训试题
- 读《为历史学辩护》有感
- 深圳市华侨城中学广东省普通高中教学水平评估自评报告
- ESXI5.1配置手册 - 图文
- 小学二年级美术上册全册教案 岭南版 教师收藏
- 基于MATLAB的多容对象液位控制系统仿真毕业设计(PID 串级控制)
- 四年级上数学期末试题综合考练(24)人教新课标(附答案)
- 东华大学入学测试机考《数学》(高起点)模拟题及答案
- 腔体滤波器的设计中耦合窗口的计算
- 大学生心理健康考试重点