Public Member Functions | Protected Attributes

Image4d< VOXEL > Class Template Reference
[3D+time image handlers]

A class for storing sequence of 3D images. More...

#include <ofTimelapseImage.h>

List of all members.

Public Member Functions

 Image4d (const Offset *off_=0, const Resolution *res_=0)
 Image4d (const Image4d< VOXEL > &seq, const VOI< PIXELS > *voi=0)
void CopyFromVOI (const Image4d< VOXEL > &seq, const VOI< PIXELS > &voi)
 ~Image4d ()
bool IsEmpty () const
Offset GetOffset () const
Resolution GetResolution () const
size_t GetFrameSize (void) const
size_t GetSliceSize (void) const
Vector3d< size_t > GetSize (void) const
size_t GetWidth (void) const
size_t GetHeight (void) const
size_t GetNumSlices (void) const
size_t GetNumFrames (void) const
size_t GetSizeX (void) const
size_t GetSizeY (void) const
size_t GetSizeZ (void) const
size_t GetSizeT (void) const
void SetOffset (const Offset &off_)
void SetResolution (const Resolution &res_)
size_t GetX (size_t i) const
size_t GetY (size_t i) const
size_t GetZ (size_t i) const
size_t GetInFrameIndex (size_t x, size_t y, size_t z) const
size_t GetInFrameIndex (Vector3d< size_t > v) const
Coords GetInFrameCoords (size_t i) const
Vector3d< size_t > GetFramePos (size_t i) const
VOXEL GetVoxel (size_t x, size_t y, size_t z, size_t frame) const
VOXEL GetVoxel (const Vector3d< size_t > &v, size_t frame) const
VOXEL GetVoxel (size_t i, size_t frame) const
void SetVoxel (size_t x, size_t y, size_t z, size_t frame, VOXEL voxel)
void SetVoxel (const Vector3d< size_t > &v, size_t frame, VOXEL voxel)
void SetVoxel (size_t i, size_t frame, VOXEL voxel)
VOXEL * GetVoxelAddr (size_t x, size_t y, size_t z, size_t frame)
const VOXEL * GetVoxelAddr (size_t x, size_t y, size_t z, size_t frame) const
VOXEL * GetVoxelAddr (size_t i, size_t frame)
const VOXEL * GetVoxelAddr (size_t i, size_t frame) const
VOXEL * GetFirstVoxelAddr (size_t frame)
const VOXEL * GetFirstVoxelAddr (size_t frame) const
std::vector< Image3d< VOXEL > * > & GetVoxelData (void)
const std::vector< Image3d
< VOXEL > * > & 
GetVoxelData (void) const
std::valarray< VOXEL > & GetVoxelData (size_t frame)
const std::valarray< VOXEL > & GetVoxelData (size_t frame) const
i3d::Image3d< VOXEL > * GetImage (size_t frame)
const i3d::Image3d< VOXEL > * GetImage (size_t frame) const
bool OnFrameBorder (const size_t x, const size_t y, const size_t z) const
bool OnFrameBorder (const Vector3d< size_t > v) const
bool OnSequenceBorder (const size_t frm) const
bool OnBorder (const size_t x, const size_t y, const size_t z, size_t frm) const
bool OnBorder (const Vector3d< size_t > v, size_t frm) const
bool Include (int x, int y, int z) const
bool Include (Vector3d< int > v) const
bool Include (int x, int y, int z, int t) const
bool Include (Vector3d< int > v, int t) const
int ReadSequence (const char *NamePrefix, const int Width, const char *NameSuffix, const int StartIndex, const int StopIndex)
int SaveSequence (const char *NamePrefix, const int Width, const char *NameSuffix, const int StartIndex, const int StopIndex)
void DisposeData ()
void DestroyData ()
void MakeRoom (size_t width, size_t height, size_t slices, size_t frms)
void MakeRoom (const Vector3d< size_t > &sz, size_t frms)
int InsertFrame (Image3d< VOXEL > const &img, const int time=-1)
int RemoveFrame (const int time, const VOXEL v=0)
int TestConsistency (void) const

