ITPub博客

首页 > IT职业 > IT生活 > 基于MATLAB的指纹识别算法仿真实现

基于MATLAB的指纹识别算法仿真实现

IT生活 作者:专注的阿熊 时间:2022-11-25 15:58:10 0 删除 编辑

clc;

clear all;

close all;

warning off;

% 读取图片

% 注意,为了和论文中的结果对应起来,我们使用论文中的图片进行代码的测试

I=imread('images.jpg');

if isrgb(I) == 1

    I = rgb2gray(I);

else

    I = I;

end

I_tmp = I;

figure;

subplot(121);

imshow(I);

% 图像预处理,去噪滤波

I = medfilt2(I,[3,3]);% 进行中值滤波 ;

subplot(122);

imshow(I);

% 背景分割

% 图像二值化处理

% 首先进行归一化

I=norms(I,120,600);  

figure;

% 为了显示处理效果,需要数据类型转换

subplot(121);

imshow(double(I));

Ker   = 8;

[m,n] = size(I);

m1    = m/Ker;

n1    = n/Ker;

for i=1:m1

    for j=1:n1

        % 设定门限

       t=mean2(I((i-1)*Ker+1:(i-1)*Ker+Ker,(j-1)*Ker+1:(j-1)*Ker+Ker));

       for k=(i-1)*Ker+1:(i-1)*Ker+Ker

           for l=(j-1)*Ker+1:(j-1)*Ker+Ker

               if I(k,l) < t

                   I(k,l)=1;

               else

                   I(k,l)=0;

               end

           end

       end

    end

end

% 为了显示处理效果,需要数据类型转换

subplot(122);

imshow(double(I));

% 异常点的处理

for i=1:m

     for j=1:n

         if I(i,j)>1

             I(i,j)=0;

         end

     end

end

for i=1:m

     for j=1:n

         if I(i,j)==1

             for k=1:j

                 I(i,k)=1;

             end

             break;

         end

     end

end

for i=1:m

     for j=n:-1:1

         if I(i,j)==1

             for k=n:-1:j

                I(i,k)=1;

             end

             break;

    end

     end

end

for i=1:m

     for j=1:n

         if I(i,j)==1

             I(i,j)=0;

         else

             I(i,j)=1;

         end

     end

end

figure;

% 为了显示处理效果,需要数据类型转换

imshow(double(I));

% 对细化前的图像进行维纳滤波

figure;

subplot(121);

imshow(double(I));

I=wiener2(I,[3 3]);

subplot(122);

imshow(double(I));

% 以下为细化处理

[r,c] = size(I);

for i1=1:r;

     for j1=1:c

         if (I(i1,j1)==1)

            I(i1,j1)= 255;

            I2      = I;

         end

     end

end

y = thinning(I2);

figure;

imshow(y);

% 以上的代码是你之前的第三章的代码的仿真图

% 以下的代码是对应第四章的仿真图

% 首先需要提取指纹图像的中心点——对应论文的“图 4-1 提取中心点后的细化图像”

[XC,YC] =外汇跟单gendan5.com find_central_point(y);

% 找寻细化图像的特征点

% 特征点的建立——对应论文的“图 4 - 2 特征点提取后的图像”

[dpx3,dpy3,dpcount3,fpx3,fpy3,fpcount3]=characterpoint(y);

figure;

imshow(y);

hold on;

plot(dpy3,dpx3,'o');

hold on;

plot(fpy3,fpx3,'+');

hold on;

plot(XC,YC,'*r');

hold off;

% 以下代码是对最后的识别结果和数据库中的进行匹配

% 计算每个特征点到中心点的距离,

Dpcount=size(dpx3,2);

Fpcount=size(fpx3,2);

for i=1:Dpcount

     DP_Feature(i)=sqrt((dpx3(i)-YC)^2+(dpy3(i)-XC)^2);

end

for j=1:Fpcount

     FP_Feature(j)=sqrt((fpx3(j)-YC)^2+(fpy3(j)-XC)^2);

end   

% 计算指纹图像的方向角

theta = func_theta(I_tmp);

% 建立待识别的特征库

for i=1:Dpcount

     PointOfModel(i,1)=1;

     PointOfModel(i,2)=DP_Feature(i);

     PointOfModel(i,3)=theta(dpx3(i),dpy3(i))-theta(YC,XC);

end

for i=Dpcount+1:Dpcount+Fpcount

     PointOfModel(i,1)=2;

     PointOfModel(i,2)=FP_Feature(i-Dpcount);

     PointOfModel(i,3)=theta(fpx3(i-Dpcount),fpy3(i-Dpcount))-theta(YC,XC);

end    

% 调用 database_feature 计算得到 PointOfMatch

I=imread('database/22.tif');

if isrgb(I) == 1

    I = rgb2gray(I);

else

    I = I;

end

PointOfMatch = database_feature(I);

% 调用 MATCH 函数进行匹配

% 图 4-3 匹配后的图像

NUM = 90;% 这个参数是新加的,设置相似度,即多少个匹配点对上才算成功

Count=match(y,PointOfModel,PointOfMatch,dpx3,dpy3,fpx3,fpy3,NUM);


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69946337/viewspace-2925232/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-08-23

  • 博文量
    410
  • 访问量
    276752