資源描述:
《車牌識別matlab源程序.doc》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、車牌識別matlab源程序基于顏色的車牌定位和分割技術(shù)研究與實現(xiàn)function[seg]=character_segmentation(bw);%character_segmentation:Returnsthedigitsegmentsinthesuppliedbinaryimage.%Thefunctionusesthe"segment"function,keepingonlytheseven%segmentsintheresultwithlargestarea,andincaselessthanseven
2、%segmentswerefound,itattemptstorecallthefunction,makingthe%separationbetweenthealreadyfoundsegmentsclearer(bycleaningthe%bitswhicharethere.DIGIT_WIDTH=18;MIN_AREA=250;loadglobal_var.mat;plot_vector(sum(bw),4,CharacterSegmentation-ColumnsSumGraph:,debug2);seg=
3、segment(bw,DIGIT_WIDTH,MIN_AREA);[xy]=size(seg);%Ifwegotlessthan7digits,wetrytomaketheseprationbetweenthem%clearerbycleaningthebitsbetweenthem,andwecallthe"segment"%functionagain:ifx<7fori=1:xbw(:,seg(i,2))=0;end;seg=segment(bw,DIGIT_WIDTH,MIN_AREA);end;%Keep
4、ingintheresultsthesevensegmentswiththelargestarea:area=[];fori=1:xpic=bw(:,seg(i,1):seg(i,2),:);area(i)=bwarea(pic);end;area1=sort(area);seg=seg;forj=1:(length(area1)-7)i=find(area==area1(j));len=length(area);ifi==1area=[area(2:len)];seg=[seg(:,2:len)];elseif
5、i==lenarea=[area(1:i-1)];seg=[seg(:,1:i-1)];elsearea=[area(1:i-1)area(i+1:len)];seg=[seg(:,1:i-1)seg(:,i+1:len)];end;end;seg=seg;return;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function[segmentation]=segment(im,digit_width,min
6、_area);%segment:Segmentthepicturesindigitimagesaccordingtothevariable%"digit_width"andreturnsamatrixcontainingthetwoboundsoftheeach%digitsegment.Thefunctionkeepsintheresultonlysegmentwhose%"rectangular"areasismorethan"min_area".segmentation=[];%Summingthecolu
7、msofthepic:t=sum(im);%Gettingthesegmentsinthepic:seg=clean(find_valleys(t,2,1,digit_width),3);%Keepingintheresultonlythesegmentswhoserectangularareasismorethanmin_area:j=1;fori=1:(length(seg)-1)band_width=seg(i+1)-seg(i);maxi=max(t(1,seg(i):seg(i+1)));if(maxi
8、*band_width>min_area)segmentation(j,1)=seg(i);segmentation(j,2)=seg(i+1);j=j+1;end;end;return;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function[s]=find_va