Protected Attributes

Offset offset
Resolution resolution
Vector3d< size_t > size
size_t frames
std::vector< Image3d< VOXEL > * > data

Detailed Description

template<class VOXEL>
class Image4d< VOXEL >

A class for storing sequence of 3D images.

Basically, it consists of a vector of Image3d images where the position of the image in the vector represents the temporal position. In fact, the index to the vector is exactly the temporal (time) coordinate. An important consequence is that the entire 4D image is not layed continuously in the memory. Only each 3D image is continuous.

This class tries to mimic the class Image3d. This class is not inherited from class Image3d. Most of the methods is preserved except, where appropriate, for the addition of fourth time coordinate. Some were renamed not to be confused with the-same-named methods in Image3d. Currently, histogram handling is not supported.

Author:
VladimĂ­r Ulman <xulman@fi.muni.cz>
Date:
2007

Constructor & Destructor Documentation

template<class VOXEL >
Image4d< VOXEL >::Image4d ( const Offset *  off_ = 0,
const Resolution *  res_ = 0 
) [inline, explicit]
template<class VOXEL >
Image4d< VOXEL >::Image4d ( const Image4d< VOXEL > &  seq,
const VOI< PIXELS > *  voi = 0 
)

Copy constructor.

Only a portions, of each frame in the image sequence, corresponding to VOI are copied when VOI is set. The number of frames retains, only the dimension of frames is changed. Otherwise, if VOI == 0, the whole input image sequence is copied.

VOI is in pixels and is relative to origin of image. New offset is recomputed apropriately. Offsets are simply handled, i.e. it's supposed 1 pixel = 1 micron.

template<class VOXEL >
Image4d< VOXEL >::~Image4d (  )  [inline]

Destructor:


Member Function Documentation

template<class VOXEL >
void Image4d< VOXEL >::CopyFromVOI ( const Image4d< VOXEL > &  seq,
const VOI< PIXELS > &  voi 
)

It extracts a portion, given by voi, of each frame from given sequence seq.

The content of this Image4d is destroyed and length is shrinken to zero prior copying.

template<class VOXEL >
bool Image4d< VOXEL >::IsEmpty (  )  const [inline]

Is the image empty? True if empty.

template<class VOXEL >
Offset Image4d< VOXEL >::GetOffset (  )  const [inline]

Get the offset of this image.

template<class VOXEL >
Resolution Image4d< VOXEL >::GetResolution (  )  const [inline]

Get the resolution of this image.

template<class VOXEL >
size_t Image4d< VOXEL >::GetFrameSize ( void   )  const [inline]

Get the number of voxels in one frame.

template<class VOXEL >
size_t Image4d< VOXEL >::GetSliceSize ( void   )  const [inline]

Get the number of voxels in one slice.

template<class VOXEL >
Vector3d<size_t> Image4d< VOXEL >::GetSize ( void   )  const [inline]

Get the dimensions of the image frame.

template<class VOXEL >
size_t Image4d< VOXEL >::GetWidth ( void   )  const [inline]

Get the width (horizontal axis) of the image.

template<class VOXEL >
size_t Image4d< VOXEL >::GetHeight ( void   )  const [inline]

Get the height (vertical axis) of the image.

template<class VOXEL >
size_t Image4d< VOXEL >::GetNumSlices ( void   )  const [inline]

Get number of slices per image.

template<class VOXEL >
size_t Image4d< VOXEL >::GetNumFrames ( void   )  const [inline]

Get the number of frames in the sequence.

template<class VOXEL >
size_t Image4d< VOXEL >::GetSizeX ( void   )  const [inline]

Get the width (horizontal axis) of the image.

template<class VOXEL >
size_t Image4d< VOXEL >::GetSizeY ( void   )  const [inline]

Get the height (vertical axis) of the image.

template<class VOXEL >
size_t Image4d< VOXEL >::GetSizeZ ( void   )  const [inline]

Get number of slices per image.

