车牌分析及处理办法便于车牌的确定

时间:2012-01-22 18:09:07
【文件属性】:

文件名称:车牌分析及处理办法便于车牌的确定

文件大小:4KB

文件格式:TXT

更新时间:2012-01-22 18:09:07

车牌

进行车牌定位和识别 clear; clc; close all; chos=0; possibility=5; while chos~=possibility, %%%%%%%%%%%%%%%%%%%%%%%%%制作操作栏%%%%%%%%%%%%%%%%%% chos=menu('车牌定位系统','载入图片','图象处理','图象分割','车牌号码识别','退出'); if chos==1, clc; [namefile,pathname]=uigetfile('*.jpg','Select image'); if namefile~=0 I=imread(strcat(pathname,namefile)); imshow(I); end end %二值化 if chos==2, I1=rgb2gray(I); %边缘化 I2=edge(I1,'robert',0.15,'both'); %腐蚀 se=[1;1;1]; I3=imerode(I2,se); %连通 se=strel('rectangle',[25,25]); I4=imclose(I3,se); %滤波 I5=bwareaopen(I4,1500); imshow(I5); [y,x,z]=size(I5); myI=I5; %定位 %%%%%%%%%%% 统计分析 %%%%%%%%%%%%%%% %%%%%%%% Y 方向 %%%%%%%%%% whitr_y=zeros(y,1); for i=1:y for j=1:x if(myI(i,j,1)==1) % 白色RGB的灰度范围 whitr_y(i,1)= whitr_y(i,1)+1; % 白色象素点统计 end end end [temp MaxY]=max(whitr_y); % Y方向车牌区域确定 PY1=MaxY; while ((whitr_y(PY1,1)>=5)&&(PY1>1)) PY1=PY1-1; end PY2=MaxY; while ((whitr_y(PY2,1)>=5)&&(PY2PX1)) PX2=PX2-1; end Plate=I(PY1-13:PY2+13,PX1-5:PX2+5,:);%预留多些利于倾斜校正 % t=toc % 读取计时 ;imshow(Plate);title('Plate'); end if chos==3, I8=rgb2gray(Plate); %%%%%%%根据直方图 %subplot(2,2,1);imshow(I8);title('原始图像'); %subplot(2,2,2);imhist(I8);title('直方图像'); bw_160=I8>160; %subplot(2,2,3);imshow(bw_160);title('取阈值160图像'); bw_210=I8>210; %subplot(2,2,4);imshow(bw_210);title('取阈值210图像'); [r,c]=find(bw_210==0); bw=bwselect(~bw_160,c,r,8); figure,imshow(bw); title('分割图像'); word1=bw(14:53,6:30); word2=bw(14:53,34:58); word3=bw(14:53,60:84); word4=bw(14:53,113:137); word5=bw(14:53,140:164); word6=bw(17:56,166:190); subplot(2,3,1);imshow(word1);title('1'); subplot(2,3,2);imshow(word2);title('2'); subplot(2,3,3);imshow(word3);title('3'); subplot(2,3,4);imshow(word4);title('4'); subplot(2,3,5);imshow(word5);title('5'); subplot(2,3,6);imshow(word6);title('6'); end if chos==4 g=uint8(word1)*255; for i=1:36 w=strcat('E:\work\moban1\',num2str(i),'.jpg');%所放的摸版位置 n=imread(w); n=rgb2gray(n); s=g-n s=sum(s) r(i)=sum(s) end m=min(r); for i=1:36 if m==r(i) q=strcat('E:\work\moban1\',num2str(i),'.jpg');%所放的摸版位置 qq=imread(q); figure,imshow(qq); end end end end


网友评论