/*--------------------------------------------------------------------- ファイングリッド giファイルのアルベド・輝度温度への変換 cct2br.c A.Kondoh 2001 ---------------------------------------------------------------------*/ #include #include #include #include #include #include #include #include #include #include #define HEADER_SIZE 80 #define BUFFER_SIZE 1448 #define NUMBER_OF_LINES 1448 #define NUMBER_OF_PIXELS 1448 #define FILE_ERR (-1) unsigned char buffer[BUFFER_SIZE]; unsigned short br[BUFFER_SIZE]; void main(argc,argv) int argc; char *argv[]; { int fi,fo; FILE *ft; int i,j; int number_of_lines; int number_of_pixels; int header_size; int isw; /* 1:ir1,2:ir2,3:wv */ int count; float vis[256],ir1[256],ir2[256],wv[256]; if(argc!=5){ printf("Usage: cct2br [input] [output] [table] [isw]\n"); printf("ISW: 0=VIS, 1=IR1, 2=IR2, 3=WV\n"); printf("Output:Unsigned 16-bit integer\n"); exit(-1); } isw=atoi(argv[4]); /* file open */ if ((fi=open(argv[1],O_RDONLY | O_BINARY))==FILE_ERR){ printf("Can't open %s.\n",argv[1]); exit(-1); } if( (fo=open(argv[2], O_RDWR | O_TRUNC | O_CREAT | O_BINARY, S_IREAD | S_IWRITE))==FILE_ERR){ printf("Can't open %s.\n",argv[2]); exit(-1); }/* end of output file open */ if((ft=fopen(argv[3],"rt"))==NULL){ printf("Can't open %s.\n",argv[3]); exit(-1); }/* end of table file open */ /* 校正表読み込み */ for(i=0;i<=255;i++){ fscanf(ft,"%d %f %f %f %f",&count,&vis[i],&ir1[i],&ir2[i],&wv[i]); if(count!=(int)i){ printf("error!\n"); exit(-1); } } /* 処理 */ number_of_lines=NUMBER_OF_LINES; number_of_pixels=NUMBER_OF_PIXELS; header_size=HEADER_SIZE; switch(isw){ case 0: printf("VIS processing.\n"); break; case 1: printf("IR1 processing.\n"); break; case 2: printf("IR2 processing.\n"); break; case 3: printf("WV processing.\n"); break; } /* printf("* Input file name : %s\n",argv[1]); printf("* Output file name : %s\n",argv[2]); */ if(header_size!=0){ lseek(fi,header_size,SEEK_SET); } /* 変換 */ for(i=0;i