• 大小: 2KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-04-21
  • 语言: Matlab
  • 标签: MATLAB  车牌提取  

资源简介

matlab的车牌定位提取。包括预处理,腐蚀,开闭运算,图形切割等。该程序准确率高达98 。

资源截图

代码片段和文件信息

clc;
clear all;
image=imread(‘5.bmp‘);
im1=rgb2gray(image);
figure(10)imshow(im1);

im1=medfilt2(im1[3 3]); %二维中值滤波处理图像噪声%
figure(12)imshow(im1);

BW = edge(im1‘sobel‘); %边缘检测
figure(13)imshow(BW);

[imximy]=size(BW);
msk=[0 0 0 0 0;
     0 1 1 1 0;
     0 1 1 1 0;
     0 1 1 1 0;
     0 0 0 0 0;];
B=conv2(double(BW)double(msk)); %二维卷积操作  Smoothing  image to reduce the number of connected components
figure(1)imshow(B);

grd=B;
bg1=imclose(grdstrel(‘rectangle‘[519]));%取矩形框的闭运算
figure(2)imshow(bg1);title(‘图像闭运算[519]‘);%输出闭运算的图像
bg3=imopen(bg1strel(‘rectangle‘[519]));%取矩形框的开运算
figure(3)imshow(bg3);title(‘图像开运算[519]‘);%输出开运算的图像
bg2=imopen(bg3strel(‘rectangle‘[191]));%取矩形框的开运算
figure(4)imshow(bg2);title(‘图像开运算[191]‘);%输出开运算的图像

[xy]=size(bg2);               
II=double(bg2); 


%将I变为对应区块的函数 区域照度优化!
x11=x/2;
x12=uint16(x11);
x13=double(x12);
y11=y/4;
y12=uint16(y11);
y13=double(y12);
y23=3*y13;
for i=x13:x
    for j=y13:y23
        I(ij)=II(ij);
    end
end

figure(14)imshow(II);
figure(15)imshow(I);
%取边缘    二值化                 
z0=max(max(I));  %取I中最大值              
z1=min(min(I));  %取I中最小值                
T=(z0+z1)/2;                      
TT=0;
S0=0; n0=0;
S1=0; n1=0;
allow=0.5;                       
d=abs(T-TT);
count=0;                        

[aabb]=size(I)
while(d>=allow)                 
    count=count+1;
    for i=1:aa
        for j=1:bb
            if (I(ij)>=T)
                S0=S0+I(ij);
                n0=n0+1;
            end
            if (I(ij)                S1=S1+I(ij);
                n1=n1+1;
            end
        end
    end 
    T0=S0/n0;
    T1=S1/n1;
    TT=(T0+T1)/2;
    d=abs(T-TT);
    T=TT;
end

Seg=zeros(xy);

for i=1:aa
    for j=1:bb
        if(I(ij)>=1.9*T)%照度影响明显 降低必然明显影响准确度
            Seg(ij)=1;               
        end
    end
end
figure(16)imshow(Seg);
SI=1-Seg;        
figure(17)imshow(SI);
se1=strel(‘square‘3); %选择3腐蚀 为使得边界精细             
SI1=imerode(SIse1);  
figure(17)imshow(SI1);    
BW=SI-SI1;                          
figure(5);
imshow(BW);title(‘BW‘)     


% 增加颗粒
hsize=[33];
H = fspecial(‘average‘hsize); %预定义滤波器
smoothed = imfilter(BWH‘replicate‘);
figure(6);
imshow(smoothed); title(‘3*3 Smoothed Image‘);
%填充封闭区域
BW1 = bwfill(BW‘holes‘);
figure(7);
imshow(BW1);
%取边缘
BW2 = bwmorph(BW1‘remove‘);
figure(8);
imshow(BW2);
%close pot 去除较小的白点
tt2=bwarea(BW1); %计算BW的面积
tt3=tt2/2
if(tt3>=10000)
       J2=bwareaopen(BW110000);
     elseif(tt3>=9000) 
         J2 = bwareaopen(BW19000);
         elseif(tt3>=8000) 
         J2 = bwareaopen(BW18000);
     elseif(tt3>=7000) 
         J2 = bwareaopen(BW17000);
     elseif(tt3>=6000) 
         J2 = bwareaopen(BW16000);
     elseif(tt3>=5000) 
         J2 = bwareaopen(BW15000);
     elseif(tt3>=4000) 
         J2 = bwareaopen(BW14000);
     elseif(tt3>=3000)
         J2 = bwarea

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       4545  2011-12-24 15:16  r1.m

----------- ---------  ---------- -----  ----

                 4545                    1


评论

共有 条评论