新博念 足球网站开发,宏润建设集团有限公司网站,国外工作室网站,wordpress主题4mudi课题介绍
本课题为基于连通域分割和模板匹配的二代居民身份证号码识别系统#xff0c;带有一个GUI人机交互界面。可以识别数十张身份证图片。
首先从身份证图像上获取0#xff5e;9和X共十一个号码字符的样本图像作为后续识别的字符库样本#xff0c;其次将待测身份证图像… 课题介绍
本课题为基于连通域分割和模板匹配的二代居民身份证号码识别系统带有一个GUI人机交互界面。可以识别数十张身份证图片。
首先从身份证图像上获取09和X共十一个号码字符的样本图像作为后续识别的字符库样本其次将待测身份证图像进行去噪、灰度化、二值化、水平投影切割垂直投影并切割将待测身份证号码分割出来然后进行待测号码图片与字符库样本对比计算、识别判断、最终确定待测身份证号号码。本设计关于身份证号码的识别是基于Matlab软件的基础上进行的。 算法流程
输入身份证图片2、根据几何信息定位身份证号码位置并且切割3、利用连通域算法切割字符4、利用模板匹配算法进行识别 GUI界面设计 四、运行预期ps图 五、源码
1、打开图像
[FileName,PathName] uigetfile(*.jpg,Select an image);
if PathName~0 str [PathName,FileName]; Timread(str); axes(handles.axes1); imshow(T);
end
预处理
[m,n,r]size(I);%图像的像素为width*height
%%%%%蓝色字体变黑
myIdouble(I); for i1:m for j1: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; %绿色分量 end end
end
%figure, imshow(I);title(变色后的图像); widthround(0.9*n);heightround(0.87*m);
rxround(0.05*n);cyround(0.075*m);
Isubim(I,height,width,rx,cy);
%figure,imshow(I); if sum(size(I)0)3 %倘若是彩色图--2维*3先转换成灰度图
Irgb2gray(I);
end
%figure,imhist(I);
x3;%行数分为x部分
y1;%列数分为y部分
BWerzhihua(I,x,y); BWimadjust(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);
识别
[image_h image_w]size(imagen);
%figure;imshow(imagen);title(INPUT IMAGE) % Convert to gray scale
if size(imagen,3)3 %RGB image imagenrgb2gray(imagen);
end %Storage matrix word from image
word[ ];
reimagen;
% Compute the number of letters in template file
num_letrassize(templates,2); plot_flag1;
while 1 %Fcn lines separate lines in text [fl re]lines(re); imgnfl; [line_h line_w]size(fl);%记录下切割出来的一行字符的长宽 %Uncomment line below to see lines one by one % imshow(fl);pause(1) %----------------------------------------------------------------- % Label and count connected components [L Ne] bwlabel(imgn); n1;%记录循环次数
while(nNe) char_flag0;%为0时是第一次判断这个连通域 flag1;%初始化两个连通域属于同个字符 while(flag1) if char_flag0 [r,c] find(Ln); Width0max(r)-min(r);%连通域宽度 Height0max(c)-min(c);%连通域高度 Radio0Width0/Height0;%连通域宽高比 maxrmax(r); maxcmax(c); minrmin(r); mincmin(c); end if nNe [r1,c1] find(L(n1));%寻找下一个连通域 Width1max(r)-min(r);%连通域宽度 Height1max(c)-min(c);%连通域高度 Radio1Width1/Height1;%连通域宽高比 Square1Width1*Height1;%连通域面积 Uheightmax(maxc,max(c1))-min(minc,min(c1));%合并后高度 Uwidthmax(maxr,max(r1))-min(minr,min(r1));%合并后宽度 UradioUwidth/Uheight;%合并后的宽高比 OheigthHeight0Height1-Uheight;%重叠高度 OwidthWidth0Width1-Uwidth;%重叠宽度 OsquareOheigth*Owidth;%重叠面积 else flag0;%这是这一行最后一个连通域 end ph5;%边界因子 pw7; if(flag1)((Owidth-(image_w/pw)Owidth0)||(Oheigth-(line_h*0.3)Oheigth0))%两个连通域较近但不重叠 if((Uradio0.8)(Uradio1.2))%认为两个连通域属于同一个字符 elseif Uheightline_h*0.4;%连通域的合并之后高度过小的认为是一个字符的一部分很可能是边旁部首 else flag0;%否则这两个连通域属于不同字符 end elseif(flag1)((Owidth0))%两连通域重叠 if(((Uradio0.78)(Uradio1.3)))%认为两个连通域属于同一个字符 elseif(Osquare0.4*min(Square0,Square1)(Uwidthimage_w/45)) else flag0;%两个连通域属于不同字符 end else flag0;%两个连通域属于不同字符 end if flag1%经过上面判断两个连通域属于同一个字符进行连通域合并 Width0Uwidth;%连通域宽度 Height0Uheight;%连通域高度 Radio0Width0/Height0;%连通域宽高比 Square0Width0*Height0;%连通域面积 maxrmax(maxr,max(r1)); maxcmax(maxc,max(c1)); minrmin(minr,min(r1)); mincmin(minc,min(c1)); nn1;%指向下一个连通域 char_flag1; end end %while(flag1)的end % Extract letter n1imgn(minr:maxr,minc:maxc); % Resize letter (same size of template) img_rimresize(n1,[36 23]); plot_flagplot_flag1; %Uncomment line below to see letters one by one % imshow(img_r);title(n);pause(0.5) %------------------------------------------------------------------- % Call fcn to convert image to text letterread_letter(img_r,num_letras); % Letter concatenation word[word letter]; nn1; end % while(nNe)的end %fprintf(fid,%s\n,lower(word));%Write word in text file (lower) set(handles.edit1,string,word); word[ ];