The description that follows is extracted with only minor editing from the Drishti online help. Some additional comments.
for (i=0;i<NX;i++) { // x axis
for (j=0;j<NY;j++) { // y axis
for (k=0;k<NZ;k++) { // z axis
fwrite(,,,);
}
}
}
The datatype for volume data in the RAW file can be either unsigned byte, unsigned short (2 bytes), unsigned int (4 bytes) or float (4 bytes). There are three options for the format of RAW files :
NX, NY and NZ are the grid dimensions written as 4-byte integers and volume data is the complete volumetric data with Z as the fastest varying loop index. The file size for such a raw formatted file is 1+12+NX*NY*NZ*sizeof(datatype)
For example for volume of size 128x128x128 with datatype as unsigned short (2-bytes per voxel) the file size would be 13+128*128*128*2 = 4194317 bytes.
NX, NY and NZ are the grid dimensions written as 4-byte integers and volume data is the complete volumetric data with Z as the fastest varying loop index. The user needs to specify voxel type in the dialog for reading raw files. The file size for such a raw formatted file is 12+NX*NY*NZ*sizeof(datatype)
For example for volume of size 128x128x128 with datatype as unsigned short (2-bytes per voxel) the file size would be 12+128*128*128*2 = 4194316 bytes.
A user defined header can be as big as the user wants. The header will be skipped while loading the volume data. The user will have to specify number of header bytes to skip.
The volume data is the complete volumetric data with Z as the fastest varying loop index. The user will have to specify grid size (NX,NY,NZ) and voxel type in the dialog for reading raw files. The file size for such a raw formatted file is NX*NY*NZ*sizeof(voxel type)
For example for volume of size 128x128x128 with datatype as unsigned short (2-bytes per voxel) the file size would be 128*128*128*2 = 4194304 bytes.
PVL stands for Processed Volume. This file is generated from the RAW data by Drishti. The format for PVL is as follows :
The first 4 bytes are all zero.Followed by 128 byte comment.
The next 12 bytes contain grid size as three 4-byte integers - [NX][NY][NZ].
Followed by voxel data with 2-bytes per voxel irrespective of the original volume data type. The first byte of the 2-byte voxel information is the voxel intensity and the second byte is the voxel gradient magnitude. The voxel gradient is numerically computed using Sobel tranform. The voxel intensity and gradient information is scaled to fit in one byte.
The file size of a 128x128x128 volume is 4+128+12+128*128*128*2 = 4194448 bytes.