资源简介

车牌识别(基于模板匹配和神经网络),压缩包里包含神经网络的车牌识别算法、模板匹配的车牌识别算法、车牌字符模板、神经网络训练字符、参考文献

资源截图

代码片段和文件信息

%% 图像预处理
clear all;
image=imread(‘chepai2.jpg‘);
figure(1)subplot(331)imshow(image);title(‘原图‘);
I1=rgb2gray(image);
figure(1)subplot(332)imshow(I1);title(‘灰度图‘);
figure(1)subplot(333)imhist(I1);title(‘灰度图直方图‘);
I2=edge(I1‘sobel‘0.15‘both‘);
figure(1)subplot(334)imshow(I2);title(‘算子边缘检测‘);
se=[1;1;1];
I3=imerode(I2se);
figure(1)subplot(335)imshow(I3);title(‘腐蚀后图像‘);
se=strel(‘rectangle‘[2020]);
I4=imclose(I3se);
figure(1)subplot(336)imshow(I4);title(‘闭运算后‘);
I5=bwareaopen(I42000);
figure(1)subplot(337)imshow(I5);title(‘从对象中移除小对象‘);
se = strel(‘rectangle‘[50 80]);
I6 = imdilate(I5se);
figure(1)subplot(338);imshow(I6);title(‘膨胀处理‘);
%%

%% 定位车牌

%%%%%%%%%%%%%%%%%%%%%%%%%%%% 找出长宽比在2~4的区域 %%%%%%%%%%%%%%%%%%%%%%%%%%
ed=edge(I6);
L = bwlabel(I6);%标记连通域
L1 = bwlabel(ed);
p=zeros(1max(L1(:)));
for i=1:max(L(:))%得到连通域的长宽比
    p(i)=sum(ed(L==i));
    [yx]=find(L==i);
    x0=min(x(:));
    x1=max(x(:));
    y0=min(y(:));
    y1=max(y(:));
    bl=(x1-x0)/(y1-y0);
    if bl>2&&bl<4
        X0 = x0;
        X1 = x1;
        Y0 = y0;
        Y1 = y1;
    end
end
I7=imcrop(image[X0Y0X1-X0Y1-Y0]);
figure(1)subplot(339);imshow(I7);title(‘裁剪后图像‘);
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%% 根据蓝色像素点定位车牌位置%%%%%%%%%%%%%%%%%%%%%
[xyz]=size(I7);
% 以下为找车牌Y方向蓝色的范围
Blue_y=zeros(y1);% zeros(MN) 表示的是M行*N列的全0矩阵
for i=1:x    
    for j=1:y         
        if(I7(ij3)>(I7(ij1)+I7(ij2))&&(I7(ij3)>128))%% 判断蓝色像素           
            Blue_y(j1)= Blue_y(j1)+1;% 蓝色像素点统计          
        end       
    end       
