plastimatch
Loading...
Searching...
No Matches
Volume Class Reference

The Volume class represents a three-dimensional volume on a uniform grid. The volume can be located at arbitrary positions and orientations in space, and can represent most voxel types (float, unsigned char, etc.). A volume can also support multiple planes, which is used to hold three dimensional vector fields, or three-dimensional bitfields.
More...

#include <volume.h>

Public Member Functions

 SMART_POINTER_SUPPORT (Volume)
 
 Volume ()
 
 Volume (const plm_long dim[3], const float origin[3], const float spacing[3], const float direction_cosines[9], enum Volume_pixel_type vox_type, int vox_planes)
 
 Volume (const plm_long dim[3], const float origin[3], const float spacing[3], const Direction_cosines &direction_cosines, enum Volume_pixel_type vox_type, int vox_planes)
 
 Volume (const Volume_header &vh, enum Volume_pixel_type vox_type, int vox_planes)
 
 ~Volume ()
 
plm_long index (plm_long i, plm_long j, plm_long k) const
 Return a linear index to a voxel.
 
plm_long index (plm_long ijk[3]) const
 Return a linear index to a voxel.
 
void create (const plm_long new_dim[3], const float origin[3], const float spacing[3], const float direction_cosines[9], enum Volume_pixel_type vox_type, int vox_planes=1)
 Initialize and allocate memory for the image.
 
void create (const Volume_header &vh, enum Volume_pixel_type vox_type, int vox_planes=1)
 Initialize and allocate memory for the image.
 
Volume::Pointer clone ()
 Make a copy of the volume.
 
Volume::Pointer clone (Volume_pixel_type new_type) const
 Make a copy of the volume with the same geometry and same voxel values, but converted to a different data type.
 
Volume::Pointer clone_empty ()
 Make a copy of the volume with the same geometry, but set all the voxel values to zero.
 
void convert (Volume_pixel_type new_type)
 Convert the image voxels to a new data type.
 
const float * get_origin (void) const
 Get a pointer to the origin of the volume.
The origin is defined as the location in world coordinates of the center of the first voxel in the volume.
 
void get_origin (float *) const
 
void set_origin (const float origin[3])
 Set the origin. The origin is defined as the location in world coordinates of the center of the first voxel in the volume.
 
const plm_long * get_dim (void)
 Get a pointer to the volume dimensions.
 
const float * get_spacing (void) const
 Get a pointer to the spacing of the volume.
The spacing is distance between voxels.
 
void get_spacing (float *) const
 
void set_spacing (const float spacing[3])
 Set the spacing. The spacing is distance between voxels.
 
Direction_cosinesget_direction_cosines (void)
 Get a pointer to the direction cosines.
Direction cosines hold the orientation of a volume. They are defined as the unit length direction vectors of the volume in world space as one traverses the pixels in the raw array of values.
 
const Direction_cosinesget_direction_cosines (void) const
 
float * get_direction_matrix (void)
 
const float * get_direction_matrix (void) const
 
void set_direction_cosines (const float direction_cosines[9])
 Set the direction cosines.
Direction cosines hold the orientation of a volume. They are defined as the unit length direction vectors of the volume in world space as one traverses the pixels in the raw array of values.
 
void set_header (const Volume_header &)
 Set the image header. This routine doesn't change any of the pixel values. It just changes the image geometry.
 
void set_header (const Plm_image_header *)
 
template<class T >
T * get_raw ()
 Get the raw image pointer as specified type. No error checking done.
 
template<class T >
const T * get_raw () const
 
const float * get_step (void) const
 Get the step matrix. The step matrix encodes the transform from voxel coordinates to world coordinates.
 
const float * get_proj (void) const
 Get the proj matrix. The proj matrix encodes the transform from world coordinates to voxel coordinates.
 
void position (float xyz[3], const plm_long ijk[3])
 Return a world coordinates of a voxel.
 
void coordinates (plm_long ijk[3], plm_long idx)
 Return coordinates from index.
 
float get_ijk_value (const float xyz[3]) const
 Get the value at a voxel coordinate, clamped and tri-linearly interpolated. Only applies to float volumes.
 
void get_xyz_from_ijk (double xyz[3], const plm_long ijk[3])
 
plm_long get_idx_from_xyz (const float xyz[3], bool *in)
 
void get_ijk_from_xyz (plm_long ijk[3], const float xyz[3], bool *in)
 
void get_ijk_from_xyz (float ijk[3], const float xyz[3], bool *in)
 
bool is_inside (const float ijk[3]) const
 Return true if continuous index ijk is inside volume.
 
void move_origin_to_idx (const plm_long ijk[3])
 Move the origin to the coordinate at a given index. This is used to correct itk images which have a non-zero region index.
 
void scale_inplace (float scale)
 In-place (destructive) scaling of the image according to the supplied scale factor.
 
void debug ()
 
void direction_cosines_debug ()
 
Volumeclone_raw ()
 

Public Attributes

plm_long dim [3]
 
plm_long npix
 
float origin [3]
 
float spacing [3]
 
Direction_cosines direction_cosines
 
enum Volume_pixel_type pix_type
 
int vox_planes
 
int pix_size
 
void * img
 
float step [9]
 
float proj [9]
 

Protected Member Functions

void allocate (void)
 
void init ()
 

Detailed Description

The Volume class represents a three-dimensional volume on a uniform grid. The volume can be located at arbitrary positions and orientations in space, and can represent most voxel types (float, unsigned char, etc.). A volume can also support multiple planes, which is used to hold three dimensional vector fields, or three-dimensional bitfields.

Constructor & Destructor Documentation

◆ Volume() [1/4]

Volume::Volume ( )

◆ Volume() [2/4]

Volume::Volume ( const plm_long dim[3],
const float origin[3],
const float spacing[3],
const float direction_cosines[9],
enum Volume_pixel_type vox_type,
int vox_planes )

◆ Volume() [3/4]

Volume::Volume ( const plm_long dim[3],
const float origin[3],
const float spacing[3],
const Direction_cosines & direction_cosines,
enum Volume_pixel_type vox_type,
int vox_planes )

◆ Volume() [4/4]

Volume::Volume ( const Volume_header & vh,
enum Volume_pixel_type vox_type,
int vox_planes )

◆ ~Volume()

Volume::~Volume ( )

Member Function Documentation

◆ allocate()

void Volume::allocate ( void )
protected

◆ clone() [1/2]

Volume::Pointer Volume::clone ( )

Make a copy of the volume.

◆ clone() [2/2]

Volume::Pointer Volume::clone ( Volume_pixel_type new_type) const

Make a copy of the volume with the same geometry and same voxel values, but converted to a different data type.

◆ clone_empty()

Volume::Pointer Volume::clone_empty ( )

Make a copy of the volume with the same geometry, but set all the voxel values to zero.

◆ clone_raw()

Volume * Volume::clone_raw ( )

◆ convert()

void Volume::convert ( Volume_pixel_type new_type)

Convert the image voxels to a new data type.

◆ coordinates()

void Volume::coordinates ( plm_long ijk[3],
plm_long idx )
inline

Return coordinates from index.

◆ create() [1/2]

void Volume::create ( const plm_long new_dim[3],
const float origin[3],
const float spacing[3],
const float direction_cosines[9],
enum Volume_pixel_type vox_type,
int vox_planes = 1 )

Initialize and allocate memory for the image.

◆ create() [2/2]

void Volume::create ( const Volume_header & vh,
enum Volume_pixel_type vox_type,
int vox_planes = 1 )

Initialize and allocate memory for the image.

◆ debug()

void Volume::debug ( )

◆ direction_cosines_debug()

void Volume::direction_cosines_debug ( )

◆ get_dim()

const plm_long * Volume::get_dim ( void )
inline

Get a pointer to the volume dimensions.

◆ get_direction_cosines() [1/2]

Direction_cosines & Volume::get_direction_cosines ( void )
inline

Get a pointer to the direction cosines.
Direction cosines hold the orientation of a volume. They are defined as the unit length direction vectors of the volume in world space as one traverses the pixels in the raw array of values.

◆ get_direction_cosines() [2/2]

const Direction_cosines & Volume::get_direction_cosines ( void ) const
inline

◆ get_direction_matrix() [1/2]

float * Volume::get_direction_matrix ( void )
inline

◆ get_direction_matrix() [2/2]

const float * Volume::get_direction_matrix ( void ) const
inline

◆ get_idx_from_xyz()

