/* ---------------------------------------- Image Processing pf1.c Affine Transformation Ichinoseki National College Advanced Course ------------------------------------------ */ #include #include #include main(argc,argv) int argc; char *argv[]; { static int i,j,m,n,x,y,u,v,x0,y0,u0,v0; static int pixel,line; static double a,b,c,d,e,f; static int g[1000*1000]; static int h[1000*1000]; FILE *fp1,*fp2; a=0.70711;/*cos(45)*/ b=0.70711;/*sin(45)*/ c=0; d=-0.70711/*sin(45)*/; e=0.70711;/*sin(45)*/ f=0; x0=0; y0=0; u0=0; v0=0; /* Command parameter check */ if (argc!=5){ printf("Usage : command input_file pixel line output_file\n"); return 1; } /* Image size parameter load */ sscanf(argv[2],"%d",&pixel); sscanf(argv[3],"%d",&line); if (pixel*line >= 3000000){ printf("Too big image size\n"); return 1; } /*回転軸の設定*/ x0=pixel/2; y0=line/2; u0=pixel/2; v0=line/2; /* 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[4],"w") )==NULL){ printf("Can't open output_file\n"); return 1; } /* Skip header data of Input Image */ fseek(fp1,60,0); /* Load Image Data from Input File to Image Array */ for (j=0; jpixel || y<0 || y>line){ h[j*pixel+i]=0; } else{ h[j*pixel+i]=g[y*pixel+x]; } } } /* ppm header output */ fprintf(fp2,"P5\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