分享

基于zhang 的骨架提取

 文清阳 2017-08-10
    最近在学图像处理的骨架提取,发现很多中文教材对这个方面讲的很有欠缺,于是我决定看英文原文的论文。看了2篇论文,“A fast parallel algorithm for thinning digital patterns” by T.Y. Zhang and C.Y. Suen.以及Parallel thinning with two sub-iteration algorithms” by Zicheng Guo and Richard Hall.。
    看了论文后,发现中文一些教材只是简单截取了论文的片段,导致无法理解(即便是天才,没介绍参数的意义应该也不懂吧)。后来,还发现了3个将其算法用opencv实现的代码。网址如下:
    基于以上,已经完美的完成了项目的运行需求。
     Zhang and C.Y. Suen的图像骨架提取算法可以得到比较平滑的边界。具体的算法如下:
基于zhang <wbr>的骨架提取
    定义,B(P1)为p1点的非零邻域的个数,A(P1)为p1点周围8个像素点灰度值以0-1顺序排列的个数(一部分国内教材没介绍A(P1)的具体含义,导致看不懂原理),如上图所示。之后,进行对每个像素点如下图所示操作:
基于zhang <wbr>的骨架提取    该算法的伪代码如下所示:

Zhang-Suen thinning steps:

  1. While points are deleted do
  2.     For all pixels p(i,j) do
  3.         if (a) 2 ≤ B(P1) ≤ 6
               (b) A(P1) = 1
               (c) Apply one of the following:
                  1. P2 x P4 x P6 = 0 in odd iterations
                  2. P2 x P4 x P8 = 0 in even iterations
               (d) Apply one of the following:
                  1. P4 x P6 x P8 = 0 in odd iterations
                  2. P2 x P6 x P8 = 0 in even iterations
            then
  4.            Delete pixel p(i,j)
  5.         end if
  6.     end for
  7. end while

Where A(P1) is the number of 0 to 1 transitions in a clockwise direction from P9 back to itself, and B(P1) is the number of non-zero neighbors of P1.

    我在国外上面的链接上找到了这个算法的opencv编程实现,效率很高。源代码和用法见文件内(thin.cpp):

http://pan.baidu.com/s/1yFzUe。



    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多