/* ---------------------------------------- Image Processing pa1.c PGM Format Gray Image Data Generation Ichinoseki National College Advanced Course ------------------------------------------ */ #include #include #include main(argc,argv) int argc; char *argv[]; { static int i,j,m; static int pixel,line; FILE *fp1; /* Command parameter check */ if (argc!=4){ printf("Usage : command pixel line output_file\n"); return 1; } /* Image size parameter load */ sscanf(argv[1],"%d",&pixel); sscanf(argv[2],"%d",&line); /**/ if ( pixel*line>1000*1000){ printf("Over image size\n"); return 1; } /* Output image file name read */ if (( fp1=fopen(argv[3],"w") )==NULL){ printf("Can't open output_file\n"); return 1; } /* pnm(pgm) header code output */ fprintf(fp1,"P5\n"); /* Gray binary image data */ fprintf(fp1,"# INCT\n"); /* Comment */ fprintf(fp1,"%s %s\n",argv[1],argv[2]); /* Pixel Line Image size */ fprintf(fp1,"255\n"); /* Imade data maximum value */ /* Gray binary image data output */ for (i=0; i