基于matlab车牌的定位与分割识别程序文件.doc

上传人:scccc 文档编号:12060957 上传时间:2021-12-01 格式:DOC 页数:18 大小:403KB
返回 下载 相关 举报
基于matlab车牌的定位与分割识别程序文件.doc_第1页
第1页 / 共18页
基于matlab车牌的定位与分割识别程序文件.doc_第2页
第2页 / 共18页
基于matlab车牌的定位与分割识别程序文件.doc_第3页
第3页 / 共18页
基于matlab车牌的定位与分割识别程序文件.doc_第4页
第4页 / 共18页
基于matlab车牌的定位与分割识别程序文件.doc_第5页
第5页 / 共18页
点击查看更多>>
资源描述

《基于matlab车牌的定位与分割识别程序文件.doc》由会员分享,可在线阅读,更多相关《基于matlab车牌的定位与分割识别程序文件.doc(18页珍藏版)》请在三一文库上搜索。

1、专业资料基于Matlab的车牌定位与分割经典算法匸imread('car.jpg');%读取图像word完美格式figure。; subplot(3,2,1),imshow(l), title('原始图像');I仁rgb2gray(l);%转化为灰度图像subplot(3,2,2),imshow(I1),title('灰度图像');灰度图像I2=edge(I1,'robert',0.09,'both');%缘检测采用robert算子进行边subplot(3,2,3),imshow(l2),title('边缘

2、检测后图像');边缘检测方se=1;1;1; %线型结构元素I3=imerode(l2,se); %腐蚀图像subplot(3,2,4),imshow(I3),title('腐蚀后边缘图像');se=strel('recta ngle',25,25);矩形结构元素I4=imclose(l3,se);%图像聚类、填充图像subplot(3,2,5),imshow(I4),title('填充后图像');I5=bwareaopen(l4,2000);% 去除聚团灰度值小于2000的部分 subplot(3,2,6),imshow(l5),tit

3、le('形态滤波后图像');形吉滤波启y,x,z=size(l5);I6=double(I5);Y 1=zeros(y,1);for i=1:yfor j=1:xif(l6(i,j,1)=1)Y 1(i,1)= Y 1(i,1)+1;endendendtemp Max Y=max( Y1);figure();subplot(3,2,1),plot(0:y-1, Y1),title('行方向像素点灰度值累计和'),xlabel(' 行值'),ylabel(' 像素');行債%求的车牌的行起始位置和终止位置PY 仁Max Y;whil

4、e (Y 1(P Y1,1)>=50)&&(PY 1>1)PY 1=P Y1-1;endPY 2=Max Y;while (Y 1(P Y2,1)>=50)&&(PY 2<y)PY 2=P Y2+1;endIY =I(P Y1:P Y2,:,:);X1=zeros(1,x);for j=1:xfor i=P Y1:P Y2if(l6(i,j,1)=1)X1(1,j)= X1(1,j)+1;endend endsubplot(3,2,2),plot(0:x-1,X1),title('列方向像素点灰度值累计和'),xlabel

5、(' 列值'),ylabel(' 像数');歹U方向像素点挟度值累计和%求的车牌的列起始位置和终止位置PX1=1;while (X1(1,PX1)<3)&&(PX1<x)PX1=PX1+1;endPX2=x;while (X1(1,PX2)<3 )&&(PX2>PX1)PX2=PX2-1;endPX1=PX1 -1;PX2=PX2+1;%分割出车牌图像% dw=l(P Y1:P Y2,PX1:PX2,:);subplot(3,2,3),imshow(dw),title('定位剪切后的彩色车牌图像&#

6、39;)定位剪切后的彩色车牌图傢4.2车牌字符分割确定车牌位置后下一步的任务就是进行字符切分分离出车牌号 码的全部字符图像。if isrgb(I)I1 = rgb2gray(I); %将RG图像转化为灰度图像else I1=l ; endg_max=double(max(max(l1);g_mi n=double(mi n(min (11);T=rou nd(g_max-(g_max-g_mi n)/3); % T为二值化的阈值m, n=size(I1);% d:二值图像%h=graythresh(I1);I仁im2bw(l1,T/256);subplot(3,2,4);imshow(l1),

7、title('二值化车牌图像');二值化车牌图像I2=bwareaope n( 11,20);subplot(3,2,5);imshow(I2),title('形态学滤波后的二值化图像');中值滤波后的二值化图像y1,x1,z1=size(l2);I3=double(I2);TT=1;%除图像顶端和底端的不感兴趣区域%Y1=zeros(y1,1);for i=1:y1for j=1:x1if(l3(i,j,1)=1)Y 1(i,1)= Y 1(i,1)+1 ;endendendPy 1=1;PyO=1;while (Y 1(Py0,1)<20)&&

8、amp;(PyO<y1)PyO=PyO+1;endPy1= Py0;while(Y1(Py1,1)>=20)&&(Py1<y1)Py1= Py1+1;endI2=I2(Py0:Py1,:,:);subplot(3,2,6);imshow(l2),title(' 目标车牌区域');目标车牌区域%分割字符按行积累量%X1=zeros(1,x1);for j=1:x1for i=1:y1if(l3(i,j,1)=1)X1(1,j)= X1(1,j)+1;endendendfigure®plot(0:x1-1,X1),title('列

9、方向像素点灰度值累计和'),xlabel(' 列值'),ylabel(' 累计像素量');Px0=1;Px 1=1;%分割字符 for i=1:7while (X1(1,PxO)<3)&&(PxO<x1)PxO=PxO+1;endPx仁 Px0;while (X1(1,Px1)>=3)&&(Px1<x1)|(Px1 -Px0)<10)Px1=Px1+1;endZ=l2(:,PxO:Px1,:);switch strcat('Z', nu m2str(i)case 'Z1

10、'PIN0=Z;case 'Z2'PIN 仁Z;case 'Z3'PIN2=Z;case 'Z4'PIN3=Z;case 'Z5'PIN4=Z;case 'Z6'PIN5=Z;otherwisePIN6=Z; end figure(3); subplot(1,7,i); imshow(Z);PxO=Px1;Endfun cti on inpt = pretreatme nt(l)%Y UCHULI Summary of this fun ctio n goes here% Detailed expla na

11、ti on goes hereif isrgb(I)I1 = rgb2gray(l);elseI1=I;endI仁imresize(l1,50 20);%将图片统一划为 50*20大小I1=im2bw(I1,0.9);m,n=size(I1);in pt=zeros(1,m* n);%各图像按列转换成一个行向量for j=1: nfor i=1:min pt(1,m*(j-1)+i)=l1(i,j);endend%神经网络进行识别。close all;clear all;%一化训练样本%I0=pretreatme nt(imread('O.jpg');I1=pretreatme

12、 nt(imread('1.jpg');I2=pretreatme nt(imread('2.jpg');I3=pretreatme nt(imread('3.jpg');I4=pretreatme nt(imread('4.jpg');I5=pretreatme nt(imread('5.jpg');I6=pretreatme nt(imread('6.jpg');I7=pretreatme nt(imread('7.jpg');I8=pretreatme nt(imread(&#

13、39;8.jpg');I9=pretreatme nt(imread('9.jpg');I10=pretreatme nt(imread('A.jpg');I11=pretreatme nt(imread('C.jpg');I12=pretreatme nt(imread('G.jpg');I13=pretreatme nt(imread('L.jpg');I14=pretreatme nt(imread('M.jpg');I15=pretreatme nt(imread('R.jp

14、g');I16=pretreatme nt(imread('H.jpg');I17=pretreatme nt(imread('N.jpg');P=IO',I1',I2',I3',I4',I5',I6',I7',I8',I9',I1O',I11',I12',I13',I14',I15',I16',I17'%输出样本%T=eye(18,18);%b神经网络参数设置net=newff(mi nm ax(P),1000

15、,32,18,'logsig','logsig','logsig','trai nrp');n et.i nputWeights1,1.i nitFc n ='ra ndnr:n et.layerWeights2,1.i nitFc n ='ra ndnr:n et.tra in param.epochs=5000;n et.tra in param.show=50;%n et.tra in param.lr=0.003;net.trai nparam.goal=0.0000000001;n et=i nit( n

16、et);%训练样本%n et,tr=trai n(n et,P,T);%测试%l=imread('DSC01323.jpg');匸imread('DSC01344.jpg');dw=locatio n(l);%车牌定位PIN0,PIN1,PIN2,PIN3,PIN4,PIN5,PIN6=Stri ngSplit(dw);%字符分割及处理%测试字符,得到识别数值%PINO=pretreatme nt(PINO);PIN1=pretreatme nt(PIN1);PIN2=pretreatme nt(PIN2);PIN3=pretreatme nt(PIN3);PI

17、N4=pretreatme nt(PIN4);PIN5=pretreatme nt(PIN5);PIN6=pretreatme nt(PIN6);P0=PIN0',PIN1',PIN2',PIN3',PIN4',PIN5',PIN6'for i=2:7T0= sim( net ,P0(:,i);T1 = compet (T0);d =find(T1 = 1) - 1if (d=10)str='A:elseif (d=11)str=C;elseif (d=12)str='G:elseif (d=13) str='L:

18、elseif (d=14) str='M:elseif (d=15)str='R:elseif (d=16)str='H:elseif (d=17)str='N:elsestr=nu m2str(d);endswitch icase 2str仁str;case 3str2=str;case 4str3=str;case 5str4=str;case 6str5=str;otherwisestr6=str;endend%显示定位后的分割出的车牌彩图,%渝 AN7968id%结果以标题形式显示在图上%s=strcat(' 渝',str1,str2,str3,str4,str5,str6);figure。;imshow(dw),title(s);非诚勿扰欢迎下载

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1