Advertisement
Kojima0502

☆COMBINE_PF☆

Jan 27th, 2014
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.65 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main(int argc,char *argv[])
  6. {
  7.     FILE *fpi1,*fpi2,*fpo;
  8.     int i,j,height1,width1,height2,width2;
  9.     float dn1;
  10.     int x,y;
  11.     int re;
  12.     int ix,iy;
  13.     float *file1,*file2;//,*file3;
  14.     int iw,ih,iW,iH;
  15.    
  16.     if(argc!=11)
  17.     {
  18.         fprintf(stderr,"Usage: %s\n(2)Input_file1_filename\n(3)Input_file2_filename\n(4)Output_new_filename\n(5)width1\n(6)height1\n(7)width2\n(8)height2\n(9)x\n(10)y\n(11)re\n",argv[0]);
  19.         exit(1);
  20.     }
  21.    
  22.     printf("OPEN R FILE NAME:%s\n",argv[1]);
  23.     printf("OPEN NIR FILE NAME:\%s\n",argv[2]);
  24.     printf("OPEN OUTPUT FILE NAME:%s\n",argv[3]);
  25.    
  26.     width1 = atoi(argv[4]); printf("W = %d,", width1);
  27.     iw=width1/10;
  28.    
  29.     height1 = atoi(argv[5]); printf("H = %d\n", height1);
  30.     ih=height1/10;
  31.    
  32.     width2 = atoi(argv[6]); printf("W = %d,", width2);
  33.     iW=width2/10;
  34.    
  35.     height2 = atoi(argv[7]); printf("H = %d\n", height2);
  36.     iH=height2/10;
  37.    
  38.     x = atoi(argv[8]); printf("X = %d\n" , x);
  39.     y = atoi(argv[9]); printf("Y = %d\n" , y);
  40.     re = atoi(argv[10]); printf("RE = %d\n" , re);
  41.     ix=x*re/10;
  42.     iy=y*re/10;
  43.    
  44.     printf("check00\n");
  45.    
  46.     file1= (float *)malloc(iw*ih*sizeof(float));
  47.     file2= (float *)malloc(iW*iH*sizeof(float));
  48.     //file3= (float *)malloc(width1*height1*sizeof(float));
  49.    
  50.     printf("check0\n");
  51.    
  52.     if((fpi1=fopen(argv[1],"rb+"))==NULL)
  53.     {
  54.         fprintf(stderr,"input file open error\n");
  55.         exit(1);
  56.     }
  57.     printf("check0-1\n");
  58.     fread((float *)file1,sizeof(float),iw*ih,fpi1);
  59.     printf("check0-2\n");
  60.     if((fpi2=fopen(argv[2],"rb"))==NULL)
  61.     {
  62.         fprintf(stderr,"input file open error\n");
  63.         exit(1);
  64.     }
  65.     printf("check0-3\n");
  66.     fread((float *)file2,sizeof(float),iW*iH,fpi2);
  67.     printf("check0-4\n");
  68.     if((fpo=fopen(argv[3],"wb"))==NULL)
  69.     {
  70.         fprintf(stderr,"output file open error\n");
  71.         exit(1);
  72.     }
  73.     //fread((float *)file3,sizeof(float),width1*height1,fpo);
  74.     printf("check1\n");
  75.     for(i=0;i<ih;i++)
  76.     {
  77.         for(j=0;j<iw;j++)
  78.         {
  79.             if(i>iy && i<iy+iH && j>ix && j<ix+iW)
  80.             {
  81.                 dn1=file2[(i-iy)*iW+(j-ix)];
  82.             }
  83.            // else
  84.            // {
  85.                // dn1=file1[i*iw+j];
  86.             //}
  87.             //printf("check3\n");
  88.             //fwrite(&dn1,sizeof(float),1,fpo);
  89.             //printf("i=%d j=%d dn1=%f\n",i,j,dn1);
  90.         }
  91.     }
  92.     printf("check2\n");
  93.    
  94.     free(file1);
  95.     free(file2);
  96.     //free(file3);
  97.     fclose(fpi1);
  98.     fclose(fpi2);
  99.     fclose(fpo);
  100.    
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement