收藏 分享(赏)

车牌识别程序(License plate recognition program).doc

上传人:dzzj200808 文档编号:5749170 上传时间:2019-03-15 格式:DOC 页数:21 大小:44.50KB
下载 相关 举报
车牌识别程序(License plate recognition program).doc_第1页
第1页 / 共21页
车牌识别程序(License plate recognition program).doc_第2页
第2页 / 共21页
车牌识别程序(License plate recognition program).doc_第3页
第3页 / 共21页
车牌识别程序(License plate recognition program).doc_第4页
第4页 / 共21页
车牌识别程序(License plate recognition program).doc_第5页
第5页 / 共21页
点击查看更多>>
资源描述

1、车牌识别程序(License plate recognition program)%功能D = main()关闭所有清空命令窗口的所有输入和输出 CLC %,类似于清屏%自动弹出提示框读入图像文件名,文件路径 =交互式(“.jpg” 、“输入一个需要识别的车牌图像) ;直接自动读入% %文件= strcat(,文件名) ;%将函数:连接字符串;把文件路径文件名的连接的字符串与,即路径/文件名我= imread(car .jpg” ) ;图(name, “原图) ,imshow(I) ;标题(“原图” )%图像增强% h =人(5,5)/ 25;%过滤器 H%我= imfilter(I,H) ;

2、%真彩色增强%图(name, “真彩色增强) ;imshow(I) ;标题(“真彩色增强” );I1 = rgb2gray(我) ;%的 RGB图像转灰度图像图(name, “灰度处理前) ,情节(1,2,1) ,imshow(I1) ;标题(“灰度处理前的灰度图” ) ;subplot(1,2,2) ,imhist(I1) ;标题(“灰度处理前的灰度图直方图” ) ;%线性灰度变换I1 = imadjust(I1,0.3,0.7 , ) ;图(name, “灰度处理后) ,情节(1,2,1) ,imshow(I1) ;标题(“灰度处理后的灰度图” ) ;subplot(1,2,2) ,imh

3、ist(I1) ;标题(“灰度处理后的灰度图直方图” ) ;%进行中值滤波I1 = medfilt2(I1) ;图,imshow(I1) ;标题(“中值滤波” ) ;%边缘检测:Sobel、罗伯茨、精明,prewitt等i2 = edge (i1, “roberts“, 0.25, both);% 边缘检测算法, 强度小于阈值 0.15的边缘被省略掉, both 两个方向检测 (缺省默认)figure (“name“, “边缘检测 ), imshow (i2); title ( robert算子边缘检测 )it = 1; 1; 1;i3 = imerode (i2, i);% 腐蚀 imero

4、de (x, i).其中 x是待处理的图像, se 是结构元素对象figure (“name“, “腐蚀后图像 ), imshow (i3); title ( 腐蚀后的图像 );it = strel (“rectangle , 20,20);% 25x25的矩形 strel? ?imclose (i3, i4 = it);% 用 25 * 25的矩形对图像进行闭运算 (先膨胀后腐蚀) 有平滑边界作用figure (“name“, “平滑处理 ), imshow (i4); title ( 平滑图像的轮廓 );i5 = bwareaopen (i41000);% 从二进制图像中移除所有少于 20

5、00像素的连接对象, 消失的是连续的白色像素数量少于 2000的字符figure (“name“, “移除小对象 ), imshow (i5); title ( 从对象中移除小对象 );y, x, z = size (i5);% y是行数, x 是列数, z 是维数sold = double (i5);% 转成双精度型tic% 开始计时blue _ y = zeros (y, 1);% zeros (m, n) 表示的是 m行 * n 列的全 0矩阵for i = 1: yfor j = 1: xif (sold (i, j, 1) = = 1)% 判断蓝色像素blue _ y (i, 1)

