資源簡介
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個文件信息
- 上一篇:深思4加密狗的分析.rar
- 下一篇:stm32控制步進電機加減速
評論
共有 條評論