template<class VOXEL >
size_t Image4d< VOXEL >::GetSizeT ( void   )  const [inline]

Get the number of frames in the sequence.

template<class VOXEL >
void Image4d< VOXEL >::SetOffset ( const Offset &  off_  )  [inline]

Set the offset for this image.

template<class VOXEL >
void Image4d< VOXEL >::SetResolution ( const Resolution &  res_  )  [inline]

Set the resolution for this image.

template<class VOXEL >
size_t Image4d< VOXEL >::GetX ( size_t  i  )  const [inline]

Get the x-coordinate of the i-th voxel in the image data block.

template<class VOXEL >
size_t Image4d< VOXEL >::GetY ( size_t  i  )  const [inline]

Get the y-coordinate of the i-th voxel in the image data block.

template<class VOXEL >
size_t Image4d< VOXEL >::GetZ ( size_t  i  )  const [inline]

Get the z-coordinate of the i-th voxel in the image data block.

template<class VOXEL >
size_t Image4d< VOXEL >::GetInFrameIndex ( size_t  x,
size_t  y,
size_t  z 
) const [inline]

Get the position of the voxel in the image data block (first position is O).

template<class VOXEL >
size_t Image4d< VOXEL >::GetInFrameIndex ( Vector3d< size_t >  v  )  const [inline]
template<class VOXEL >
Coords Image4d< VOXEL >::GetInFrameCoords ( size_t  i  )  const [inline]

get the coords from the position in the image vector coords is Vector3d<int> type - for relative positions

template<class VOXEL >
Vector3d<size_t> Image4d< VOXEL >::GetFramePos ( size_t  i  )  const [inline]
template<class VOXEL >
VOXEL Image4d< VOXEL >::GetVoxel ( size_t  x,
size_t  y,
size_t  z,
size_t  frame 
) const [inline]

Get a voxel value (voxels are numbered from 0):

template<class VOXEL >
VOXEL Image4d< VOXEL >::GetVoxel ( const Vector3d< size_t > &  v,
size_t  frame 
) const [inline]

Get a voxel value (voxels are numbered from 0).

template<class VOXEL >
VOXEL Image4d< VOXEL >::GetVoxel ( size_t  i,
size_t  frame 
) const [inline]

Get a voxel value (voxels are numbered from 0).

template<class VOXEL >
void Image4d< VOXEL >::SetVoxel ( size_t  x,
size_t  y,
size_t  z,
size_t  frame,
VOXEL  voxel 
) [inline]

Set a voxel to value (voxels are numbered from 0).

template<class VOXEL >
void Image4d< VOXEL >::SetVoxel ( const Vector3d< size_t > &  v,
size_t  frame,
VOXEL  voxel 
) [inline]

Set a voxel to value (voxels are numbered from 0).

template<class VOXEL >
void Image4d< VOXEL >::SetVoxel ( size_t  i,
size_t  frame,
VOXEL  voxel 
) [inline]

Set a voxel to value (voxels are numbered from 0).

template<class VOXEL >
VOXEL* Image4d< VOXEL >::GetVoxelAddr ( size_t  x,
size_t  y,
size_t  z,
size_t  frame 
) [inline]

Get a voxel address (voxels are numbered from 0).

template<class VOXEL >
const VOXEL* Image4d< VOXEL >::GetVoxelAddr ( size_t  x,
size_t  y,
size_t  z,
size_t  frame 
) const [inline]

Get a voxel address (voxels are numbered from 0).

template<class VOXEL >
VOXEL* Image4d< VOXEL >::GetVoxelAddr ( size_t  i,
size_t  frame 
) [inline]

Get a voxel address (voxels are numbered from 0).

template<class VOXEL >
const VOXEL* Image4d< VOXEL >::GetVoxelAddr ( size_t  i,
size_t  frame 
) const [inline]

Get a voxel address (voxels are numbered from 0).

template<class VOXEL >
VOXEL* Image4d< VOXEL >::GetFirstVoxelAddr ( size_t  frame  )  [inline]

Get the first voxel address (voxels are numbered from 0).

