• 大小: 2.75MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-10-10
  • 语言: 其他
  • 标签: matlab  

资源简介

MATLB模板识别字符分割和识别有问题,可以用于参考。In recent years, with the increasing number of vehicles, traffic problems have caused people to pay more attention to vehicle management. Nowadays, we can use the existing image processing technology to make our vehicle management more convenient. For example, Alibaba's urban brain is very good in the field of intelligent transportation. License Plate Recognition (LPR), as a key link in the field of intelligent transportation, can help us to acquire relevant information of automobiles. It is of great significance for us to manage traffic vehicles, establish community parking lots, check traffic, combat crime, and effective security work.

资源截图

代码片段和文件信息

clear ;
close all;
web -browser http://www.ilovematlab.cn/thread-23229-1-1.html
%Step1 获取图像   装入待处理彩色图像并显示原始图像
Scolor = imread(‘3.jpg‘);%imread函数读取图像文件
%将彩色图像转换为黑白并显示
Sgray = rgb2gray(Scolor);%rgb2gray转换成灰度图
figureimshow(Scolor)title(‘原始彩色图像‘);%figure命令同时显示两幅图像
figureimshow(Sgray)title(‘原始黑白图像‘);
%Step2 图像预处理   对Sgray 原始黑白图像进行开操作得到图像背景
s=strel(‘disk‘13);%strei函数
Bgray=imopen(Sgrays);%打开sgray s图像
figureimshow(Bgray);title(‘背景图像‘);%输出背景图像
%用原始图像与背景图像作减法,增强图像
Egray=imsubtract(SgrayBgray);%两幅图相减
figureimshow(Egray);title(‘增强黑白图像‘);%输出黑白图像
%Step3 取得最佳阈值,将图像二值化
fmax1=double(max(max(Egray)));%egray的最大值并输出双精度型
fmin1=double(min(min(Egray)));%egray的最小值并输出双精度型
level=(fmax1-(fmax1-fmin1)/3)/255;%获得最佳阈值
bw22=im2bw(Egraylevel);%转换图像为二进制图像
bw2=double(bw22);
%Step4 对得到二值图像作开闭操作进行滤波
figureimshow(bw2);title(‘图像二值化‘);%得到二值图像
grd=edge(bw2‘canny‘)%用canny算子识别强度图像中的边界
figureimshow(grd);title(‘图像边缘提取‘);%输出图像边缘
bg1=imclose(grdstrel(‘rectangle‘[519]));%取矩形框的闭运算
figureimshow(bg1);title(‘图像闭运算[519]‘);%输出闭运算的图像
bg3=imopen(bg1strel(‘rectangle‘[519]));%取矩形框的开运算
figureimshow(bg3);title(‘图像开运算[519]‘);%输出开运算的图像
bg2=imopen(bg3strel(‘rectangle‘[191]));%取矩形框的开运算
figureimshow(bg2);title(‘图像开运算[191]‘);%输出开运算的图像
%Step5 对二值图像进行区域提取,并计算区域特征参数。进行区域特征参数比较,提取车牌区域
[Lnum] = bwlabel(bg28);%标注二进制图像中已连接的部分
Feastats = imfeature(L‘basic‘);%计算图像区域的特征尺寸
Area=[Feastats.Area];%区域面积
BoundingBox=[Feastats.BoundingBox];%[x y width height]车牌的框架大小
RGB = label2rgb(L ‘spring‘ ‘k‘ ‘shuffle‘); %标志图像向RGB图像转换
figureimshow(RGB);title(‘图像彩色标记‘);%输出框架的彩色图像
lx=0;
for l=1:num
    width=BoundingBox((l-1)*4+3);%框架宽度的计算
    hight=BoundingBox((l-1)*4+4);%框架高度的计算
    if (width>98 & width<160 & hight>25 & hight<50)%框架的宽度和高度的范围
        lx=lx+1;
        Getok(lx)=l;
    end
end
for k= 1:lx
    l=Getok(k);    
    startcol=BoundingBox((l-1)*4+1)-2;%开始列
    startrow=BoundingBox((l-1)*4+2)-2;%开始行
    width=BoundingBox((l-1)*4+3)+8;%车牌宽
    hight=BoundingBox((l-1)*4+4)+2;%车牌高
    rato=width/hight;%计算车牌长宽比
    if rato>2 & rato<4   
        break;
    end
end
sbw1=bw2(startrow:startrow+hightstartcol:startcol+width-1); %获取车牌二值子图
subcol1=Sgray(startrow:startrow+hightstartcol:startcol+width-1);%获取车牌灰度子图
figuresubplot(211)imshow(subcol1);title(‘车牌灰度子图‘);%输出灰度图像
subplot(212)imshow(sbw1);title(‘车牌二值子图‘);%输出车牌的二值图
%Step6 计算车牌水平投影,并对水平投影进行峰谷分析
histcol1=sum(sbw1);      %计算垂直投影
histrow=sum(sbw1‘);      %计算水平投影
figuresubplot(211)bar(histcol1);title(‘垂直投影(含边框)‘);%输出垂直投影
subplot(212)bar(histrow);     title(‘水平投影(含边框)‘);%输出水平投影
figuresubplot(211)bar(histrow);     title(‘水平投影(含边框)‘);%输出水平投影
subplot(212)imshow(sbw1);title(‘车牌二值子图‘);%输出二值图
%对水平投影进行峰谷分析
meanrow=mean(histrow);%求水平投影的平均值
minrow=min(histrow);%求水平投影的最小值
levelrow=(meanrow+minrow)/2;%求水平投影的平均值
count1=0;
l=1;
for k=1:hight
    if histrow(k)<=levelrow                             
        count1=count1+1;                                
    else 
        

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件     1090205  2019-04-23 19:52  car4.png
     目录           0  2019-04-20 13:28  work\
     文件       35993  2008-12-27 09:51  work\3.jpg
     目录           0  2019-04-20 13:28  work\sam\
     文件         534  2008-12-27 16:26  work\sam\image1.jpg
     文件         521  2008-12-29 15:01  work\sam\image2.jpg
     文件         541  2008-12-29 15:01  work\sam\image3.jpg
     文件         532  2008-12-29 15:01  work\sam\image4.jpg
     文件         536  2008-12-29 15:01  work\sam\image5.jpg
     文件         527  2008-12-29 15:01  work\sam\image6.jpg
     文件         525  2008-12-29 15:01  work\sam\image7.jpg
     文件         519  2008-12-29 15:01  work\sam\image8.jpg
     文件       11395  2008-12-27 11:42  work\sam\Sam0.jpg
     文件       11169  2008-12-27 11:43  work\sam\Sam1.jpg
     文件         514  2008-12-27 10:12  work\sam\Sam2.jpg
     文件         522  2008-12-27 10:12  work\sam\Sam3.jpg
     文件       11416  2008-12-27 11:43  work\sam\Sam4.jpg
     文件         509  2008-12-27 10:12  work\sam\Sam5.jpg
     文件       11467  2008-12-27 11:44  work\sam\Sam6.jpg
     文件       11219  2008-12-27 11:44  work\sam\Sam7.jpg
     文件         529  2008-12-27 10:12  work\sam\Sam8.jpg
     文件         510  2008-12-27 10:12  work\sam\Sam9.jpg
     文件         528  2008-12-27 10:12  work\sam\SamA.jpg
     文件       11546  2008-12-27 10:20  work\sam\SamB.jpg
     文件       11417  2008-12-27 10:27  work\sam\SamC.jpg
     文件       11464  2008-12-27 10:28  work\sam\SamD.jpg
     文件       11490  2008-12-27 10:29  work\sam\SamE.jpg
     文件       11379  2008-12-27 11:32  work\sam\SamF.jpg
     文件       11520  2008-12-27 11:33  work\sam\SamG.jpg
     文件       11427  2008-12-27 11:33  work\sam\SamH.jpg
     文件       11107  2008-12-27 11:34  work\sam\SamI.jpg
............此处省略29个文件信息

评论

共有 条评论