1、bw=Plate;figure,imshow(bw);车牌图像%hsv彩图提取图像%=这里要根据图像的倾斜度进行选择这里选择的图片20090425686.jpgbw=rgb2gray(bw);灰度图像%=倾斜校正=qingxiejiao=rando_bianhuan(bw)bw=imrotate(bw,qingxiejiao,bilinearcrop倾斜校正%取值为负值向右旋转%=bw=im2bw(bw,graythresh(bw);%figure,imshow(bw);bw=bwmorph(bw,hbreak,inf);spur擦除之前open,5);闭合运算bw = bwareaopen(
2、bw, threshold);擦除%=加入进度条=% h=waitbar(0,程序运行中,请稍等.)% for i=1:10000% waitbar(i/5000,h) % end% close(h);%wavplay(wavread(程序运行中.wav),22000);bw=bw;擦除反色 %=对图像进一步裁剪,保证边框贴近字体=bw=touying(bw);imshow(bw);Y方向处理二次擦除y,x=size(bw);%对长宽重新赋值%=文字分割=fenge=shuzifenge(bw,qingxiejiao)m,k=size(fenge);%=显示分割图像结果= for s=1:2:
3、k-1 subplot(1,k/2,(s+1)/2);imshow(bw( 1:y,fenge(s):fenge(s+1);end%= 给七张图片定位=桂AV6388han_zi =bw( 1:y,fenge(1):fenge(2);zi_mu =bw( 1:y,fenge(3):fenge(4);zm_sz_1 =bw( 1:y,fenge(5):fenge(6);zm_sz_2 =bw( 1:y,fenge(7):fenge(8);shuzi_1 =bw( 1:y,fenge(9):fenge(10);shuzi_2 =bw( 1:y,fenge(11):fenge(12);shuzi_3
4、 =bw( 1:y,fenge(13):fenge(14);%=识别=%=把修正数据读入=xiuzhenghanzi = imresize(han_zi, 110 55,xiuzhengzimu = imresize(zi_mu, 110 55,xiuzhengzm_sz_1= imresize(zm_sz_1,110 55,xiuzhengzm_sz_2 = imresize(zm_sz_2,110 55,xiuzhengshuzi_1 = imresize(shuzi_1,110 55,xiuzhengshuzi_2 = imresize(shuzi_2,110 55,xiuzhengsh
5、uzi_3 = imresize(shuzi_3,110 55,%= 把0-9 , A-Z以及省份简称的数据存储方便访问=hanzishengfen=duquhanzi(imread(cpgui.bmp),imread(cpguizhou.bmpcpjing.bmpcpsu.bmpcpyue.bmp);%因数字和字母比例不同。这里要修改shuzizimu=duquszzm(imread(0.bmp1.bmp2.bmp3.bmp4.bmp),. imread(5.bmp6.bmp7.bmp8.bmp9.bmp10.bmp11.bmp12.bmp13.bmp14.bmp15.bmp16.bmp17
6、.bmp18.bmp19.bmp20.bmp21.bmp22.bmp23.bmp24.bmp25.bmp26.bmp27.bmp28.bmp29.bmp30.bmp31.bmp32.bmp33.bmpzimu = duquzimu(imread(shuzi = duqushuzi(imread(%=识别结果= i=1;%shibiezm_sz该函数识别数字有问题jieguohanzi = shibiehanzi(hanzishengfen,xiuzhenghanzi);shibiejieguo(1,i) =jieguohanzi; i=i+1;jieguozimu = shibiezimu(z
7、imu,xiuzhengzimu); shibiejieguo(1,i) =jieguozimu;jieguozm_sz_1= shibiezm_sz(shuzizimu,xiuzhengzm_sz_1); shibiejieguo(1,i) =jieguozm_sz_1;i=i+1;jieguozm_sz_2= shibiezm_sz(shuzizimu,xiuzhengzm_sz_2); shibiejieguo(1,i) =jieguozm_sz_2;jieguoshuzi_1= shibieshuzi(shuzi,xiuzhengshuzi_1); shibiejieguo(1,i)
8、=jieguoshuzi_1;jieguoshuzi_2= shibieshuzi(shuzi,xiuzhengshuzi_2); shibiejieguo(1,i) =jieguoshuzi_2;jieguoshuzi_3= shibieshuzi(shuzi,xiuzhengshuzi_3); shibiejieguo(1,i) =jieguoshuzi_3;%=对话框显示显示=shibiejieguo%=后面的注释掉了(语音读出这一部分)=msgbox(shibiejieguo,识别结果% %=导出文本=% fid=fopen(Data.xlsa+% fprintf(fid,%srn,s
9、hibiejieguo,datestr(now);% fclose(fid);% %=读出声音=% duchushengyin(shibiejieguo);%=读取计时=t=toc %记录程序运行时间%=自己编写的子函数function bw_fir = touying(imane_bw)X_yuzhi=1;y,x=size(imane_bw);Y_touying=(sum(imane_bw);%往左边投影统计黑点X_touying=sum(imane_bw);%往下面投影%找黑体边缘Y_up=fix(y/2);Y_yuzhi=mean(Y_touying(fix(y/2)-10):(fix(
10、y/2)+10),1)/1.6;while (Y_touying(Y_up,1)=Y_yuzhi)&(Y_up1)%找到图片上边界 Y_up=Y_up-1;end Y_down=fix(y/2);while (Y_touying(Y_down,1)(Y_downy)%找到图片上边界 Y_down=Y_down+1;%去除左边边框干扰 X_right=1;if (X_touying(1,fix(x/14)=X_yuzhi X_right=fix(x/14)bw_fir=imane_bw(Y_up:Y_down,X_right:x);function fenge = shuzifenge(imfe
11、nge,qingxiejiao)y,x=size(imfenge);%=用函数设定分割阈值=SS=x*yif SS20000&SS=3000030000&=5000050000&=80000elseganrao=SS/100;%=%定义数组histogram存储垂直方向的黑点数histogram=sum(imfenge);%=文字分割=k=1;for h=1:x-1 if (histogram(1,h)shedingyuzhi)|(h=1)&histogram(1,h)shedingyuzhi) fenge(1,k)=h; k=k+1; elseif (histogram(1,h)shedin
12、gyuzhi)&(histogram(1,h+1)=shedingyuzhi)|(h=x-1)& fenge(1,k)=h+1; endk=k-1;%去掉多产生的一个K值if k10 msgbox(提取出错警告 wavplay(wavread(提取出错.wav pause;if (sum(histogram(1,fenge(1,1):fenge(1,2)ganrao)|(fenge(1,2)-fenge(1,1)(fenge(1,4)-fenge(1,3)/2) for i=3:k fenge(1,i-2)=fenge(1,i);m n=size(fenge);if n=max(baifenb
13、i);chepai=chepai(1,1);%=数字直接返回=if (chepai=1)&(chepai=11)&=34)%=字母对应序号转字母=%=11-15 ABCDE 16-20FGHIJ 21-25 KLMNP 26-30 QRSTU 31-35 VWXYZ if chepai=11 zm_sz=A elseif chepai=12B elseif chepai=13C elseif chepai=14D elseif chepai=15E elseif chepai=16F elseif chepai=17G elseif chepai=18H elseif chepai=19J elseif chepai=20K elseif chepai=21L elseif chepai=22M elseif chepai=23N elseif chepai=24P elseif chepai=25Q elseif chepai=26R elseif chepai=27S elseif chepai=28T elseif chepai=29U elseif chepai=30V elseif chepai=31W elseif chepai=32X elseif chepai=33Y elseif chepai=34Zshibiezm_sz=zm_sz; zm_sz
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2