MATLAB实现基于小波变换的车牌定位

        基于小波变换车牌粗定位,实现能将一副图像中判定为车牌的矩形块控制在三个以内,下面就介绍我实现的算法流程,以及matla实现代码和相应的处理结果。算法的流程如下图:

                                                                                     

 这是算法的流程框图,实现代码如下:

close ;
clear;
src=imread('G:\progress\车牌识别\plate_judge.jpg');
gray_I = rgb2gray(src);
subplot(2,2,4);
imshow(gray_I);
title('原始灰度图像');
[c,l]=wavedec2(gray_I,3,'sym3');
ch1=wcodemat(detcoef2('h',c,l,1),255);
ch2=wcodemat(detcoef2('h',c,l,2),255);
ch3=wcodemat(detcoef2('h',c,l,3),255);
ch22=interp2(ch2,'linear');
ch31=interp2(ch3,'linear');
ch33=interp2(ch31,'linear');
[m,n]=size(ch1);
subplot(2,2,1);
c1=uint8(ch1);
imshow(c1);
title('第一层竖直分量');
subplot(2,2,2);
[m2,n2]=size(gray_I);
ch22_alter=myresize(ch22,m,n);
ch33_alter=myresize(ch33,m,n);
c2=uint8(ch22_alter);
imshow(c2);
title('第二层竖直分量');
subplot(2,2,3);
c3=uint8(ch33_alter);
ch=ch1*0.6+ch22_alter*0.3+ch33_alter*0.1;
ch_z=interp2(ch,'linear');
ch_alter=myresize(ch_z,m2,n2);
cc=uint8(ch_alter);
thresh =graythresh(cc);
fc=im2bw(cc,thresh);
%imshow(fc);
se=strel('square',23);
fc_2=imclose(fc,se);
imshow(fc_2);
[I,t]=bwlabel(fc_2,8);
status=regionprops(I,'BoundingBox');
%imshow(fc_2);
hold on;
for i=1:t
     rectangle('position',status(i).BoundingBox,'edgecolor','r');
end 
hold off;
title('闭操作后的外接矩形图');
aa=zeros(t,7);
L=zeros(t,1);
a=status;
for ig=1:t
    aa(ig,1:4)=a(ig).BoundingBox;
    aa(ig,5)=aa(ig,3)*aa(ig,4);   %第五列存的的是矩形的面积
    aa(ig,6)=aa(ig,1)+aa(ig,3)/2;
    aa(ig,7)=aa(ig,2)+aa(ig,4)/2;
end
s1=m2*n2;
for ig=1:t
    L1=(abs(0.05*s1-aa(ig,5)))/(0.05*s1);
    L2=(abs(6-aa(ig,3)/aa(ig,4)))/6;
    L3=5*(m2-aa(ig,7))/m2+abs(0.5*n2-aa(ig,6))/(0.5*n2);
    L(ig,1)=L1+L2+L3;
end
[sor,index]=sort(L);
for j=1:3
   b(j)=status(index(j));
end
figure(2);
imshow(fc_2);
hold on;
for i=1:3
     rectangle('position',b(i).BoundingBox,'edgecolor','r');
end 
hold off;
title('待判定车牌');

实现结果如下:




  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值