Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main(int argc,char *argv[])
- {
- FILE *fpi1,*fpi2,*fpo;
- int i,j,height1,width1,height2,width2;
- float dn1;
- int x,y;
- int re;
- int ix,iy;
- int iw,ih,iW,iH;
- float *file1,*file2;//,*file3;
- if(argc!=11)
- {
- 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]);
- exit(1);
- }
- printf("OPEN R FILE NAME:%s\n",argv[1]);
- printf("OPEN NIR FILE NAME:\%s\n",argv[2]);
- printf("OPEN OUTPUT FILE NAME:%s\n",argv[3]);
- width1 = atoi(argv[4]); printf("W = %d,", width1); //large
- iw=width1/10;
- height1 = atoi(argv[5]); printf("H = %d\n", height1);//large
- ih=height1/10;
- width2 = atoi(argv[6]); printf("W = %d,", width2); //small
- iW=width2/10;
- height2 = atoi(argv[7]); printf("H = %d\n", height2); //small
- iH=height2/10;
- x = atoi(argv[8]); printf("X = %d\n" , x); //upper Left
- y = atoi(argv[9]); printf("Y = %d\n" , y); //upper Left
- re = atoi(argv[10]); printf("RE = %d\n" , re);
- ix=x*re/10; //image coordinate of upper left : X
- iy=y*re/10; //image coordinate of upper left : Y
- printf("check00\n");
- file1= (float *)malloc(iw*ih*sizeof(float)); //large
- file2= (float *)malloc(iW*iH*sizeof(float)); //small
- //file3= (float *)malloc(width1*height1*sizeof(float));
- // printf("check0\n");
- //large
- if((fpi1=fopen(argv[1],"rb+"))==NULL)
- {
- fprintf(stderr,"input file open error\n");
- exit(1);
- }
- printf("check0-1\n");
- fread((float *)file1,sizeof(float),iw*ih,fpi1);//large
- printf("check0-2\n");
- //small
- if((fpi2=fopen(argv[2],"rb"))==NULL)
- {
- fprintf(stderr,"input file open error\n");
- exit(1);
- }
- printf("check0-3\n");
- fread((float *)file2,sizeof(float),iW*iH,fpi2);//small
- printf("check0-4\n");
- /*
- if((fpo=fopen(argv[3],"wb"))==NULL)
- {
- fprintf(stderr,"output file open error\n");
- exit(1);
- }
- */
- //fread((float *)file3,sizeof(float),width1*height1,fpo);
- printf("check1\n");
- for(i=0;i<ih;i++)
- {
- for(j=0;j<iw;j++)
- {
- if(i>iy && i<iy+iH && j>ix && j<ix+iW)
- {
- file1[i*iw+j]=file2[(i-iy)*iW+(j-ix)];
- }
- //else
- // {
- // dn1=file1[i*iw+j];
- //}
- //printf("check3\n");
- //fwrite(&dn1,sizeof(float),1,fpo);
- //printf("i=%d j=%d dn1=%f\n",i,j,dn1);
- }
- }
- printf("check2\n");
- free(file1);
- free(file2);
- //free(file3);
- fclose(fpi1);
- fclose(fpi2);
- fclose(fpo);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement