본문 바로가기
IT-개발,DB

[영역처리] Thinning (세선화) --- ③

by SB리치퍼슨 2016. 7. 4.

[영역처리] Thinning (세선화) --- ③


2003.09.01


위의 그림은 알고리즘을 적용한 실험결과.


Zhang Suen 세선화 알고리즘의 주요부분임.


소스코드(주요부분) 

   // mark and delete pixels. 
   While Again = 1 Do 
   Begin 
       again := 0; 
       // Second sub-iteration. 
       For row := 1 To sy -2 Do 
           For col := 1 To sx -2 Do 
           Begin 
               If tTgt[col, row] <> 1 Then 
                   Continue; 
               k := nays8(tTgt, col, row); 
               If ( (k >= 2) And (k <= 6) ) And (Connectivity(tTgt, col, row) = 1) Then 
               Begin 
                   If ( tTgt[col+1, row] * tTgt[col, row-1] * tTgt[col-1, row] = 0) And 
                     ( tTgt[col, row-1] * tTgt[col, row+1] * tTgt[col-1, row] = 0) Then 
                   Begin 
                       localTgt[col, row] := 1; 
                       again := 1; 
                   End; 
                   // of if ..else. 
               End // End of if tTgt. 
           End; // Of For col. 
       // End of For row. 

       // delete pixel. 
       DeletePixel(tTgt, localTgt); 
       If Again = 0 Then 
           Break; 

       // First sub-iteration. 
       For row := 1 To sy -2 Do 
           For col := 1 To sx -2 Do 
           Begin 
               If tTgt[col, row] <> 1 Then 
                   Continue; 
               k := nays8(tTgt, col, row); 
               If ( (k >= 2) And (k <= 6) ) And (Connectivity(tTgt, col, row) = 1) Then 
               Begin 
                   If ( tTgt[col, row-1] * tTgt[col+1, row] * tTgt[col, row+1] = 0) And 
                     ( tTgt[col+1, row] * tTgt[col, row+1] * tTgt[col-1, row] = 0) Then 
                   Begin 
                       localTgt[col, row] := 1; 
                       again := 1; 
                   End; 
                   // of if ..else. 
               End // End of if tTgt. 
           End; // Of For col. 
       // End of For row. 

       // delete pixel. 
       deletePixel(tTgt, localTgt); 
   End; // of While Again. 





반응형

댓글