Esempio n. 1
0
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*/  
Esempio n. 2
0
File: aidp.c Progetto: punu92/aidp
/*---------------------------------------*/
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*/   
                        }
Esempio n. 3
0
int main(int argc, char* argv[])
{
	int o, rc;

	memset(&im, 0, sizeof(im));

	strcpy(im.outputfile, DEFAULT_OUTPUT_FILE);
	strcpy(im.version, DEFAULT_VERSION);
	memcpy(im.magic, MAGIC_HEADER, MAGIC_LENGTH);
	im.flash_baseaddr = DEFAULT_FLASH_BASE;

	while ((o = getopt(argc, argv, "f:hm:o:p:v:z")) != -1)
	{
		switch (o) {
		case 'f':
			if (optarg)
				if (str2u32(optarg, &im.flash_baseaddr)) {
					ERROR("Invalid flash start address %s\n", optarg);
					return -1;
				}
			break;
		case 'h':
			usage(argv[0]);
			return -1;
		case 'm':
			if (optarg) {
				if (strlen(optarg) != MAGIC_LENGTH) {
					ERROR("Invalid magic %s\n", optarg);
					return -1;
				}

				memcpy(im.magic, optarg, MAGIC_LENGTH);
			}
			break;
		case 'o':
			if (optarg)
				strncpy(im.outputfile, optarg, sizeof(im.outputfile));
			break;
		case 'p':
			if (optarg) {
				if (image_layout_add_partition(optarg))
					return -1;
			}
			break;
		case 'v':
			if (optarg)
				strncpy(im.version, optarg, sizeof(im.version));
			break;
		case 'z':
			zero_part_baseaddr = 1;
			break;
		}
	}

	rc = image_layout_verify();
	if (rc)	{
		ERROR("Failed validating firmware layout - error code: %d\n",
				rc);
		return -4;
	}

	print_image_info();

	rc = build_image();
	if (rc)	{
		ERROR("Failed building image file '%s' - error code: %d\n",
				im.outputfile, rc);
		return -5;
	}

	return 0;
}
Esempio n. 4
0
int main(int argc, char* argv[])
{
	char kernelfile[PATH_MAX];
	char rootfsfile[PATH_MAX];
	int o, rc;
	image_info_t im;

	memset(&im, 0, sizeof(im));
	memset(kernelfile, 0, sizeof(kernelfile));
	memset(rootfsfile, 0, sizeof(rootfsfile));

	strcpy(im.outputfile, DEFAULT_OUTPUT_FILE);
	strcpy(im.version, DEFAULT_VERSION);

	while ((o = getopt(argc, argv, OPTIONS)) != -1)
	{
		switch (o) {
		case 'v':
			if (optarg)
				strncpy(im.version, optarg, sizeof(im.version));
			break;
		case 'o':
			if (optarg)
				strncpy(im.outputfile, optarg, sizeof(im.outputfile));
			break;
		case 'h':
			usage(argv[0]);
			return -1;
		case 'k':
			if (optarg)
				strncpy(kernelfile, optarg, sizeof(kernelfile));
			break;
		case 'r':
			if (optarg)
				strncpy(rootfsfile, optarg, sizeof(rootfsfile));
			break;
		case 's':
			if (optarg)
				#undef partition_startaddr
				#define partition_startaddr	(optarg)
			break;
		}
	}

	if (strlen(kernelfile) == 0)
	{
		ERROR("Kernel file is not specified, cannot continue\n");
		usage(argv[0]);
		return -2;
	}

	if (strlen(rootfsfile) == 0)
	{
		ERROR("Root FS file is not specified, cannot continue\n");
		usage(argv[0]);
		return -2;
	}

	if ((rc = create_image_layout(kernelfile, rootfsfile, &im)) != 0)
	{
		ERROR("Failed creating firmware layout description - error code: %d\n", rc);
		return -3;
	}

	if ((rc = validate_image_layout(&im)) != 0)
	{
		ERROR("Failed validating firmware layout - error code: %d\n", rc);
		return -4;
	}

	print_image_info(&im);

	if ((rc = build_image(&im)) != 0)
	{
		ERROR("Failed building image file '%s' - error code: %d\n", im.outputfile, rc);
		return -5;
	}

	return 0;
}
Esempio n. 5
0
int main(int argc, char* argv[])
{
	char inputfile[PATH_MAX];
	int o, rc;
	image_info_t im;

	memset(&im, 0, sizeof(im));
	memset(inputfile, 0, sizeof(inputfile));

	strcpy(im.outputfile, DEFAULT_OUTPUT_FILE);
	strcpy(im.version, DEFAULT_VERSION);

	while ((o = getopt(argc, argv, OPTIONS)) != -1)
	{
		switch (o) {
		case 'v':
			if (optarg)
				strncpy(im.version, optarg, sizeof(im.version));
			break;
		case 'o':
			if (optarg)
				strncpy(im.outputfile, optarg, sizeof(im.outputfile));
			break;
		case 'i':
			if (optarg)
				strncpy(inputfile, optarg, sizeof(inputfile));
			break;
		case 'h':
			usage(argv[0]);
			return -1;
		}
	}

	if (strlen(inputfile) == 0)
	{
		ERROR("Input file is not specified, cannot continue\n");
		usage(argv[0]);
		return -2;
	}

	if ((rc = parse_image_layout(inputfile, &im)) != 0)
	{
		ERROR("Failed parsing firmware layout file '%s' - error code: %d\n", 
			inputfile, rc);
		return -3;
	}

	if ((rc = validate_image_layout(&im)) != 0)
	{
		ERROR("Failed validating firmware layout - error code: %d\n", rc);
		return -4;
	}

	print_image_info(&im);

	if ((rc = build_image(&im)) != 0)
	{
		ERROR("Failed building image file '%s' - error code: %d\n", im.outputfile, rc);
		return -5;
	}

	return 0;
}
Esempio n. 6
0
File: aidp1.c Progetto: punu92/aidp
/*---------------------------------------*/
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*/