6、= blue _ y (i, 1) + 1;%蓝色像素点统计结束结束结束温糯 =最大(blue_y) ;% y 方向车牌区域确定温度临时变量糯糯PY1 =糯;%以下为找车牌 Y方向最小值而(blue_y(py1,1) = 5)PX2=PX2+3;PY2=PY2+10;Dw=I (PY1:PY2-8, PX1:PX2:):% cropped imagesTOC%t=toc;% stop time%figure (7), subplot (1,2,1), imshow (IY), title ( line direction, reasonable region );Figure (name, l

7、ocate, post cut color license plate images),%subplot (1,2,2),Imshow (DW), title (locate color image of license plate after shearing)Imwrite (DW,dw.jpg);% automatically reads%filename automatically, filepath=uigetfile (dw.jpg, enter a location clipping image of the license plate);%jpg=strcat (filepat

8、h, filename);% strcat function: connect string; connect filepath string to filename, that is path / file nameA=imread (dw.jpg);B=rgb2gray (a);Imwrite (B,1. license plate grayscale image.Jpg);Figure (name, license plate processing ), subplot (3,2,1), imshow (b), title (1. license plate gray image)%g_

9、max=double (max (max (b). Threshold below% (grayscale to two values)%g_min=double (min (min (b); the maximum value of each column for% max (a) is one dimensional data; max (max (a) is the maximum value for this one-dimensional data.%T=round (g_max- (g_max-g_min) /2);% T two threshold round: round%m,

10、 n=size (b); row vector number of% m:b row vector number of n:b% =(双(B) = T) ;D:二值图像% imwrite(d,2。车牌二值图像.jpg” ) ;%线性灰度变换B = imadjust(B, 0.3,0.7 , ) ;subplot(3,2,2) ,imshow(B) ;(2 线性灰度处理后的灰度图”称号。 ) ;%进行二值化处理a im2bw(B,0.4) ;%将灰度图像进行二值化处理imwrite(d,2。车牌二值图像.jpg” ) ;subplot(3) ,imshow(D) 、标题(3。车牌二值图像 ) ;

11、%显示二值化图像%进行中值滤波a medfilt2(D) ;imwrite(D 。均值滤波后.jpg” ) ;subplot(3,2,4) ,imshow(D) ;标题(中值滤波后 。 ”) ;%均值滤波% h = fspecial(“平均” ,3) ;%d = im2bw(圆(过滤器(H,D) ) ) ;%滤波后,im2bw():将图像转成二值图像(可以不用圆函数也是一样的)% imwrite(D 。均值滤波后.jpg” ) ;%的插曲(3,2,4) ,imshow(D) 、标题(均值滤波后 。 ”)%某些图像进行操作膨胀或腐蚀感觉没什么效果咧%?% SE =斯太尔(square ,3) ;

12、%使用一个 3x3的正方形结果元素对象对创建的图像进行膨胀%“线”/ diamond / ball / square /食物线/菱形/球/正方形/圆SE =眼(2) ;%的眼睛(N)返回 N乘 N单一矩阵;单位矩阵m,n =大小(d) ;如果 bwarea(D)/ M / N0。The 365% function bwarea calculates the area of the object, in pixels, and bwarea/m/n as a single pixelD=imerode (D, Se)% corrosionElseif bwarea (d) /m/n=round

13、(n/6.5)val, num=min (sum (d (: k1+5:k2-5);D (: k1+num+5) =0;% splitEndEndPercent re cutting%d=qiege (D);% cut out 7 charactersY1=10; y2=0.25; flag=0; word1=;While flag=0% flag is custom to mark the loopm, n=size (D);%left=1;Wide=0;While sum (d (:, wide+1) =0% two value images: black pixels represent

14、 objects of interest, while white pixels represent the background. The logical matrix contains only 0 (shown as black) and 1 (shown as white)Wide=wide+1?%? Whats the meaning of wide?EndIf widey2%? What do you mean?Flag=1; word1=temp;% first characterEndD (: 1:wide) =0; d=qiege (d);%? Why do you deal

15、 with it again?EndEnd% split out second charactersword2, d=getword (D);% split out third charactersword3, d=getword (D);% split out fourth charactersword4, d=getword (D);% split out fifth charactersword5, d=getword (D);% split out sixth charactersword6, d=getword (D);% split out seventh characterswo

16、rd7, d=getword (D);Subplot (5,7,1), imshow (word1), title (1);Subplot (5,7,2), imshow (word2), title (2);Subplot (5,7,3), imshow (Word3), title (3);Subplot (5,7,4), imshow (word4), title (4);Subplot (5,7,5), imshow (word5), title (5);Subplot (5,7,6), imshow (word6), title (6);Subplot (5,7,7), imshow

17、 (word7), title (7);m, n=size (word1);% commercial system procedures with a normalized size of 40*20, demonstrated hereWord1=imresize (word1 40 20);%imresize zoom image processing, common call format: B=imresize (A, Ntimes, method); the method (optional nearest, bilinear, bicubic, bilinear) box, lan

18、czors2, lanczors3 etc.Word2=imresize (word2, 40, 20);Word3=imresize (Word3, 40, 20);Word4=imresize (word4, 40, 20);Word5=imresize (word5, 40, 20);Word6=imresize (word6, 40, 20);Word7=imresize (word7, 40, 20);Subplot (5,7,15), imshow (word1), title (11);subplot(5,7,16) ,imshow(word2) 、标题(22” ) ;subpl

19、ot(5,7,17) ,imshow(word3) 、标题(分 33秒) ;subplot(5,7,18) ,imshow(WORD4) 、标题(44” ) ;subplot(5,7,19) ,imshow(言语深深) 、标题(州的) ;subplot(5,7,20) ,imshow(word6) 、标题(66” ) ;subplot(5,7,21) ,imshow(word7) 、标题(1977 届毕业生” ) ;imwrite(word1,1 .jpg” ) ;%创建七位车牌字符图像imwrite(word2,2 .jpg” ) ;imwrite(word3,3 .jpg” ) ;imwr

20、ite(WORD4、4 .jpg” ) ;imwrite(言语深深,5 .jpg” ) ;imwrite(word6,6 .jpg” ) ;imwrite(word7,7 .jpg” ) ;liccode =字符( 0”:9” “:Z”京辽桂陕苏渝浙”) ;%建立自动识别字符代码表京津沪渝港澳吉辽鲁豫冀鄂湘晋青皖苏赣浙闽粤琼台陕甘云川贵黑藏蒙桂新宁” ;“%编号:0-9 分别为 1-10;A-Z 分别为 11-36;%京津沪渝港澳吉辽鲁豫冀鄂湘晋青皖苏%赣浙闽粤琼台陕甘云川贵黑藏蒙桂新宁% 3738394041424344454647484950515253545556575859% 60,6

21、1,62,63,64,65,66,67,68,69,70subbw2 =零(20) ;% 40 20 0 矩阵列的创建一个行l1;我= 1:7Ii=int2str (I);% converts integer data into string dataT=imread (ii,.jpg);% reads into seven bit license plate characters sequentiallySegBw2=imresize (T, 40, 20,nearest);% scaling the read charactersIf I=1% first Chinese characte

22、r recognitionKmin=37;Kmax=43;Elseif I=2% second bit AZ letter recognitionKmin=11;Kmax=36;Else% third bits are followed by letters or numbers; that is, I=3Kmin=1;Kmax=36;EndFor k2=kmin:kmaxFname=strcat (template, liccode (K2),.jpg);% strcat function: the connection stringSamBw2 = imread (fname);For i

23、=1:40For j=1:20SubBw2 (I, J), =SegBw2 (I, J), -SamBw2 (I, J);EndEndMore than% is equivalent to two pictures subtracted to get third pictures to matchDmax=0;% the number of points different from the templateFor k1=1:40For l1=1:20if (subbw2 (k1, l1) 10 | | subbw2 (k1, l1) 2 15) 20 以上无区别dmax = dmax + 1

24、;endendenderror (k2) = dmax;% 记录下字符与模板 k2不同的点个数enderror1 = error (kmin: kmax);minerror = min (error1);% 差别最小的findc = find (error1 = = minerror);% 找出差别最小的模板code (l) = liccode (findc (1) + kmin - 1);% 此处用 2 * l - 1且后面的 2 * l = , 第隔一空格输出一个字符code (3) = ; code (4) = ;l = l + 1.if l = = 3% 后五位与前两位字符隔开l =

25、l + 2;endendfigure (10), subplot (5,7,1: 7), imshow (dw), title (第一步: 车牌定位),xlabel (第二步: 车牌分割);% subplot (6,7,15), imshow (word1);subplot (6,7,16), imshow (word2);subplot (6,7,17), imshow (word3);subplot (6,7,18), imshow (word4);subplot (6,7,19), imshow (word5);subplot (6,7,20), imshow (word6);subplot (6,7,21)imshow(word7) ;subplot(6,7,22:42) ,imshow(dw .jpg” ) ;%xlabel(第三步:识别结果为:,代码, “色彩” ,B) ;

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

当前位置:首页 > 高等教育 > 大学课件

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报