end
PY1=1; 
while ((Blue_y(PY11)<10)&&(PY1    PY1=PY1+1;  %PY1是Y坐标方向蓝色范围的下限
end   
PY2=y; 
while ((Blue_y(PY21)<10)&&(PY2>PY1))        
    PY2=PY2-1; %PY2是Y坐标方向蓝色范围的上限
end   

% 以下为找车牌X方向蓝色的范围
Blue_x=zeros(1x);
for i=1:x     
    for j=1:y  % 只需扫描的行         
        if(I7(ij3)>(I7(ij1)+I7(ij2))&&(I7(ij3)>128)) %% 判断蓝色像素            
            Blue_x(1i)= Blue_x(1i)+1; % 蓝色像素点统计                      
        end      
    end   
end
PX1=1;
while ((Blue_x(1PX1)<5)&&(PX1       PX1=PX1+1; %PX1是X坐标方向蓝色范围的下限
end    
PX2=x;
while ((Blue_x(1PX2)<3)&&(PX2>PX1)) 
       PX2=PX2-1; %PX2是X坐标方向蓝色范围的上限
end    
I8=I7(PX1:PX2PY1:PY2:);% 裁剪图像
figure(2);imshow(I8)title(‘定位剪切后的彩色车牌图像‘);
%% 

%% 倾斜矫正

I9=rgb2gray(I8);
figure(4)subplot(221);imshow(I9);title(‘灰度图‘);
I10=edge(I9);
figure(4)subplot(222);imshow(I10);title(‘边缘检测‘);
theta=1:180;    
[Rxp]=radon( I10theta);
[I0J]=find(R>=max(max(R)));%找倾斜角
qxj=90-J;
I11=imrotate(I8qxj‘bilinear‘‘crop‘);
figure(4)subplot(223);imshow(I8);title(‘原图‘);
figure(4)subplot(224);imshow(I11);title(‘倾斜矫正‘);
thresh = graythresh(I9);     %自动确定二值化阈值;
I12 = im2bw(I9thresh); 
figure(5)subplot(121);imshow(I12);title(‘二值化‘);
I13=imrotate(I12qxj‘bilinear‘‘crop‘);
figure(5)subplot(122);imshow(I13);t

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-12-07 16:44  周鹏-2019250068-机电学院-车牌识别\
     目录           0  2019-12-07 16:29  周鹏-2019250068-机电学院-车牌识别\charSamples\
     目录           0  2019-12-07 16:29  周鹏-2019250068-机电学院-车牌识别\charSamples\0\
     文件         376  2013-11-07 08:35  周鹏-2019250068-机电学院-车牌识别\charSamples\0\10_0.792674_gray_14967_5950_step5_recog_4_0_0.890217_0.705652.png
     文件         413  2013-11-10 08:12  周鹏-2019250068-机电学院-车牌识别\charSamples\0\11_0.971377_gray_20751_8531_step5_recog_4_0_0.996446_0.967925.png
     文件         413  2013-11-09 08:47  周鹏-2019250068-机电学院-车牌识别\charSamples\0\12_0.953826_gray_975_407_step5_recog_5_0_0.987086_0.941508.png
     文件         376  2013-11-06 07:31  周鹏-2019250068-机电学院-车牌识别\charSamples\0\13_0.924615_gray_5457_2092_step5_recog_6_0_0.987233_0.912810.png
     文件         413  2013-11-07 10:29  周鹏-2019250068-机电学院-车牌识别\charSamples\0\14_0.749970_gray_17934_7138_step5_recog_4_0_0.787806_0.590831.png
     文件         398  2013-11-07 01:38  周鹏-2019250068-机电学院-车牌识别\charSamples\0\15_0.877296_gray_8040_2899_step5_recog_4_0_0.969689_0.850704.png
     文件         390  2013-11-09 16:11  周鹏-2019250068-机电学院-车牌识别\charSamples\0\16_0.949891_gray_12542_5631_step5_recog_5_0_0.989526_0.939942.png
     文件         413  2013-11-05 23:09  周鹏-2019250068-机电学院-车牌识别\charSamples\0\17_0.906434_gray_1645_517_step5_recog_3_0_0.985269_0.893081.png
     文件         413  2013-11-04 07:38  周鹏-2019250068-机电学院-车牌识别\charSamples\0\18_0.494551_gray_4696_2106_step5_recog_5_D_0.340885_0.168585.png
     文件         413  2013-11-10 17:49  周鹏-2019250068-机电学院-车牌识别\charSamples\0\19_0.968513_gray_35240_14963_step5_recog_4_0_0.994962_0.963633.png
     文件         390  2013-11-05 11:37  周鹏-2019250068-机电学院-车牌识别\charSamples\0\1_0.822474_gray_13564_5332_step5_recog_2_0_0.891312_0.733081.png
     文件         452  2013-11-07 09:17  周鹏-2019250068-机电学院-车牌识别\charSamples\0\20_0.737201_gray_16436_6504_step5_recog_3_0_0.828133_0.610500.png
     文件         328  2013-11-09 09:13  周鹏-2019250068-机电学院-车牌识别\charSamples\0\21_0.750968_gray_1741_702_step5_recog_5_0_0.724394_0.543997.png
     文件         578  2013-11-06 07:23  周鹏-2019250068-机电学院-车牌识别\charSamples\0\22_0.610848_gray_4813_1822_step5_recog_6_0_0.772820_0.472076.png
     文件         429  2013-11-08 21:58  周鹏-2019250068-机电学院-车牌识别\charSamples\0\23_0.976079_gray_9338_3994_step5_recog_4_0_0.996512_0.972675.png
     文件         404  2013-11-05 10:21  周鹏-2019250068-机电学院-车牌识别\charSamples\0\24_0.876098_gray_12240_4810_step5_recog_6_0_0.960593_0.841573.png
     文件         398  2013-11-10 13:17  周鹏-2019250068-机电学院-车牌识别\charSamples\0\25_0.978677_gray_28271_11796_step5_recog_3_0_0.997614_0.976341.png
     文件         845  2013-11-07 07:07  周鹏-2019250068-机电学院-车牌识别\charSamples\0\26_0.915550_gray_9737_3597_step5_recog_6_0_0.984816_0.901648.png
     文件         413  2013-11-06 16:41  周鹏-2019250068-机电学院-车牌识别\charSamples\0\27_0.942230_gray_2943_1159_step5_recog_4_0_0.982740_0.925967.png
     文件         390  2013-11-06 07:09  周鹏-2019250068-机电学院-车牌识别\charSamples\0\28_0.845480_gray_4035_1484_step5_recog_2_0_0.902136_0.762738.png
     文件         436  2013-11-07 08:11  周鹏-2019250068-机电学院-车牌识别\charSamples\0\29_0.736003_gray_13772_5440_step5_recog_4_0_0.816986_0.601304.png
     文件         413  2013-11-04 17:45  周鹏-2019250068-机电学院-车牌识别\charSamples\0\2_0.734930_gray_10773_4652_step5_recog_6_0_0.932386_0.685239.png
     文件         595  2013-11-08 12:21  周鹏-2019250068-机电学院-车牌识别\charSamples\0\30_0.669019_gray_4754_2801_step5_recog_4_0_0.669949_0.448209.png
     文件         443  2013-11-04 11:41  周鹏-2019250068-机电学院-车牌识别\charSamples\0\31_0.941303_gray_3574_1589_step5_recog_5_0_0.991813_0.933597.png
     文件         390  2013-11-10 14:35  周鹏-2019250068-机电学院-车牌识别\charSamples\0\32_0.910823_gray_30504_12844_step5_recog_2_0_0.938536_0.854839.png
     文件         413  2013-11-09 00:43  周鹏-2019250068-机电学院-车牌识别\charSamples\0\33_0.944410_gray_10675_4406_step5_recog_5_0_0.977869_0.923509.png
     文件         443  2013-11-04 10:34  周鹏-2019250068-机电学院-车牌识别\charSamples\0\34_0.913401_gray_2467_1090_step5_recog_3_0_0.986072_0.900679.png
     文件         376  2013-11-05 07:53  周鹏-2019250068-机电学院-车牌识别\charSamples\0\35_0.908210_gray_6976_2539_step5_recog_4_0_0.974391_0.884952.png
............此处省略1795个文件信息

评论

共有 条评论