⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matlab二值图像的细化.txt

📁 MATLAB绘制出权值wv和阀值bv确定的误差曲面
💻 TXT
字号:
二值图像的细化算法和源程序代码(Matlab)

有关图像细化算法,从方法上有很多,具体请参看各图像处理的经典教材,但有一本书,我记得是大概1980年代科学出版社出版的,是著名的Pavlidis编著,并由国内学者翻译的,将图像细化算法,包括并行算法。

这部分介绍的是一本西文版教材上的例子, Zhang-Suen skeletonization algorithm (骨架化)

(Zhang-Suen skeletonization algorithm )

1 算法的具体原理,请参看:

   Introduction to Digital Image Processing with Matlab 数字图像处理概论 
   [美]Alasdair MchAndrew 著,胡小平 缩编

   重庆大学出版社

From:

Definition:

To check whether a pixel is 4-simple or 8 -simple , we introduce some numbers associated with the neighborhood of a foreground pixel p.

Define Np to be the 3x3 neighborhood of p and Np* to be the 3x3 neighborhood excluding p, Then

A(p) = the number of 4-components in Np*

C(p) = the number of 8-components in Np*

B(p) = the number of foreground pixels in Np*

For example , in the following figure, (a) and (b) ,

       1    1     0                   1   1   0

       0    1    0                   1    1    1

       0     1    1                  0    0    1

          (a)                            (b)

in figure (a) , we have

A(p) =2

C(p) =2

B(p) =4

in figure (b) , we have

A(p) =2

C(p) =1

B(p) =5







2 The Zhang-Suen Skeletonizatoin Algorithm的具体实现

    (1)

    function out=zseven(nbhd);
    s=sum(nbhd(:))-nbhd(5);
    temp1=(2<=s)&(s<=6);
    p=[nbhd(1) nbhd(4) nbhd(7) nbhd(8) nbhd(9) nbhd(6) nbhd(3) nbhd(2)];
    pp=[p(2:8) p(1)];
    xp=sum((1-p).*pp);
    temp2=(xp==1);
    prod1=nbhd(4)*nbhd(8)*nbhd(2);
    prod2=nbhd(4)*nbhd(6)*nbhd(2);
    temp3=(prod1==0)&(prod2==0);
    if temp1&temp2&temp3&nbhd(5)==1
         out=0;
    else
        out=nbhd(5);
    end;

   (2)

function out=zsodd(nbhd);
    s=sum(nbhd(:))-nbhd(5);
    temp1=(2<=s)&(s<=6);
    p=[nbhd(1) nbhd(4) nbhd(7) nbhd(8) nbhd(9) nbhd(6) nbhd(3) nbhd(2)];
    pp=[p(2:8) p(1)];
    xp=sum((1-p).*pp);
    temp2=(xp==1);
    prod1=nbhd(4)*nbhd(8)*nbhd(6);
    prod2=nbhd(8)*nbhd(6)*nbhd(2);
    temp3=(prod1==0)&(prod2==0);
    if temp1&temp2&temp3&nbhd(5)==1
         out=0;
    else
        out=nbhd(5);
    end;

(3)

function out=zs(im)
%
%zs appises the Zhang-Suen skeletonization algorithm to image IM. IM must
%be binary.
%
luteven=makelut('zseven',3);
lutodd=makelut('zsodd',3);
done=0;
N=2;
last=im;
previous=applylut(last ,lutodd);
current=applylut(previous,luteven);
while done==0,
    if all(current(:)==last(:)),
        done=1;
    end
    N=N+1;
    last=previous;
    previous=current;
    if mod(N,2)==0,
        current=applylut(current,luteven);
    else
        current=applylut(current,lutodd);
    end;
end;
out=current;

3 实例:


Example:

L =

     0     0     0     0     0     0     0     0     0     0
     0     1     1     1     1     1     0     0     0     0
     0     1     1     1     1     1     0     0     0     0
     0     1     1     1     1     1     0     0     0     0
     0     1     1     1     1     1     0     0     0     0
     0     1     1     1     1     1     0     0     0     0
     0     1     1     1     1     1     1     1     1     0
     0     1     1     1     1     1     1     1     1     0
     0     1     1     1     1     1     1     1     1     0
     0     1     1     1     1     1     1     1     1     0
     0     1     1     1     1     1     1     1     1     0
     0     0     0     0     0     0     0     0     0     0

Result:

Ls=zs(L)

Ls =

     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0
     0     0     0     1     0     0     0     0     0     0
     0     0     0     1     0     0     0     0     0     0
     0     0     0     1     0     0     0     0     0     0
     0     0     0     1     0     0     0     0     0     0
     0     0     0     1     0     0     0     0     0     0
     0     0     0     1     1     1     0     0     0     0
     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0


实际图象细化的例子:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -