乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      圖像細(xì)化(骨架化)算法 分析

       學(xué)海無(wú)涯GL 2012-09-11

      圖像細(xì)化(骨架化)算法 分析

      圖像的細(xì)化是模式識(shí)別中很重要的一個(gè)技術(shù),指的是將原本"臃腫"的像素簡(jiǎn)化為單像素相連接的二值圖像(即類似骨架的概念),細(xì)化的好壞直接影響到后面識(shí)別匹配的效率。

      摘自某文章的話,細(xì)化就是經(jīng)過(guò)一層層的剝離,從原來(lái)的圖中去掉一些點(diǎn),但仍要保持原來(lái)的形狀,直到得到圖像的骨架。骨架,可以理解為圖象的中軸,例如一個(gè)長(zhǎng)方形的骨架是它的長(zhǎng)方向上的中軸線;正方形的骨架是它的中心點(diǎn);圓的骨架是它的圓心,直線的骨架是它自身,孤立點(diǎn)的骨架也是自身。

      下面先介紹經(jīng)典的Zhang并行快速細(xì)化算法:

      設(shè)p1點(diǎn)的八鄰域?yàn)椋?/p>

      【 p9 p2 p3

      p8 p1 p4

      p7 p6 p5 】

      (其中p1為白點(diǎn),如果以下四個(gè)條件同時(shí)滿足,則刪除p1,即令p1=0)

      其中迭代分為兩個(gè)子過(guò)程:

      過(guò)程1 細(xì)化刪除條件為: (1)、2 < =N(p1) <= 6, N(x)為x的8鄰域中黑點(diǎn)的數(shù)目

      (2)、A(p1)=1, A(x)指的是將p2-p8之間按序前后分別為0、1的對(duì)數(shù)(背景色:0

      (3)、p2*p4*p6=0

      (4)、p4*p6*p8=0

      如果同時(shí)滿足以上四個(gè)條件則該點(diǎn)可以刪除(賦值為0)。

      過(guò)程2 細(xì)化刪除條件為: (1)、2 < =N(p1) <= 6, N(x)為x的8鄰域中黑點(diǎn)的數(shù)目

      (2)、A(p1)=1, A(x)指的是將p2-p8之間按序前后分別為0、1的對(duì)數(shù)(背景色:0

      (3)、p2*p4*p8=0

      (4)、p2*p6*p8=0

      如果同時(shí)滿足以上四個(gè)條件則該點(diǎn)可以刪除。

      代碼如下:

      A.m

      復(fù)制代碼
      1 function n=A(temp,i,j)
      2 %0->1的數(shù)目
      3 shuzu=[temp(i,j),temp(i-1,j),temp(i-1,j+1),temp(i,j+1),temp(i+1,j+1),temp(i+1,j),temp(i+1,j-1),temp(i,j-1),temp(i-1,j-1)];
      4 n=0;
      5 for i=2:8
      6 if shuzu(i)==0&&shuzu(i+1)==1
      7 n=n+1;
      8 end
      9 end
      復(fù)制代碼

      主函數(shù)代碼:

      復(fù)制代碼
       1 test=input('Please input a digits image:','s'); %輸入圖像
      2 x=imread(test);
      3 if ~isbw(x)
      4 '請(qǐng)確保輸入圖像為二值化圖像!';
      5 else
      6 [height,width]=size(x);
      7 mark=1;
      8 % temp=zeros(height+2,width+2);
      9 % temp(2:height+1,2:width+1)=x(:,:);
      10 temp=x;
      11 imshow(temp);
      12 while mark==1
      13 mark=0;
      14
      15 for i=2:height-1
      16 for j=2:width-1
      17 condition=0;
      18 %判斷P(r,c)是否為可細(xì)化像素
      19 if temp(i,j)==1
      20 n=0;
      21 for ii=-1:1
      22 for jj=-1:1
      23 n=n+temp(i+ii,j+jj);
      24 end
      25 end
      26 if (n>=3 && n<=7)
      27 condition=condition+1;
      28 end
      29 if A(temp,i,j)==1
      30 condition=condition+1;
      31 end
      32 if temp(i-1,j)*temp(i,j+1)*temp(i+1,j)==0
      33 condition=condition+1;
      34 end
      35 if temp(i,j+1)*temp(i+1,j)*temp(i,j-1)==0
      36 condition=condition+1;
      37 end
      38 if condition==4
      39 mark=1;
      40 temp(i,j)=0;
      41 end
      42 end
      43 end
      44 end
      45 figure;imshow(temp);
      46
      47
      48 for i=2:height-1
      49 for j=2:width-1
      50 condition=0;
      51 %判斷P(r,c)是否為可細(xì)化像素
      52 if temp(i,j)==1
      53 n=0;
      54 for ii=-1:1
      55 for jj=-1:1
      56 n=n+temp(i+ii,j+jj);
      57 end
      58 end
      59 if (n>=3 && n<=7)
      60 condition=condition+1;
      61 end
      62 if A(temp,i,j)==1
      63 condition=condition+1;
      64 end
      65 if temp(i-1,j)*temp(i,j+1)*temp(i,j-1)==0
      66 condition=condition+1;
      67 end
      68 if temp(i,j-1)*temp(i+1,j)*temp(i,j-1)==0
      69 condition=condition+1;
      70 end
      71 if condition==4
      72 mark=1;
      73 temp(i,j)=0;
      74 end
      75 end
      76 end
      77 end
      78 figure;imshow(temp);
      79 end
      80 end
      復(fù)制代碼

      結(jié)果:



        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多