圖像細化算法大全.doc
《圖像細化算法大全.doc》由会员分享,可在线阅读,更多相关《圖像細化算法大全.doc(18页珍藏版)》请在文库网上搜索。
1、圖像細化算法大全 #include StdAfx.h#include #include void beforethin(unsigned char *ip, unsigned char *jp, unsigned long lx, unsigned long ly) unsigned long i,j; for(i=0; ily; i+) for(j=0; j0) jpi*lx+j=1; else jpi*lx+j=0; /Hilditch細化算法/功能:對圖像進行細化/參數:image:代表圖像的一維數組/ lx:圖像寬度/ ly:圖像高度/ 無返回值void ThinnerHilditch
2、(void *image, unsigned long lx, unsigned long ly) char *f, *g; char n10; unsigned int counter; short k, shori, xx, nrn; unsigned long i, j; long kk, kk11, kk12, kk13, kk21, kk22, kk23, kk31, kk32, kk33, size; size = (long)lx * (long)ly; g = (char *)malloc(size); if(g = NULL) printf(error in allocati
3、ng memory!/n); return; f = (char *)image; for(i=0; ilx; i+) for(j=0; jly; j+) kk=i*ly+j; if(fkk!=0) fkk=1; gkk=fkk; counter = 1; do printf(%4d*,counter); counter+; shori = 0; for(i=0; ilx; i+) for(j=0; jly; j+) kk = i*ly+j; if(fkk0) fkk = 0; gkk= fkk; for(i=1; ilx-1; i+) for(j=1; jly-1; j+) kk=i*ly+
4、j; if(fkk!=1) continue; kk11 = (i-1)*ly+j-1; kk12 = kk11 + 1; kk13 = kk12 + 1; kk21 = i*ly+j-1; kk22 = kk21 + 1; kk23 = kk22 + 1; kk31 = (i+1)*ly+j-1; kk32 = kk31 + 1; kk33 = kk32 + 1; if(gkk12&gkk21&gkk23&gkk32)!=0) continue; nrn = gkk11 + gkk12 + gkk13 + gkk21 + gkk23 + gkk31 + gkk32 + gkk33; if(n
5、rn = 1) fkk22 = 2; continue; n4 = fkk11; n3 = fkk12; n2 = fkk13; n5 = fkk21; n1 = fkk23; n6 = fkk31; n7 = fkk32; n8 = fkk33; n9 = n1; xx = 0; for(k=1; k8; k=k+2) if(!nk)&(nk+1|nk+2) xx+; if(xx!=1) fkk22 = 2; continue; if(fkk12 = -1) fkk12 = 0; n3 = 0; xx = 0; for(k=1; k8; k=k+2) if(!nk)&(nk+1|nk+2)
6、xx+; if(xx != 1) fkk12 = -1; continue; fkk12 = -1; n3 = -1; if(fkk21!=-1) fkk22 = -1; shori = 1; continue; fkk21 = 0; n5 = 0; xx = 0; for(k=1; k8; k=k+2) if(!nk)&(nk+1|nk+2) xx+; if(xx = 1) fkk21 = -1; fkk22 = -1; shori =1; else fkk21 = -1; while(shori); free(g); /Pavlidis細化算法/功能:對圖像進行細化/參數:image:代表
7、圖像的一維數組/ lx:圖像寬度/ ly:圖像高度/ 無返回值void ThinnerPavlidis(void *image, unsigned long lx, unsigned long ly) char erase, n8; char *f; unsigned char bdr1,bdr2,bdr4,bdr5; short c,k,b; unsigned long i,j; long kk,kk1,kk2,kk3; f = (char*)image; for(i=1; ilx-1; i+) for(j=1; jly-1; j+) kk = i*ly + j; if(fkk) fkk =
8、 1; for(i=0, kk1=0, kk2=ly-1; ilx; i+, kk1+=ly, kk2+=ly) fkk1=0; fkk2=0; for(j=0, kk=(lx-1)*ly; jly; j+,kk+) fj=0; fkk=0; c=5; erase =1; while(erase) c+; for(i=1; ilx-1; i+) for(j=1; jly-1; j+) kk=i*ly+j; if(fkk!=1) continue; kk1 = kk-ly -1; kk2 = kk1 + 1; kk3 = kk2 + 1; n3 = fkk1; n2 = fkk2; n1 = f
9、kk3; kk1 = kk - 1; kk3 = kk + 1; n4 = fkk1; n0 = fkk3; kk1 = kk + ly -1; kk2 = kk1 + 1; kk3 = kk2 + 1; n5 = fkk1; n6 = fkk2; n7 = fkk3; bdr1 =0; for(k=0; k=1) bdr1|=0x80k; if(bdr1&0252)= 0252) continue; fkk = 2; b=0; for(k=0; kk); if(b=1) fkk=3; if(bdr1&0160)!=0&(bdr1&07)!=0&(bdr1&0210)=0) fkk=3; el
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 圖像細化 算法 大全