GTR File

From Spin Help
Jump to: navigation, search

The GTR ("Ground Truth") is a binary file containing voxel coordinates for an object (3D ROI). It is a simplified version of a TOB File that is written as follows:

Number Of Type Description
1 int (4 bytes) Number of Objects
1 int (4 bytes) L1 = First object array length (# of points * 3)
L1 int (4 bytes) Object array arragned x1,y1,z1, x2,y2,z2...
1 int (4 bytes) L2 = Second object array length
L2 int (4 bytes) Second object array
... ... ...
1 int (4 bytes) Ln = Last object array length
Ln int (4 bytes) Last object array
End of File


Example Code

Some simple code to read a .GTR file


<syntaxhighlight lang="cpp"> FILE *inFile; int *objectArray; int numberObjects; CString openName; //****Get openName here*****

//Open file if ( (inFile=fopen(openName,"rb"))==NULL) { AfxMessageBox("Error, cannot open file \n"); return; }

//Read Header fread(&numberObjects,sizeof(int),1,inFile);

//Loop over all objects for(int n=0; n<numberObjects; n++) { //Read header int objectArrayLength; fread(&objectArrayLength,sizeof(int),1,inFile);

//Initialize array objectArray = new int[objectArrayLength];

//Read array fread(objectArray,sizeof(int),objectArrayLength,inFile);

//Copy array to something..... //***********Save Array Here******

//Delete Array delete [] objectArray; }

//Close file fclose(inFile); </syntaxhighlight>