static size_t count_rc(wtreeNode_t* node) { if (!node) return 0; if (!node->right && !node->left) return 1; if (node->right && node->left) return count_rc(node->left) + count_rc(node->right) + 1; if (!node->right) return count_rc(node->left) + 1; if (!node->left) return count_rc(node->right) + 1; return 0; }
size_t wtree_nodeCount(wtreeRoot_t* root) { if(!root) return 0; if(!root->entry) return 0; return count_rc(root->entry); }
int main(int argc,char* argv[]) { int *x; int i,j;int result; int fx,fy; x=count_rc(argv[1]); /* the pgm file is given as input ; returns #row, #col*/ row=*(x+1); col=*x; //row=row/2;col=col/2; cdata =(int*)malloc(row*col*sizeof(int)); newimage=(int*)malloc(row*col*sizeof(int)); direc=(int*)malloc(row*col*sizeof(int)); mat=(int*)malloc(row*col*sizeof(int)); v=(Vertex*)malloc(row*col*sizeof(Vertex)); get_the_mat(argv[1],row,col); /* input image read -- fill mat*/ myfilter(row,col); printf("enter the relaxation\n"); scanf("%d",&relax); for(i=0;i<row;i++) { for(j=0;j<col;j++) { *(newimage+i*col+j)=255; } } for(i=0;i<row;i++) for(j=0;j<col;j++) { /* fy= (*(mat+(i-1)*col+(j-1))-*(mat+(i+1)*col+(j-1))) + (*(mat+(i-1)*col+(j))-*(mat+(i+1)*col+(j))) + (*(mat+(i-1)*col+(j+1))-*(mat+(i+1)*col+(j+1))); fy=fy/6; fx= (*(mat+(i-1)*col+(j+1))-*(mat+(i-1)*col+(j-1))) + (*(mat+(i)*col+(j+1))-*(mat+(i)*col+(j-1))) + (*(mat+(i+1)*col+(j+1))-*(mat+(i+1)*col+(j-1))); fx=fx/6; result=sqrt(pow(fx,2)+pow(fy,2)); *(cdata+i*col+j)=result; */ *(cdata+i*col+j)=prewitt(i,j,row,col); } find_max(row,col); build_image(row,col, argv[1]);/*build image -- uses cdata*/ return 0; } /* main end*/
/*---------------------------------------*/ main(int argc,char* argv[]) { int *x,flag=0; int i,j,vc=0; FILE *fm=fopen("mat.dat","w"); FILE *fv=fopen("ver.dat","w"); x=count_rc(argv[1]); /* the pgm file is given as input ; returns #row, #col*/ row=*(x+1); col=*x; printf("%d\t%d\n",row,col); get_the_mat(argv[1],row,col); /* input image read -- fill mat*/ cdata =(int *)malloc(row*col*sizeof(int)); visited =(int *)malloc(row*col*sizeof(int)); taken =(int *)malloc(row*col*sizeof(int)); printf("Enter alpha: "); scanf("%f",&alpha); printf("Enter beta: "); scanf("%f",&beta); for(i=0;i<row;i++) { for(j=0;j<col;j++) { if(*(mat+i*col+j)==0) { *(cdata+i*col+j)=0; fprintf(fv,"%d\t%d\n",i,j); count0++; } fprintf(fm,"%d\t",*(mat+i*col+j)); *(cdata+i*col+j)=255; *(visited+i*col+j)=0; *(taken+i*col+j)=0; } fprintf(fm,"\n"); } fprintf(fm,"\n"); fclose(fm); fclose(fv); v=(vertx *)malloc(count0*sizeof(int)); direc=(int *)malloc(count0*sizeof(int)); for(i=0;i<row;i++) for(j=0;j<col;j++) if(*(mat+i*col+j)==0) *(cdata+i*col+j)=0; for(i=0;i<row;i++) { for(j=0;j<col;j++) { if(*(mat+i*col+j)==0 && *(taken+i*col+j)==0) {omega=0.0;ep=0.0;vdev=0.0;vcount=0;totvd=0.0;totrd=0.0;mark=0;vdcount=0;rdcount=0;x=0; printf("Calling for %d row, %d col\n",i,j); poly(i,j); //flag=1; }//if(flag) break; }//if(flag) break; } //poly(i,j); /* for(i=0;i<row;i++) for(j=0;j<col;j++) if(*(visited+i*col+j)==1) fprintf(fv,"%d\t%d\n",i,j); fclose(fv);*/ build_image(row,col, argv[1]);/*build image -- uses cdata*/ }
/*---------------------------------------*/ main(int argc,char* argv[]) { vertx vprev; int *x; int i,j,vc=0,m,cntr=0; FILE *fm=fopen("mat.dat","w"); FILE *fp=fopen("ver.dat","w"); FILE *fv=fopen("vis.dat","w"); FILE *ft=fopen("taken.dat","w"); x=count_rc(argv[1]); /* the pgm file is given as input ; returns #row, #col*/ row=*(x+1); col=*x; //printf("%d\t%d\n",row,col); get_the_mat(argv[1],row,col); /* input image read -- fill mat*/ cdata =(int*)malloc(row*col*sizeof(int)); visited =(int*)malloc(row*col*sizeof(int)); for(i=0;i<row;i++) { for(j=0;j<col;j++){ if(*(mat+i*col+j)==0) {vcount++; *(cdata+i*col+j)=0;} fprintf(fm,"%d\t",*(mat+i*col+j)); *(cdata+i*col+j)=255; *(visited+i*col+j)=0; }fprintf(fm,"\n"); }fprintf(fm,"\n");fclose(fm); v=(vertx *)malloc((vcount)*sizeof(vertx)); for(i=0;i<row && vc<vcount;i++) { for(j=0;j<col && vc<vcount;j++) if(*(mat+i*col+j)==0) { v[vc].i=i; v[vc].j=j;v[vc].yes=0; vc++;*(cdata+i*col+j)=0; fprintf(fp,"%d\t%d\n",i,j); } }fclose(fp); printf("Enter alpha: "); scanf("%f",&alpha); printf("Enter beta: "); scanf("%f",&beta); printf("vcount:%d\n",vcount); vc=vcount; vcount>>1; vd=(int *)malloc(vcount*(sizeof(int))); rd=(int *)malloc(vcount*(sizeof(int))); vcount=vc; start(v,0,vcount); for(i=0;i<row;i++) for(j=0;j<col;j++) if(*(visited+i*col+j)==1) fprintf(fv,"%d\t%d\n",i,j); fclose(fv);//cntr=0; for(vc=0;vc<vcount;vc++) { if(v[vc].yes==1) {fprintf(ft,"%d\t%d\n",v[vc].i,v[vc].j);//cntr++; *(cdata+(v[vc].i)*col+(v[vc].j))=9; //if(cntr>1) // bresenham_line(v[vc].i,v[vc].j,vprev.i,vprev.j,col); //vprev=v[vc]; } } fclose(ft); build_image(row,col, argv[1]);/*build image -- uses cdata*/ } /* main end*/