车牌识别程序(License plate recognition program)_第1页
车牌识别程序(License plate recognition program)_第2页
车牌识别程序(License plate recognition program)_第3页
车牌识别程序(License plate recognition program)_第4页
车牌识别程序(License plate recognition program)_第5页
已阅读5页,还剩16页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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

2、e,“真彩色增强);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),imhist(I1);标题(“灰度处理后的灰度图直方图”);%进行中值滤波I1

3、 = 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);% 腐蚀imerode (x, i).其中x是待处理的图像, se是结构元素对象figure (name, 腐蚀后图像

4、 ), imshow (i3); title ( 腐蚀后的图像 );it = strel (rectangle , 20,20);% 25x25的矩形 strel? ?imclose (i3, i4 = it);% 用25 * 25的矩形对图像进行闭运算 (先膨胀后腐蚀) 有平滑边界作用figure (name, 平滑处理 ), imshow (i4); title ( 平滑图像的轮廓 );i5 = bwareaopen (i41000);% 从二进制图像中移除所有少于2000像素的连接对象, 消失的是连续的白色像素数量少于2000的字符figure (name, 移除小对象 ), imsho

5、w (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) = blue _ y (i, 1) + 1;%蓝色像素点统计结束结束结束温糯 =最大(blue_y);% y方向车牌区域确定温度临时变量糯糯

6、PY1 =糯;%以下为找车牌Y方向最小值而(blue_y(py1,1) = 5)&(PY1 1)%为什么判断蓝色像素点 = 5(才算蓝色)?py1-1 Py1 =;结束PY2 =糯;%以下为找车牌Y方向最大值?难道最大值不是糯?而(blue_y(py2,1) = 5)&(PY2Y)PY2 = PY2 + 1;结束% IY =我(PY1:PY2,:,:);% X方向%blue_x =零(1,x);%进一步确定X方向的车牌区域对于j = 1:x我= Py1:只需扫描的行PY2 %如果(我(I,J,1)= = 1)%判断蓝色像素blue_x(1,j)= blue_x(1,j)+ 1;%蓝色像素点统计

7、结束结束结束PX1 = 1;%以下为找车牌X方向最小值而(blue_x(1,PX1)3)&(PX1x)%为什么判断蓝色像素点3(不算蓝色?)?PX1 = PX1 + 1;结束PX2 = x;%以下为找车牌X方向最大值而(blue_x(1,PX2)3)&(PX2 PX1)PX2 = px2-1;结束py1-2 Py1 =;% correction of license plate region + why?PX1=PX1-2;PX2=PX2+3;PY2=PY2+10;Dw=I (PY1:PY2-8, PX1:PX2:):% cropped imagesTOC%t=toc;% stop time%

8、figure (7), subplot (1,2,1), imshow (IY), title ( line direction, reasonable region );Figure (name, locate, 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, f

9、ilepath=uigetfile (dw.jpg, enter a location clipping image of the license plate);%jpg=strcat (filepath, 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 (

10、name, license plate processing ), subplot (3,2,1), imshow (b), title (1. license plate gray image)%g_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 val

11、ue for this one-dimensional data.%T=round (g_max- (g_max-g_min) /2);% T two threshold round: round%m, 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

12、im2bw(B,0.4);%将灰度图像进行二值化处理imwrite(d,2。车牌二值图像.jpg”);subplot(3),imshow(D)、标题(3。车牌二值图像);%显示二值化图像%进行中值滤波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),imsho

13、w(D)、标题(均值滤波后。”)%某些图像进行操作膨胀或腐蚀感觉没什么效果咧%?% SE =斯太尔(square ,3);%使用一个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=

14、imerode (D, Se)% corrosionElseif bwarea (d) /m/n=0.235D=imdilate (D, Se);% inflationEndImopen (D, Se);%se=eye (7);%imopen (D, Se);Imwrite (D,5., expansion or corrosion treatment,.Jpg);Subplot (3,2,5), imshow (d), title (5. after expansion or corrosion treatment)% looking for blocks with continuous t

15、ext. If the length is greater than a threshold, the block is considered to have two characters and needs to be segmentedD=qiege (d);% call qiege () subroutinem, n=size (D);Figure, subplot (2,1,1), imshow (d), title (n)%k1=1; k2=1;J=1;S=sum (d);%sum (x) is a vertical addition to the sum of each colum

16、n; the result is a row vector; sum (x, 2) represents the horizontal addition of the matrix X; the sum of the rows is computed; the result is the column vector. Sum (X (=) represents a sum of matricesWhile j=n% what principle?While s (J) =0, no text? Why?J=j+1;EndK1=j;While s (J) =0 and j=round (n/6.

17、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 obje

18、cts 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 with

19、 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 charactersword7,

20、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 (wor

21、d7), 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, lanczors

22、2, 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”);subplot(5,7,17

23、),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”);imwrite(WORD4、4 .jpg”);imwrite(言语深深,5 .

24、jpg”);imwrite(word6,6 .jpg”);imwrite(word7,7 .jpg”);liccode =字符( 0”:9”“:Z”京辽桂陕苏渝浙”);%建立自动识别字符代码表京津沪渝港澳吉辽鲁豫冀鄂湘晋青皖苏赣浙闽粤琼台陕甘云川贵黑藏蒙桂新宁”;“%编号:0-9分别为1-10;A-Z分别为11-36;%京津沪渝港澳吉辽鲁豫冀鄂湘晋青皖苏%赣浙闽粤琼台陕甘云川贵黑藏蒙桂新宁% 3738394041424344454647484950515253545556575859% 60,61,62,63,64,65,66,67,68,69,70subbw2 =零(20);% 40 20

25、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 character recognitionKmin=37;Kmax=43;Elseif I=2% second bit

26、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=1:40For j=1:20SubBw2 (I, J), =SegBw2 (I, J), -SamBw2 (I, J);EndEndMore than% is equivalent to two pictures subtra

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论