/* ---------------------------------------- Image Processing pe1.c File Image Data Processing Ichinoseki National College Advanced Course ------------------------------------------ */ #include #include #include main(argc,argv) int argc; char *argv[]; { static int i,j,m,n; static int pixel,line; static double a,b,x,y; static int g[1000*1000*3]; FILE *fp1,*fp2;/*fp1は入力、fp2は出力*/ /* Command parameter check */ if (argc!=7){ printf("Usage : command input_file pixel line A B output_file\n"); return 1; } /* Image size parameter load */ sscanf(argv[2],"%d",&pixel); sscanf(argv[3],"%d",&line); sscanf(argv[4],"%lf",&a); sscanf(argv[5],"%lf",&b);/**/ if (pixel*line >= 3000000){ printf("Too big image size\n"); return 1; } /* Input image file check */ if (( fp1=fopen(argv[1],"r") )==NULL){ printf("Can't open input_file\n"); return 1; } /* Output image file check */ if (( fp2=fopen(argv[6],"w") )==NULL){ printf("Can't open output_file\n"); return 1; } /* Skip header data of Input Image */ fseek(fp1,60,0); /* Load Color Image Data from Input File to Image Array */ for (j=0; j255)? 255:m; m=(m<0)? 0:m; g[3*(j*pixel+i)+0]=m; /*green*/ m=(int)(a*(double)getc(fp1)+b); m=(m>255)? 255:m; m=(m<0)? 0:m; g[3*(j*pixel+i)+1]=m; /*blue*/ m=(int)(a*(double)getc(fp1)+b); m=(m>255)? 255:m; m=(m<0)? 0:m; g[3*(j*pixel+i)+2]=m; } } /* ppm header output */ fprintf(fp2,"P6\n"); fprintf(fp2,"# INCT\n"); fprintf(fp2,"%s %s\n",argv[2],argv[3]); fprintf(fp2,"255\n"); /* Output from Image Array to Image file */ for (j=0; j