MATLAB身份证号码识别系统(GUI论文)

 

  1. 课题介绍

本课题为基于连通域分割和模板匹配的二代居民身份证号码识别系统,带有一个GUI人机交互界面。可以识别数十张身份证图片。

资源链接:https://download.csdn.net/download/matlab1998_vx/14942740

首先从身份证图像上获取0~9和X共十一个号码字符的样本图像作为后续识别的字符库样本,其次将待测身份证图像进行去噪、灰度化、二值化、水平投影切割,垂直投影并切割,将待测身份证号码分割出来,然后进行待测号码图片与字符库样本对比计算、识别判断、最终确定待测身份证号号码。本设计关于身份证号码的识别是基于Matlab软件的基础上进行的。

 

  1. 算法流程
  2. 输入身份证图片;2、根据几何信息定位身份证号码位置并且切割;3、利用连通域算法切割字符;4、利用模板匹配算法进行识别

 

 

MATLAB身份证号码识别系统(GUI论文)_第1张图片

 

  1. GUI界面设计

 

 

MATLAB身份证号码识别系统(GUI论文)_第2张图片

四、运行截图

 

 

MATLAB身份证号码识别系统(GUI论文)_第3张图片

 

五、源码

1、打开图像

[FileName,PathName] = uigetfile('*.jpg','Select an image');
if PathName~=0
    str = [PathName,FileName];
    T=imread(str);
    axes(handles.axes1);
    imshow(T);
end
预处理
[m,n,r]=size(I);%图像的像素为width*height
%%%%%蓝色字体变黑
myI=double(I);
 
for i=1:m
    for j=1:n
            if((myI(i,j,1)>=15)&&(myI(i,j,1)<=130)&&((myI(i,j,2)<=165)&&(myI(i,j,2)>=90))&&((myI(i,j,3)<=220)&&(myI(i,j,3)>=135))) % 蓝色RGB的灰度范围
              I(i,j,1)=40; %红色分量
              I(i,j,2)=40; %绿色分量
              I(i,j,3)=40; %蓝色分量
           end  
    end       
end
%figure, imshow(I);title('变色后的图像');
 
width=round(0.9*n);height=round(0.87*m);
rx=round(0.05*n);cy=round(0.075*m);
I=subim(I,height,width,rx,cy);
%figure,imshow(I);
 
 
if sum(size(I)>0)==3 %倘若是彩色图--2维*3,先转换成灰度图
I=rgb2gray(I);
end
%figure,imhist(I);
x=3;%行数分为x部分
y=1;%列数分为y部分
BW=erzhihua(I,x,y);
 
[n m l]=size(BW);%图像的像素为m*n
c = [0.65*m 0.65*m m m];
r = [0 0.85*n 0.85*n 0];
BW = roifill(BW,c,r);
 
BW=imadjust(BW);%使用imadjust函数对图像进行增强对比度
% Convert to BW
threshold = graythresh(BW);
BW =~im2bw(BW,0.6*threshold);
 
[image_h image_w]=size(BW);
% Remove all object containing fewer than (imagen/80) pixels
BW = bwareaopen(BW,floor(image_w/80));
% 滤波
imshow(BW);
  1. 识别
[image_h image_w]=size(imagen);
%figure;imshow(imagen);title('INPUT IMAGE')
 
% Convert to gray scale
if size(imagen,3)==3 %RGB image
    imagen=rgb2gray(imagen);
end
 
%Storage matrix word from image
word=[ ];
re=imagen;
% Compute the number of letters in template file
num_letras=size(templates,2);
 

    % Label and count connected components
   [L Ne] = bwlabel(imgn);    
 
      n=1;%记录循环次数
while(n<=Ne)
        char_flag=0;%为0时,是第一次判断这个连通域
        flag=1;%初始化两个连通域属于同个字符
   while(flag==1)       
      if char_flag==0
        [r,c] = find(L==n);
        Width0=max(r)-min(r);%连通域宽度
        Height0=max(c)-min(c);%连通域高度
        Radio0=Width0/Height0;%连通域宽高比
        Square0=Width0*Height0;%连通域面积
        maxr=max(r);
        maxc=max(c);
        minr=min(r);
        minc=min(c);
      end
       if n=-(image_w/pw)&&Owidth<=0)||(Oheigth>=-(line_h*0.3)&&Oheigth<=0))%两个连通域较近,但不重叠
           if((Uradio>=0.8)&&(Uradio<=1.2))%认为两个连通域属于同一个字符
           elseif Uheight0)||(Oheigth>0))%两连通域重叠
      elseif(flag==1)&&((Owidth>0))%两连通域重叠
               if(((Uradio>=0.78)&&(Uradio<=1.3)))%认为两个连通域属于同一个字符
               elseif(Osquare>=0.4*min(Square0,Square1)&&(Uwidth

你可能感兴趣的:(算法,定位,计算机视觉,ocr,payment)