PVL (Processed VoLume) file format
As used by Drishti

Collated by Paul Bourke
June 2009

The description that follows is extracted with only minor editing from the Drishti online help. Some additional comments.

  • All binary data is Intel endian.

  • The third raw format is often convenient for "pure" raw data with no header.

  • While the interpretation of the axes is open, the data is notionally written with the first coordinate (eg: z) varying the fastest and the third coordinate (x) varying the slowest. For example:
       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(,,,);
             }
          }
       }  
    

From the Drishti Manual

RAW Format

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 :

  • [single byte][NX][NY][NZ][volume data]
    A single byte specifies the voxel type.
    0 : unsigned byte - 1 byte per voxel
    2 : unsigned short - 2 bytes per voxel
    4 : unsigned integer - 4 bytes per voxel
    8 : float - 4 bytes per voxel

    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][NZ][volume data]

    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.

  • [header][volume data]

    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 Format

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.