/* chenge 16bit (0-1000 [%x10]) to 8bit [0-255] for generation RGB composite image (visible version). used compiler: gcc made by: Atsushi Higuchi, CEReS, Chiba Univ. Japan Version history: ver.0.1 27 dec 2006: start make program */ #include #include #define pixel 6378 #define line 5562 FILE *fpi, *fpo; /* open file sub-rutine */ int open_file(inname, outname) char *inname, *outname; { if((fpi = fopen(inname, "rb")) == NULL){ printf("don't open %s!\n", inname); return(-1); } if((fpo = fopen(outname, "wb")) == NULL){ printf("don't write %s!\n", outname); return(-1); } return(0); } /* main */ int main(argc, argv) int argc; char *argv[]; { int i,j; signed short input[pixel]; unsigned char output[pixel]; float dummy; if(argc !=3){ printf("Usage: program [input] [output]\n", argv[0]); exit(-1); } open_file(argv[1], argv[2]); /* read & write 1line each */ for(i=0;i0){ if(input[j]<51){ dummy=(float)(input[j])*2; output[j]=(unsigned char)dummy; } } if(input[j]>50){ if(input[j]<101){ dummy=(float)(input[j]-50)+100; output[j]=(unsigned char)dummy; } } if(input[j]>100){ if(input[j]<201){ dummy=(float)((input[j]-100)*0.5)+150; output[j]=(unsigned char)dummy; } } if(input[j]>200){ if(input[j]<401){ dummy=(float)((input[j]-200)*0.125)+200; output[j]=(unsigned char)dummy; } } if(input[j]>400){ if(input[j]<801){ dummy=(float)((input[j]-400)*0.005)+225; output[j]=(unsigned char)dummy; } } if(input[j]>800){ output[j]=253; } } fwrite(output, sizeof(unsigned char), pixel, fpo); } return(0); }