#include #include"hensu.h" #define L_BASE 100 void labelset(LPDWORD image,int xs,int ys,int label) { int x,y,cnt,xm,xp,ym,yp; image[xs+ys*iWidth]=RGB(label,label,label); for(;;){ cnt=0; for(y=0;yiWidth-1) xp=iWidth-1; if(ym<0) ym=0; if(yp>iHeight-1) yp=iHeight-1; if(image[xm+ym*iWidth]==HIGH){ image[xm+ym*iWidth]=RGB(label,label,label); cnt++; } if(image[x+ym*iWidth]==HIGH){ image[x+ym*iWidth]=RGB(label,label,label); cnt++; } if(image[xp+ym*iWidth]==HIGH){ image[xp+ym*iWidth]=RGB(label,label,label); cnt++; } if(image[xm+y*iWidth]==HIGH){ image[xm+y*iWidth]=RGB(label,label,label); cnt++; } if(image[xp+y*iWidth]==HIGH){ image[xp+y*iWidth]=RGB(label,label,label); cnt++; } if(image[xm+yp*iWidth]==HIGH){ image[xm+yp*iWidth]=RGB(label,label,label); cnt++; } if(image[x+yp*iWidth]==HIGH){ image[x+yp*iWidth]=RGB(label,label,label); cnt++; } if(image[xp+yp*iWidth]==HIGH){ image[xp+yp*iWidth]=RGB(label,label,label); cnt++; } } if(cnt==0) break; } } int labeling(LPDWORD image_in,LPDWORD image_label,int *cnt,char *buf) { int x,y,label; for(y=0;y=(BYTE)HIGH){ sprintf(buf,"--Error! too many labels.\n"); return -1; } labelset(image_label,x,y,label); label++; } *cnt=label-L_BASE; sprintf(buf," number of labels : %d \n",*cnt); return 0; } #define PI 3.14159265 #define ROOT2 1.41421356 double calc_size(LPDWORD image_label,int label,int *cx,int *cy) { int x,y; double tx,ty,total; tx=0; ty=0; total=0; for(y=0;y=ratio_min && ratio[i]<=ratio_max) lno[j++]=L_BASE+i; for(y=0;y