版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、車牌識(shí)別程序(License plate recognition program)%功能D = main()關(guān)閉所有清空命令窗口的所有輸入和輸出CLC %,類似于清屏%自動(dòng)彈出提示框讀入圖像文件名,文件路徑 =交互式(“.jpg”、“輸入一個(gè)需要識(shí)別的車牌圖像);直接自動(dòng)讀入% %文件= strcat(,文件名);%將函數(shù):連接字符串;把文件路徑文件名的連接的字符串與,即路徑/文件名我= imread(car .jpg”);圖(name,“原圖),imshow(I);標(biāo)題(“原圖”)%圖像增強(qiáng)% h =人(5,5)/ 25;%過濾器H%我= imfilter(I,H);%真彩色增強(qiáng)%圖(nam
2、e,“真彩色增強(qiáng));imshow(I);標(biāo)題(“真彩色增強(qiáng)”);I1 = rgb2gray(我);%的RGB圖像轉(zhuǎn)灰度圖像圖(name,“灰度處理前),情節(jié)(1,2,1),imshow(I1);標(biāo)題(“灰度處理前的灰度圖”);subplot(1,2,2),imhist(I1);標(biāo)題(“灰度處理前的灰度圖直方圖”);%線性灰度變換I1 = imadjust(I1,0.3,0.7 , );圖(name,“灰度處理后),情節(jié)(1,2,1),imshow(I1);標(biāo)題(“灰度處理后的灰度圖”);subplot(1,2,2),imhist(I1);標(biāo)題(“灰度處理后的灰度圖直方圖”);%進(jìn)行中值濾波I1
3、 = medfilt2(I1);圖,imshow(I1);標(biāo)題(“中值濾波”);%邊緣檢測:Sobel、羅伯茨、精明,prewitt等i2 = edge (i1, roberts, 0.25, both);% 邊緣檢測算法, 強(qiáng)度小于閾值0.15的邊緣被省略掉, both 兩個(gè)方向檢測 (缺省默認(rèn))figure (name, 邊緣檢測 ), imshow (i2); title ( robert算子邊緣檢測 )it = 1; 1; 1;i3 = imerode (i2, i);% 腐蝕imerode (x, i).其中x是待處理的圖像, se是結(jié)構(gòu)元素對(duì)象figure (name, 腐蝕后圖像
4、 ), imshow (i3); title ( 腐蝕后的圖像 );it = strel (rectangle , 20,20);% 25x25的矩形 strel? ?imclose (i3, i4 = it);% 用25 * 25的矩形對(duì)圖像進(jìn)行閉運(yùn)算 (先膨脹后腐蝕) 有平滑邊界作用figure (name, 平滑處理 ), imshow (i4); title ( 平滑圖像的輪廓 );i5 = bwareaopen (i41000);% 從二進(jìn)制圖像中移除所有少于2000像素的連接對(duì)象, 消失的是連續(xù)的白色像素?cái)?shù)量少于2000的字符figure (name, 移除小對(duì)象 ), imsho
5、w (i5); title ( 從對(duì)象中移除小對(duì)象 );y, x, z = size (i5);% y是行數(shù), x是列數(shù), z是維數(shù)sold = double (i5);% 轉(zhuǎn)成雙精度型tic% 開始計(jì)時(shí)blue _ y = zeros (y, 1);% zeros (m, n) 表示的是m行 * n列的全0矩陣for i = 1: yfor j = 1: xif (sold (i, j, 1) = = 1)% 判斷藍(lán)色像素blue _ y (i, 1) = blue _ y (i, 1) + 1;%藍(lán)色像素點(diǎn)統(tǒng)計(jì)結(jié)束結(jié)束結(jié)束溫糯 =最大(blue_y);% y方向車牌區(qū)域確定溫度臨時(shí)變量糯糯
6、PY1 =糯;%以下為找車牌Y方向最小值而(blue_y(py1,1) = 5)&(PY1 1)%為什么判斷藍(lán)色像素點(diǎn) = 5(才算藍(lán)色)?py1-1 Py1 =;結(jié)束PY2 =糯;%以下為找車牌Y方向最大值?難道最大值不是糯?而(blue_y(py2,1) = 5)&(PY2Y)PY2 = PY2 + 1;結(jié)束% IY =我(PY1:PY2,:,:);% X方向%blue_x =零(1,x);%進(jìn)一步確定X方向的車牌區(qū)域?qū)τ趈 = 1:x我= Py1:只需掃描的行PY2 %如果(我(I,J,1)= = 1)%判斷藍(lán)色像素blue_x(1,j)= blue_x(1,j)+ 1;%藍(lán)色像素點(diǎn)統(tǒng)計(jì)
7、結(jié)束結(jié)束結(jié)束PX1 = 1;%以下為找車牌X方向最小值而(blue_x(1,PX1)3)&(PX1x)%為什么判斷藍(lán)色像素點(diǎn)3(不算藍(lán)色?)?PX1 = PX1 + 1;結(jié)束PX2 = x;%以下為找車牌X方向最大值而(blue_x(1,PX2)3)&(PX2 PX1)PX2 = px2-1;結(jié)束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線性灰度處理后的灰度圖”稱號(hào)。);%進(jìn)行二值化處理a
12、im2bw(B,0.4);%將灰度圖像進(jìn)行二值化處理imwrite(d,2。車牌二值圖像.jpg”);subplot(3),imshow(D)、標(biāo)題(3。車牌二值圖像);%顯示二值化圖像%進(jìn)行中值濾波a medfilt2(D);imwrite(D。均值濾波后.jpg”);subplot(3,2,4),imshow(D);標(biāo)題(中值濾波后?!保?;%均值濾波% h = fspecial(“平均”,3);%d = im2bw(圓(過濾器(H,D);%濾波后,im2bw():將圖像轉(zhuǎn)成二值圖像(可以不用圓函數(shù)也是一樣的)% imwrite(D。均值濾波后.jpg”);%的插曲(3,2,4),imsho
13、w(D)、標(biāo)題(均值濾波后?!保?某些圖像進(jìn)行操作膨脹或腐蝕感覺沒什么效果咧%?% SE =斯太爾(square ,3);%使用一個(gè)3x3的正方形結(jié)果元素對(duì)象對(duì)創(chuàng)建的圖像進(jìn)行膨脹%“線”/ 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)、標(biāo)題(22”);subplot(5,7,17
23、),imshow(word3)、標(biāo)題(分33秒);subplot(5,7,18),imshow(WORD4)、標(biāo)題(44”);subplot(5,7,19),imshow(言語深深)、標(biāo)題(州的);subplot(5,7,20),imshow(word6)、標(biāo)題(66”);subplot(5,7,21),imshow(word7)、標(biāo)題(1977屆畢業(yè)生”);imwrite(word1,1 .jpg”);%創(chuàng)建七位車牌字符圖像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”京遼桂陜蘇渝浙”);%建立自動(dòng)識(shí)別字符代碼表京津滬渝港澳吉遼魯豫冀鄂湘晉青皖蘇贛浙閩粵瓊臺(tái)陜甘云川貴黑藏蒙桂新寧”;“%編號(hào):0-9分別為1-10;A-Z分別為11-36;%京津滬渝港澳吉遼魯豫冀鄂湘晉青皖蘇%贛浙閩粵瓊臺(tái)陜甘云川貴黑藏蒙桂新寧% 3738394041424344454647484950515253545556575859% 60,61,62,63,64,65,66,67,68,69,70subbw2 =零(20);% 40 20
25、0矩陣列的創(chuàng)建一個(gè)行l(wèi)1;我= 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等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五年度農(nóng)村住房光伏發(fā)電設(shè)施租賃合同
- 2025年度農(nóng)村個(gè)人房屋買賣合同附宅基地使用權(quán)變更合同3篇
- 2025年度公司對(duì)賭協(xié)議合同-技術(shù)研發(fā)與創(chuàng)新成果轉(zhuǎn)化3篇
- 2025年農(nóng)村公路養(yǎng)護(hù)與智慧交通系統(tǒng)合作合同2篇
- 2025年度特色養(yǎng)殖場土地租賃及合作開發(fā)合同3篇
- 二零二五年度農(nóng)村房屋買賣與能源供應(yīng)合同
- 二零二五年度公司員工勞動(dòng)合同簽訂與解除管理補(bǔ)充協(xié)議3篇
- 二零二五年度網(wǎng)絡(luò)信息安全分?jǐn)偙U虾贤?篇
- 二零二五年度農(nóng)村房屋贈(zèng)與合同附農(nóng)業(yè)資源循環(huán)利用合同
- 2025年度養(yǎng)豬場養(yǎng)殖廢棄物處理設(shè)施升級(jí)改造轉(zhuǎn)讓合同3篇
- 《膽囊結(jié)石的護(hù)理》PPT
- 安徽云帆藥業(yè)有限公司原料藥生產(chǎn)項(xiàng)目環(huán)境影響報(bào)告
- 藥品質(zhì)量受權(quán)人管理規(guī)程
- 校本課程之《紅樓夢詩詞曲賞析》教案
- 熱動(dòng)復(fù)習(xí)題材料熱力學(xué)與動(dòng)力學(xué)
- 馬工程-公共財(cái)政概論-課程教案
- GB/T 38058-2019民用多旋翼無人機(jī)系統(tǒng)試驗(yàn)方法
- GB/T 30902-2014無機(jī)化工產(chǎn)品雜質(zhì)元素的測定電感耦合等離子體發(fā)射光譜法(ICP-OES)
- GB/T 22638.2-2016鋁箔試驗(yàn)方法第2部分:針孔的檢測
- GB/T 13275-1991一般用途離心通風(fēng)機(jī)技術(shù)條件
- 千年菩提路解說詞
評(píng)論
0/150
提交評(píng)論