基於matlab的車牌識別(含子程式)

專注的阿熊發表於2022-12-29

d=qiege(d);

[m,n]=size(d);

   % subplot(3,2,5),imshow(d),title(n)

k1=1;k2=1;s=sum(d);j=1;

while j~=n

     while s(j)==0

         j=j+1;

     end

     k1=j;

     while s(j)~=0 && j<=n-1

         j=j+1;

     end

     k2=j-1;

     if k2-k1>=round(n/6.5)

         [val,num]=min(sum(d(:,[k1+5:k2-5])));

         d(:,k1+num+5)=0;  % 分割

     end

end

% 再切割

d=qiege(d);

% 切割出 7 個字元

y1=10;y2=0.25;flag=0;word1=[];

while flag==0

     [m,n]=size(d);

     left=1;wide=0;

     while sum(d(:,wide+1))~=0

         wide=wide+1;

     end

     if wide<y1  跟單網gendan5.com % 認為是左側干擾

         d(:,[1:wide])=0;

         d=qiege(d);

     else

         temp=qiege(imcrop(d,[1 1 wide m]));

         [m,n]=size(temp);

         all=sum(sum(temp));

         two_thirds=sum(sum(temp([round(m/3):2*round(m/3)],:)));

         if two_thirds/all>y2

             flag=1;word1=temp;   

         end

         d(:,[1:wide])=0;d=qiege(d);

     end

end

% 分割出第二個字元

[word2,d]=getword(d);

% 分割出第三個字元

[word3,d]=getword(d);

% 分割出第四個字元

[word4,d]=getword(d);

% 分割出第五個字元

[word5,d]=getword(d);

% 分割出第六個字元

[word6,d]=getword(d);

% 分割出第七個字元

[word7,d]=getword(d);

figure(9);

subplot(2,7,1),imshow(word1),title('1');

subplot(2,7,2),imshow(word2),title('2');

subplot(2,7,3),imshow(word3),title('3');

subplot(2,7,4),imshow(word4),title('4');

subplot(2,7,5),imshow(word5),title('5');

subplot(2,7,6),imshow(word6),title('6');

subplot(2,7,7),imshow(word7),title('7');

[m,n]=size(word1);

% 商用系統程式中歸一化大小為 40*20, 此處演示

word1=imresize(word1,[40 20]);

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(2,7,8),imshow(word1),title('1');

subplot(2,7,9),imshow(word2),title('2');

subplot(2,7,10),imshow(word3),title('3');

subplot(2,7,11),imshow(word4),title('4');

subplot(2,7,12),imshow(word5),title('5');

subplot(2,7,13),imshow(word6),title('6');

subplot(2,7,14),imshow(word7),title('7');

imwrite(word1,'1.jpg');

imwrite(word2,'2.jpg');

imwrite(word3,'3.jpg');

imwrite(word4,'4.jpg');

imwrite(word5,'5.jpg');

imwrite(word6,'6.jpg');

imwrite(word7,'7.jpg'); 執行結果如下:


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69946337/viewspace-2930068/,如需轉載,請註明出處,否則將追究法律責任。

相關文章