Next: Copying Volumes Up: Volumes Previous: Volume Coordinate Systems

Volume Creation from Scratch

In some circumstances, it is desirable to create volumes in ways other than reading from a file. The following functions provide methods to create a volume from scratch or to create a volume which is similar to an existing volume.

public   Volume   create_volume(
    int         n_dimensions,
    char        *dimension_names[],
    nc_type     nc_data_type,
    BOOLEAN     signed_flag,
    Real        voxel_min,
    Real        voxel_max )

Creates and returns a volume of the given type (for instance, NC_BYTE, signed_flag equal FALSE), and given valid voxel range. The dimension_names is used to describe each dimension of the volume and is currently only used when writing the volume to a file.

public  void  set_volume_voxel_range(
    Volume   volume,
    Real     voxel_min,
    Real     voxel_max )
public  void  set_volume_real_range(
    Volume   volume,
    Real     real_min,
    Real     real_max )

After creation of a volume, the valid voxel range or valid real range can subsequently be changed by using these functions.

public  void  set_volume_sizes(
    Volume       volume,
    int          sizes[] )

Sets the sizes of the volume, the number of voxels in each dimension. Note that this must be done before calling the function alloc_volume_data to allocate the voxels.

public  void  alloc_volume_data(
    Volume   volume )

After the volume has been created, and its size has been set, then this function allocates the memory for the voxels. Note that the voxel values are not initialized, and the user must fill the volume with desired values.

Associated with each volume is a transformation from voxel space to world space. There are several ways to define this transformation. The simplest is just to specify it directly:

public  void  set_voxel_to_world_transform(
    Volume             volume,
    General_transform  *transform )

Assigns the given transformation to the volume.

public  General_transform  *get_voxel_to_world_transform(
    Volume   volume )

Returns a pointer to the voxel to world transform of the volume.

public  void  set_volume_separations(
    Volume   volume,
    Real     separations[] )

Sets the inter-voxel separations in each of the volume dimensions. Note that this will cause the voxel-to-world transformation to be updated accordingly.

public  void  set_volume_translation(
    Volume  volume,
    Real    voxel[],
    Real    world_space_voxel_maps_to[] )

Sets the translation portion of the voxel-to-world transformation. A voxel coordinate is specified (voxel), as well as a real world position to which it is desired that this voxel map (world_space_voxel_maps_to). The voxel-to-world transformation is updated to provide this mapping.

public  void  set_volume_direction_cosine(
    Volume   volume,
    int      dimension,
    Real     dir[] )

Sets the real world axis for a specific voxel dimension. For instance if dimension is 1, and dir is (0.0, 1.0, 1.0), then voxels along the second dimension of the volume will map to the real world axis (0.0, 1.0, 1.0) normalized to unit length, then scaled by the volume separation for the second volume dimension.

Next: Copying Volumes Up: Volumes Previous: Volume Coordinate Systems
Fri Feb 17 15:37:42 EST 1995