template<class VOXEL >
const VOXEL* Image4d< VOXEL >::GetFirstVoxelAddr ( size_t  frame  )  const [inline]

Get the first voxel address (voxels are numbered from 0).

template<class VOXEL >
std::vector< Image3d<VOXEL>* >& Image4d< VOXEL >::GetVoxelData ( void   )  [inline]

Returns a reference to the property data of this Image4d which is of the std::vector< Image3d<VOXEL>* > type.

template<class VOXEL >
const std::vector< Image3d<VOXEL>* >& Image4d< VOXEL >::GetVoxelData ( void   )  const [inline]
template<class VOXEL >
std::valarray<VOXEL>& Image4d< VOXEL >::GetVoxelData ( size_t  frame  )  [inline]

Returns a direct reference to the data of particular frame frame which is of the std::valarray<VOXEL> data type.

template<class VOXEL >
const std::valarray<VOXEL>& Image4d< VOXEL >::GetVoxelData ( size_t  frame  )  const [inline]
template<class VOXEL >
i3d::Image3d<VOXEL>* Image4d< VOXEL >::GetImage ( size_t  frame  )  [inline]

Returns a pointer to the Image3d (a frame) at given position.

No bounds checking, thus may crash if called inappropriatly.

template<class VOXEL >
const i3d::Image3d<VOXEL>* Image4d< VOXEL >::GetImage ( size_t  frame  )  const [inline]
template<class VOXEL >
bool Image4d< VOXEL >::OnFrameBorder ( const size_t  x,
const size_t  y,
const size_t  z 
) const [inline]

Is (x,y,z) on the border of the frame?

template<class VOXEL >
bool Image4d< VOXEL >::OnFrameBorder ( const Vector3d< size_t >  v  )  const [inline]

Is (x,y,z) (encoded in Vector3d) on the border of the frame?

template<class VOXEL >
bool Image4d< VOXEL >::OnSequenceBorder ( const size_t  frm  )  const [inline]
template<class VOXEL >
bool Image4d< VOXEL >::OnBorder ( const size_t  x,
const size_t  y,
const size_t  z,
size_t  frm 
) const [inline]
template<class VOXEL >
bool Image4d< VOXEL >::OnBorder ( const Vector3d< size_t >  v,
size_t  frm 
) const [inline]
template<class VOXEL >
bool Image4d< VOXEL >::Include ( int  x,
int  y,
int  z 
) const [inline]

Is the voxel [x,y,z] in this image?

template<class VOXEL >
bool Image4d< VOXEL >::Include ( Vector3d< int >  v  )  const [inline]

Is the voxel 'v' in this image?

template<class VOXEL >
bool Image4d< VOXEL >::Include ( int  x,
int  y,
int  z,
int  t 
) const [inline]

Is the voxel [x,y,z,t] in this image?

template<class VOXEL >
bool Image4d< VOXEL >::Include ( Vector3d< int >  v,
int  t 
) const [inline]

Is the voxel 'v'+t in this image?

template<class VOXEL >
int Image4d< VOXEL >::ReadSequence ( const char *  NamePrefix,
const int  Width,
const char *  NameSuffix,
const int  StartIndex,
const int  StopIndex 
)

Reads sequence of images and stores them in Image4d.

The specification of filenames is composed to this example:

to read files: green_0001.ics to green_0012.ics is translated into: ReadSequence("green_",4,".ics",1,12);

Parameters:
[in] NamePrefix the part of filename before the index number
[in] Width the width of zero-padded index number in the filename
[in] NameSuffix the part of filename after the index number
[in] StartIndex the first index number
[in] StopIndex the last index number

All processed images should be of the same dimension and have the same metadata.

Parameters StartIndex and StopIndex are relevant only to filenames. A new sequence image Image4d is always created. It has an appropriate length and frames are stored at positions (indices) starting with 0 (zero).

template<class VOXEL >
int Image4d< VOXEL >::SaveSequence ( const char *  NamePrefix,
const int  Width,
const char *  NameSuffix,
const int  StartIndex,
const int  StopIndex 
)

