车牌识别之识别与分割
Posted 女王公园的八神
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了车牌识别之识别与分割相关的知识,希望对你有一定的参考价值。
1.定位,主要就是根据颜色特征,中国的车牌大都是蓝牌的,也就用这种最典型的了
2.分割,分割首先还是建立在第一步基础上,然后是用位置和投影来进行分割
哇,注释全乱了。。。。。。。
clear all; pic=imread(‘1.jpg‘); figure;subplot(1,4,1);imshow(pic);title(‘original image‘) % subplot ??????m*n?????????p???,p=1????????? [ysize,xsize,zsize]=size(pic);%???????????????????????? %ysize?xsize???????zsize???????? pic_r=double(pic(:,:,1));%????????? pic_g=double(pic(:,:,2)); pic_b=double(pic(:,:,3)); for(i=1:ysize) for (j=1:xsize) mean(i,j)=(pic_r(i,j)+pic_g(i,j)+pic_b(i,j))/3;%??????? blue(i,j)=pic_b(i,j)-mean(i,j); if(blue(i,j)>30) blue0(i,j)= 1; else blue0(i,j)=0; end end end subplot(1,4,2);imshow(blue0);title(‘blue0‘) h=[1 1 1 1]; blue1=filter2(h,blue0);%??????????????h??????????? for(i=1:ysize) for(j=1:xsize) if blue1(i,j)>=1 blue1(i,j)=1; else blue1(i,j)=0; end end end blue2=bwareaopen(blue1,1000); %BW2 = bwareaopen(BW,P,conn) ??????BW?????P?????????conn??8?? subplot(1,4,3);imshow(blue1);title(‘blue1‘) subplot(1,4,4);imshow(blue2);title(‘blue2‘) xsize1=uint16(0.1*xsize); xsize2=uint16(0.9*xsize);%xsize????? ysize1=uint16(0.4*ysize);%ysize?????? ysize2=uint16(ysize); x=zeros(1,xsize);%????1???xsize??0?? y=zeros(1,ysize); for(i=ysize1:ysize2) for(j=xsize1:xsize2) if blue2(i,j)>0 x(j)=x(j)+1; y(i)=y(i)+1; end end end figure;subplot(2,2,1);plot(x);title(‘x‘); subplot(2,2,2);plot(y) ;title(‘y‘); for(i=1:ysize) if y(i)>=1 yy(i)=1;%?????????????? else yy(i)=0; end end for(j=1:xsize) if x(j)>=1 xx(j)=1; else xx(j)=0; end end subplot(2,2,3);plot(xx);title(‘xx‘); subplot(2,2,4);plot(yy) ;title(‘yy‘); for(i=1:ysize-1) if(yy(i)==1&yy(i+1)==0) y2=i; end end for(i=ysize-1:-1:1) if(yy(i)==0&yy(i+1)==1) y1=i; end end h=y2-y1; for(j=1:xsize-1); if(xx(j)==1&xx(j+1)==0) x2=j; end end for(j=xsize-1:-1:1); if (xx(j)==0&xx(j+1)==1) x1=j; end end w=x2-x1; for (m=1:h) for(n=1:w) lp_rgb(m,n,:)=pic(m+y1,n+x1,:); end end figure;subplot(2,3,1);imshow(lp_rgb); lp_resize = imresize(lp_rgb,[34,113],‘nearest‘); lp_gray=rgb2gray(lp_resize); subplot(2,3,2);imshow(lp_gray); mean=mean2(lp_gray); for(i=1:34) for(j=1:113) if lp_gray(i,j)>=mean; lp_b1(i,j)=1; else lp_b1(i,j)=0; end end end subplot(2,3,3);imshow(lp_b1); lp_b2=bwareaopen(lp_b1,6); subplot(2,3,4);imshow(lp_b2); lp_b=bwmorph(lp_b2,‘thin‘); subplot(2,3,5);imshow(lp_b); for(m=1:26) for(n=1:113) if(n>1&n<=16); cha1(m,n-1)=lp_b(m+4,n); elseif(n>16&n<=31); cha2(m,n-16)=lp_b(m+4,n); elseif(n>37&n<=52); cha3(m,n-37)=lp_b(m+4,n); elseif(n>52&n<=67); cha4(m,n-52)=lp_b(m+4,n); elseif(n>67&n<=82); cha5(m,n-67)=lp_b(m+4,n); elseif(n>82&n<=97); cha6(m,n-82)=lp_b(m+4,n); elseif(n>97&n<=112); cha7(m,n-97)=lp_b(m+4,n); end end end figure;subplot(1,7,1);imshow(cha1); subplot(1,7,2);imshow(cha2); subplot(1,7,3);imshow(cha3); subplot(1,7,4);imshow(cha4); subplot(1,7,5);imshow(cha5); subplot(1,7,6);imshow(cha6); subplot(1,7,7);imshow(cha7);
以上是关于车牌识别之识别与分割的主要内容,如果未能解决你的问题,请参考以下文章
车牌识别模板匹配新能源轿车货车车牌识别含GUI Matlab源码 2169期
车牌识别基于matlab GUI模板匹配新能源轿车货车车牌识别含Matlab源码 2169期