• 大小: 201KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-08-12
  • 语言: Matlab
  • 标签: matlab  图像处理  

资源简介

粘连字符分割、字符识别、车牌分割等,基于matlab编译

资源截图

代码片段和文件信息

%I=imread(‘24-1.jpg‘); 该图像的试验结果读者自行试验。
I=imread(‘22-2.jpg‘);    
tic 
[yxz]=size(I);
myI=double(I);
%%%%%%%%%%% RGB to HSI  %%%%%%%%

HS_I=(myI(::1)+myI(::2)+myI(::3))/3;
t1=toc
tic
%%%% 边缘点数量统计 与 S分量的纹理分割%%%%%%%%%
S=zeros(yx);

BW= edge(HS_I‘canny‘0.2);%边缘检测,对边缘像素点作统计分析。
t2=toc
tic
ES=0;  
   for i=1:x
       for j=1:y
           if (BW(ji)==1)               
              S(ji)=1-min(myI(ji:))/HS_I(ji);
              SR=round(S(ji)*100)/100;
              ES=[ES SR];
           end 
       end
  end
ESx=(0:0.01:1);


BW1=zeros(yx);
 for i=1:x
       for j=1:y 
           % 根据上述的统计直方图设定 S 的阈值
           if ((BW(ji)==1)&(S(ji)<=0.06)&(S(ji)>=0.01)) 
              BW1(ji)=1;
           end 
       end
  end
t3=toc
tic
%%%%%%%%%%%%% 边缘像素点数量统计 %%%%%%%%%%%%%%%%%%
 EdgePointsX=sum(BW1); % X方向
 AveragePointsX=mean(EdgePointsX);
 EPx=(1:x);
 
 
%%%%%%%%%%%%% 文字图像区域分割 %%%%%%%%%%%%%%%%%%%
              % X Direction
ColumnX=zeros(1x);
for i=1:x
    if (EdgePointsX(i)>=AveragePointsX)
        ColumnX(i)=1;
    end
end
Nx=sum(ColumnX); 

Posx=zeros(1Nx); % 挑出边缘点数量大于平均值的位置
k=1;
for i=1:x
    if (EdgePointsX(i)>=AveragePointsX)
        Posx(k)=i;
        k=k+1;
    end
end

gapx=12;             % 间隔小于10列的,区域合并
Partx0=zeros(1Nx);
Partx1=zeros(1Nx);
k=1;
Partx0(1)=Posx(1);
for i=2:Nx
    d=Posx(i)-Posx(i-1);
    if (d>gapx)
       Partx1(k)= Posx(i-1);
       k=k+1;
       Partx0(k)=Posx(i);
   end
end  
Partx1(k)= Posx(Nx);   %  最后一列大于平均值的位置作为,最后一个区域的切分位置

Spanx=zeros(1k); % 共有k个区域
for i=1:k
    Spanx(i)=sum(ColumnX(Partx0(i):Partx1(i)));
end
[mytemp nPartx]=max(Spanx);
word_Xseg0=Partx0(nPartx);
word_Xseg1=Partx1(nPartx); 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 BWSeg=BW1(:word_Xseg0:word_Xseg1);  % Y方向边缘点统计
 BWT=BWSeg‘;
 EdgePointsY=sum(BWT);           
 AveragePointsY=mean(EdgePointsY);
 EPy=(1:y);
            
RowY=zeros(1y);
for i=1:y
    if (EdgePointsY(i)>=AveragePointsY)
        RowY(i)=1;  
    end
end
Ny=sum(RowY);

Posy=zeros(1Ny); % 挑出边缘点数量大于平均值的位置
k=1;
for i=1:y
    if (EdgePointsY(i)>=AveragePointsY)
        Posy(k)=i;
        k=k+1;
    end
end

gapy=20;             % 间隔小于30列的,区域合并
Party0=zeros(1Ny);
Party1=zeros(1Ny);
k=1;
Party0(1)=Posy(1);
for i=2:Ny
    d=Posy(i)-Posy(i-1);
    if (d>gapy)
       Party1(k)= Posy(i-1);
       k=k+1;
       Party0(k)=Posy(i);
   end
end  
Party1(k)= Posy(Ny);   %  最后一列大于平均值的位置作为,最后一个区域的切分位置

Spany=zeros(1k); % 共有k个区域
for i=1:k
    Spany(i)=sum(RowY(Party0(i):Party1(i)));
end
[mytemp nParty]=max(Spany);
word_Yseg0=Party0(nParty);
word_Yseg1=Party1(nParty); 

word=I(word_Yseg0:word_Yseg1word_Xseg0:word_Xseg1:);
t4= toc

HS_I=uint8(HS_I);

%%%%%%%%%%%%%%%%%% Display %%%%%%%%%%%%%%%%%%%%
figure(1);
imshow(I);
figure(2);
imshow(HS_I);
figure(3);
imshow(BW);
figure(4);
hist(ESESx);grid
title(‘S Histogram of the Edge Pixels‘);
f

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

     文件        613  2003-12-25 22:19  4.jpg

     文件        564  2003-12-26 00:51  5-1.jpg

     文件        700  2003-12-25 21:54  5.jpg

     文件        579  2003-12-26 01:01  6.jpg

     文件        541  2003-12-15 21:13  7.jpg

     文件        575  2003-12-17 01:49  8.jpg

     文件        684  2003-12-24 06:30  9.jpg

     文件       2084  2003-11-22 21:15  19-3-02.jpg

     文件       7647  2003-09-23 06:36  22-2.jpg

     文件      10807  2003-09-21 04:56  24-1.jpg

     文件      12588  2004-02-07 20:28  brand02.jpg

     文件     159529  2003-09-25 05:19  Car.JPG

     文件       3600  2004-04-05 06:20  P0801.m

     文件       5887  2004-04-05 06:23  P0802.m

     文件       3468  2004-04-05 07:02  P0803.m

     文件       1432  2004-04-05 06:50  P0804.m

     文件       1299  2004-04-05 06:52  P0805.m

     文件        213  2004-07-21 21:44  readme.txt

     文件       2653  2003-12-30 01:23  Recognition.m

     文件       2173  2003-12-30 00:30  StrDetect01.m

     文件        565  2003-12-15 21:21  0.jpg

     文件        528  2003-12-17 02:20  1.jpg

     文件        568  2003-12-17 01:48  2.jpg

     文件        568  2003-12-26 00:48  3.jpg

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

               220083                    25


评论

共有 条评论