• 大小: 329KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-03
  • 语言: Matlab
  • 标签: 链码提取  

资源简介

【项目代码】该源代码的功能是用matlab来实现链码提取,内含测试图片及所用的算法源代.rar

资源截图

代码片段和文件信息

%此函数用来根据一个已知点来提取以该点为端点的特征线的链码
%im为输入二值图像x0y0为端点坐标
function result=getcode(imx0y0)
[m n]=size(im);
points(1)=x0;   %用points记录所有链码起始点的位置
points(2)=y0;
next=1;    %用来判断是否结束对当前链码的搜索
number=1;  %用来记录当前链码以搜索点的数量
list=[];
list(number)=0;
x=x0;
y=y0;
%每当搜索到一个起始点,搜索其周围点,追寻链码轨迹
while(next==1)
    if(x<=0|x>m|y<=0|y>n)    %如果链码当前点已到达边界,则停止搜索
        next=0;
    else
        im(xy)=0;       %把已搜索过的点值置零,以免重复搜索
        
        %按照方向表中从1到8的顺序检索当前点周围是否存在非0点
        if(im(xy+1)==1)
            list(number)=4;
            x=x;
            y=y+1;
            x1=x;
            y1=y;
            number=1+number;
            if(x==x0&y==y0)     %判断是否回到起始点,若是则当前特征线链码提取结束
                next=0;
            end
        elseif(im(x+1y)==1)
            list(number)=6;
            x=x+1;
            y=y;
            x1=x;
            y1=y;
            number=1+number;
            if(x==x0&y==y0)
                next=0;
            end
        elseif(im(xy-1)==1)
            list(number)=8;
            x=x;
            y=y-1;
            x1=x;
            y1=y;
            number=number+1;
            if(x==x0&y==y0)
                next=0;
            end
        elseif(im(x-1y)==1)
            list(number)=2;
            x=x-1;
            y=y;
            x1=x;
            y1=y;
            number=1+number;
            if(x==x0&y==y0)
                next=0;
            end
        elseif(im(x+1y+1)==1)
            list(number)=5;
            x=x+1;
            y=y+1;
            x1=x;
            y1=y;
            number=1+number;
            if(x==x0&y==y0)
                next=0;
            end
        elseif(im(x+1y-1)==1)
            list(number)=7;
            x=x+1;
            y=y-1;
            x1=x;
            y1=y;
            number=1+number;
            if(x==x0&y==y0)
                next=0;
            end
        elseif(im(x-1y-1)==1)
            list(number)=1;
            x=x-1;
            y=y-1;
            x1=x;
            y1=y;
            number=1+number;
            if(x==x0&y==y0)
                next=0;
            end
        elseif(im(x-1y+1)==1)
            list(number)=3;
            x=x-1;
            y=y+1;
            x1=x;
            y1=y;
            number=1+number;
            if(x==x0&y==y0)
                next=0;
            end
        else
            next=0;
        end
    end
end
result=[x0 y0 x1 y1 list(:)‘];
end

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

     文件       2690  2008-12-04 10:38  matlab链码提取算法\getcode.m

     文件       2106  2008-12-04 10:37  matlab链码提取算法\searchtip.m

     文件       4627  2008-12-04 10:43  matlab链码提取算法\listcode.m

     文件      12405  2009-11-03 21:28  matlab链码提取算法\a.bmp

     文件       2726  2009-11-03 21:48  matlab链码提取算法\getcode.asv

     文件       4695  2009-11-03 21:48  matlab链码提取算法\listcode.asv

     文件     325197  2003-10-22 19:49  matlab链码提取算法\texture1.jpg

     文件       2153  2009-11-03 22:06  matlab链码提取算法\searchtip.asv

     目录          0  2009-11-03 21:19  matlab链码提取算法

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

               356599                    9


评论

共有 条评论