Stores Image4d sequence into several files.

The specification of filenames is according to this example:

to save files: green_0001.ics to green_0012.ics is translated into: SaveSequence("green_",4,".ics",1,12);

Parameters:
[in] NamePrefix the part of filename before the index number
[in] Width the width of zero-padded index number in the filename
[in] NameSuffix the part of filename after the index number
[in] StartIndex the first index number
[in] StopIndex the last index number

All saved images will be of the same dimension and will have the same metadata.

Parameters StartIndex and StopIndex are relevant both to filenames and indices within the vector of frames in the Image4d. In other words, only a subsequence can be saved owing to the two parameters.

template<class VOXEL >
void Image4d< VOXEL >::DisposeData (  )  [inline]

Free memory occupied by data and set size to (0,0,0,frames).

It scans the entire Image4d vector data (the 4D image sequence) and iteratively calls Image3d::DisposeData(). In particular, the Image3d objects are not removed from memory. The std::vector data retains its size and content.

In other words, the frames data is released from memory while frames themselves are preserved.

template<class VOXEL >
void Image4d< VOXEL >::DestroyData (  )  [inline]

Free memory occupied by data and set size to (0,0,0,0).

It scans the entire Image4d vector data (the 4D image sequence) and iteratively destroys Image3d frames. The std::vector data is shortened to zero.

In other words, the frames data is released from memory as well as the frames themselves.

template<class VOXEL >
void Image4d< VOXEL >::MakeRoom ( size_t  width,
size_t  height,
size_t  slices,
size_t  frms 
) [inline]

Allocate/reallocate voxel memory.

Set the image size and sequence length. The input are three dimensions of all frames and the number of frames.

If the new sequence length is shorter than the original length then the appropriate number of frames is removed from memory (their destructor functions are called).

Note:
There is absolutely no guarantee on the content of new 4D image. Original image is lost.
template<class VOXEL >
void Image4d< VOXEL >::MakeRoom ( const Vector3d< size_t > &  sz,
size_t  frms 
) [inline]

Allocate/reallocate voxel memory.

Set the image size and sequence length. The input are three dimensions (in the vector form) of all frames and the number of frames.

If the new sequence length is shorter than the original length then the appropriate number of frames is removed from memory (their destructor functions are called).

Note:
There is absolutely no guarantee on the content of new 4D image. Original image is lost.
template<class VOXEL >
int Image4d< VOXEL >::InsertFrame ( Image3d< VOXEL > const &  img,
const int  time = -1 
)

Inserts or appends a copy of input frame img into the sequence right before the frame at index time.

If time is -1 then the new frame is appended at the end of this sequence.

Returns zero when no problems occured.

template<class VOXEL >
int Image4d< VOXEL >::RemoveFrame ( const int  time,
const VOXEL  v = 0 
)

Removes frame from the sequence at index time.

The last parameter is ignored. It is only an ugly hack how to deal with templates in C++ (or perhaps the author's lack of knowledge).

Returns zero when no problems occured.

template<class VOXEL >
int Image4d< VOXEL >::TestConsistency ( void   )  const [inline]

Test internal consistency of Image4d.

It controls that the length of frames vector data has the same length as stored in property frames. Moreover, it controls that each frame in the sequence has the same dimension as stated in the property size.

The function returns zero when everything is OK.


Member Data Documentation

template<class VOXEL >
Offset Image4d< VOXEL >::offset [protected]

position of the image in absolute coordinates in micrometers

template<class VOXEL >
Resolution Image4d< VOXEL >::resolution [protected]

image resolution in pixels per micrometer

template<class VOXEL >
Vector3d<size_t> Image4d< VOXEL >::size [protected]

size of the image (width x height x slices) in pixels

template<class VOXEL >
size_t Image4d< VOXEL >::frames [protected]
template<class VOXEL >
std::vector< Image3d<VOXEL>* > Image4d< VOXEL >::data [protected]

image data buffer... a std::vector of image3d


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