struct TimeCode
{ short int scene; /* 0-999 */ short int hour; /* 0- 23 */ short int minute; /* 0- 59 */ short int second; /* 0- 59 */ short int frame; /* 0- 29 */ short int field; /* 1- 2 Note: -1 indicated non-valid field */ }; typedef struct _FileHeaderData {
|
/* */ /* This program reads RTI 16 and 32 bit image files and */ /* writes an output file with data number, pixel coordinates, */ /* and corresponding assigned values. */ /* */ /* Cosme Furlong */ /* WPI-ME/Laser Laboratory */ /* */ #include <stdlib.h>
#define HOLO_SIGN "RTI"
main(argc,argv)
if ( argc < 8 ) {
if ( (handle_i=fopen(argv[1],"r"))==NULL ) {
fread(head_rti,10,1,handle_i); if (strncmp(head_rti,HOLO_SIGN,strlen(HOLO_SIGN))
== 0) {
} else { printf("Input file is NOT an
RTI file. Exiting....\n");
x1 = atoi(argv[3]);
printf("Provided coordinates:\n");
if ( (x1 > x2) || (y1 > y2) ) {
/* Set input file location to first bit */ fseek(handle_i,0,SEEK_SET); /* Read 256-bit RTI header */ fread(&hh,sizeof(hh),1,handle_i); /* Shift 256 bits */ fseek(handle_i,256,SEEK_SET); /* Image size */ IXSIZE = (hh.xMax - hh.xMin + 1);
/* Extract data type */ datatype = hh.dataSize;
if (datatype == 8) {
/* OPEN OUTPUT FILE: ASCII FILE*/ if ( (handle_o=fopen(argv[2],"w")) == NULL)
/* SWITCH DEPENDING ON DATATYPE */ switch(datatype)
printf("\n");
pdata = malloc(size*2);
/* Find data offset and shift data pointer */ Off = 512*y1+x1;
nData
= 0;
/* Print to output file. Applying correction to Y coordinate. */ corrV = 0.8*(y1+Ypo);
nData++;
printf("Number of data points written: %d\n",nData);
printf("\n");
break; case(32): printf("\n");
pdata
= malloc(size*4);
/* Find data offset and shift data pointer */ Off = 512*y1+x1;
nData = 0;
/* Write all pixels. Including bad ones.
if (fval32) {
/* Print to output file. Applying correction to Y coordinate. */ corrV = 0.8*(y1+Ypo);
nData ++;
printf("\n");
break; default:
printf("Datatype not supported. Exiting...\n");
} /* End of switch */ /* CLOSE FILES AND FREE MEMORY */ fclose(handle_i);
|
/* Program: rti2sgi.c */ /* */ /* This program reads RTI 16/32-bit image files and */ /* writes out a valid Grayscaled SGI image file (8-bit). */ /* WPI-ME/Laser Laboratory */ /* Written in ANSI C by */ /* C. Furlong */ #include <stdlib.h>
#define HOLO_SIGN "RTI"
putbyte(outf,val)
buf[0] = val;
putshort(outf,val)
buf[0] = (val>>8);
static int putlong(outf,val)
buf[0] = (val>>24);
struct TimeCode
typedef struct _FileHeaderData {
main(argc,argv)
if ( argc < 3 ) {
if ( (handle_i=fopen(argv[1],"r"))==NULL ) {
fread(head_rti,10,1,handle_i); if (strncmp(head_rti,HOLO_SIGN,strlen(HOLO_SIGN))
== 0) {
} else { printf("Input file is NOT an RTI file. Exiting....\n");
fseek(handle_i,0,SEEK_SET);
IXSIZE = (hh.xMax - hh.xMin + 1);
size = IXSIZE*IYSIZE; printf("Image size is: %d x %d\n",IXSIZE,IYSIZE);
datatype = hh.dataSize;
printf("Signature: %c\n",hh.signiture[0]);
/* OPEN OUTPUT FILE: SGI-IRIS */ if ( (handle_o=fopen(argv[2],"w")) == NULL) {
putshort(handle_o,474);
/* MAGIC
*/
for(i=0; i<4; i++) {
/* DUMMY 4 bytes */
strcpy(iname,"WPI-ME/CHSLT");
for(i=0; i<404; i++) {
/* DUMMY 404 bytes */
switch(datatype)
/* Use the extraction of high and lower byte technique.
maxi = 0;
if (abs(value) > abs(maxi)) maxi = value; outbuf[Xpo] = value*8722/256; printf("Value(%d,%d): %d\n",Xpo,Ypo,value);
fwrite(outbuf,IXSIZE,1,handle_o);
*/ pdata = malloc(size*2); if (fread(pdata,size*2,1,handle_i)
< 0) {
mini = maxi = 0;
Diffi = maxi-mini;
printf("Writing output file...\n\n");
break; case(32): pdata = malloc(size*4); if (fread(pdata,size*4,1,handle_i) < 0) {
minv = 0.0;
Diff = maxv-minv;
printf("Writing output file...\n\n");
break; default: printf("Not a data file - PBM file. Exiting...\n");
} /* switch
*/
printf("\n Done!\n");
/* CLOSE FILES AND FREE MEMORY */ fclose(handle_i);
|
Back to top
![]() [Mechanical Engineering Department] |
![]() [CHSLT / NEST Labs] |