plm_long Volume::get_idx_from_xyz ( const float xyz[3],
bool * in )

◆ get_ijk_from_xyz() [1/2]

void Volume::get_ijk_from_xyz ( float ijk[3],
const float xyz[3],
bool * in )

◆ get_ijk_from_xyz() [2/2]

void Volume::get_ijk_from_xyz ( plm_long ijk[3],
const float xyz[3],
bool * in )

◆ get_ijk_value()

float Volume::get_ijk_value ( const float xyz[3]) const

Get the value at a voxel coordinate, clamped and tri-linearly interpolated. Only applies to float volumes.

◆ get_origin() [1/2]

void Volume::get_origin ( float * origin) const

◆ get_origin() [2/2]

const float * Volume::get_origin ( void ) const

Get a pointer to the origin of the volume.
The origin is defined as the location in world coordinates of the center of the first voxel in the volume.

◆ get_proj()

const float * Volume::get_proj ( void ) const

Get the proj matrix. The proj matrix encodes the transform from world coordinates to voxel coordinates.

◆ get_raw() [1/2]

template<class T >
template float * Volume::get_raw< float > ( )

Get the raw image pointer as specified type. No error checking done.

◆ get_raw() [2/2]

template<class T >
template const float * Volume::get_raw< float > ( ) const

◆ get_spacing() [1/2]

void Volume::get_spacing ( float * spacing) const

◆ get_spacing() [2/2]

const float * Volume::get_spacing ( void ) const

Get a pointer to the spacing of the volume.
The spacing is distance between voxels.

◆ get_step()

const float * Volume::get_step ( void ) const

Get the step matrix. The step matrix encodes the transform from voxel coordinates to world coordinates.

◆ get_xyz_from_ijk()

void Volume::get_xyz_from_ijk ( double xyz[3],
const plm_long ijk[3] )

◆ index() [1/2]

plm_long Volume::index ( plm_long i,
plm_long j,
plm_long k ) const
inline

Return a linear index to a voxel.

◆ index() [2/2]

plm_long Volume::index ( plm_long ijk[3]) const
inline

Return a linear index to a voxel.

◆ init()

void Volume::init ( )
protected

◆ is_inside()

bool Volume::is_inside ( const float ijk[3]) const

Return true if continuous index ijk is inside volume.

◆ move_origin_to_idx()

void Volume::move_origin_to_idx ( const plm_long ijk[3])

Move the origin to the coordinate at a given index. This is used to correct itk images which have a non-zero region index.

◆ position()

void Volume::position ( float xyz[3],
const plm_long ijk[3] )
inline

Return a world coordinates of a voxel.

◆ scale_inplace()

void Volume::scale_inplace ( float scale)

In-place (destructive) scaling of the image according to the supplied scale factor.

◆ set_direction_cosines()

void Volume::set_direction_cosines ( const float direction_cosines[9])

Set the direction cosines.
Direction cosines hold the orientation of a volume. They are defined as the unit length direction vectors of the volume in world space as one traverses the pixels in the raw array of values.

◆ set_header() [1/2]

void Volume::set_header ( const Plm_image_header * pih)

◆ set_header() [2/2]

void Volume::set_header ( const Volume_header & vh)

Set the image header. This routine doesn't change any of the pixel values. It just changes the image geometry.

◆ set_origin()

void Volume::set_origin ( const float origin[3])

Set the origin. The origin is defined as the location in world coordinates of the center of the first voxel in the volume.

◆ set_spacing()

void Volume::set_spacing ( const float spacing[3])

Set the spacing. The spacing is distance between voxels.

◆ SMART_POINTER_SUPPORT()

Volume::SMART_POINTER_SUPPORT ( Volume )

Member Data Documentation

◆ dim

plm_long Volume::dim[3]

◆ direction_cosines

Direction_cosines Volume::direction_cosines

◆ img

void* Volume::img

◆ npix

plm_long Volume::npix

◆ origin

float Volume::origin[3]

◆ pix_size

int Volume::pix_size

◆ pix_type

enum Volume_pixel_type Volume::pix_type

◆ proj

float Volume::proj[9]

◆ spacing

float Volume::spacing[3]

◆ step

float Volume::step[9]

◆ vox_planes

int Volume::vox_planes

The documentation for this class was generated from the following files: