Public Member Functions | Private Attributes

MultiGridLevel< VOXEL > Class Template Reference
[Full Bidirectional Multi Grid Framework]

This class is for one level of the multigrid framework. More...

#include <ofMultiGridLevel.h>

List of all members.

Public Member Functions

 MultiGridLevel (size_t dimensions, i3d::Vector3d< float >spacing, i3d::Vector3d< size_t > size, size_t levelIndex, bool linearData=static_cast< bool >(true), bool linearSmooth=static_cast< bool >(true))
 ~MultiGridLevel ()
i3d::Image3d< VOXEL > * GetRightHandSide (size_t i)
VOXEL GetRightHandSide (size_t rhsIndex, size_t itemIndex)
i3d::Image3d< VOXEL > * GetRightHandSideBackup (size_t i)
void SaveRightHandSide (char *FName, size_t ind)
i3d::Image3d< VOXEL > * GetTemp (size_t i)
size_t GetTotalSize ()
i3d::Image3d< VOXEL > * GetSolution (size_t i)
i3d::Image3d< VOXEL > * GetSolutionBackup (size_t i)
size_t GetLevelIndex ()
SparseMatrixDiagStorage< VOXEL > * GetMatrix (size_t i, size_t j)
void SetSolution (size_t SolIndex, size_t ItemIndex, VOXEL Value)
VOXEL GetSolution (size_t SolIndex, size_t ItemIndex)
i3d::Image3d< VOXEL > * GetInverseMatrix (size_t i, size_t j)
i3d::Image3d< VOXEL > * GetAdditionalSpace (size_t i)
void SetAdditionalSpace (size_t i, i3d::Image3d< VOXEL > *img)
void AllocateAdditionalSpace (size_t count, size_t m=std::numeric_limits< size_t >::max())
void SetTensorBackup (MotionTensor< VOXEL > *mt)
MotionTensor< VOXEL > * GetTensorBackup ()
void SetVisited (bool v)
bool GetVisited ()
void SetMatrixComputed (bool mc)
bool GetMatrixComputed ()
i3d::Vector3d< float > & GetSpacing ()
i3d::Vector3d< size_t > & GetSize ()
size_t GetDimensions ()
std::valarray< i3d::Image3d
< VOXEL > * > & 
GetResults ()
i3d::Image3d< VOXEL > * GetResults (size_t axe)
void SetResults (i3d::Image3d< VOXEL > *w, size_t axe)
bool GetLinear ()

Private Attributes

std::valarray< i3d::Image3d
< VOXEL > * > 
m_solution
std::valarray< i3d::Image3d
< VOXEL > * > 
m_solutionBackup
std::valarray< i3d::Image3d
< VOXEL > * > 
m_rightHandSide
std::valarray< i3d::Image3d
< VOXEL > * > 
m_rightHandSideBackup
std::valarray< i3d::Image3d
< VOXEL > * > 
m_temp
std::valarray
< SparseMatrixDiagStorage
< VOXEL > * > 
m_matrices
std::valarray< i3d::Image3d
< VOXEL > * > 
m_additionalSpace
MotionTensor< VOXEL > * m_tensorBackup
size_t m_dimensions
i3d::Vector3d< float > m_spacing
i3d::Vector3d< size_t > m_size
size_t m_totalSize
size_t m_levelIndex
size_t m_numberOfMatrices
bool m_linearData
bool m_linearSmooth
bool m_visited
bool m_matrixComputed

Detailed Description

template<class VOXEL>
class MultiGridLevel< VOXEL >

This class is for one level of the multigrid framework.

It contain all necessary data and methods to handle them.

The implementation of this class is based on PhD. thesis
A. Bruhn Variational Optic Flow Computation: Accurate Modelling and Efficient Numerics Department of Mathematics and Computer Science, Universitaet des Saarlandes, Saarbruecken, July 2006

Author:
Jan Hubený (xhubeny@fi.muni.cz)
Date:
2006

Constructor & Destructor Documentation

template<class VOXEL >
MultiGridLevel< VOXEL >::MultiGridLevel ( size_t  dimensions,
i3d::Vector3d< float >  spacing,
i3d::Vector3d< size_t >  size,
size_t  levelIndex,
bool  linearData = static_cast <bool> (true),
bool  linearSmooth = static_cast <bool> (true) 
)

Constructor.

Parameters:
[in] dimensions Dimension of the underlying image (2 or 3)
[in] spacing Spacing of the voxels in the underlying image sequence
[in] size Size of the underlying images
[in] levelIndex Level index of the level in the multigrid framework. The greater the number is the coarser the level is. Zero is for the finest level.
[in] linearData True if the data term is linear (default value). False if the data term is nonlinear.
[in] linearSmooth True if the smoothing term is linear (default value). False if the data term is nonlinear.
template<class VOXEL >
MultiGridLevel< VOXEL >::~MultiGridLevel (  ) 

Destructor The member data structures are deleted in the destructor.


Member Function Documentation

template<class VOXEL >
i3d::Image3d<VOXEL>* MultiGridLevel< VOXEL >::GetRightHandSide ( size_t  i  )  [inline]

Returns pointer to the right hand side of the linear (or nonlinear) system.

In fact, it return the x,y or z component of the right-hand side vector.

Parameters:
[in] i which component should be returned. [0 - x, 1 - y, 2 - z].
Returns:
Pointer to the i3d::Image3d. In this image is the ith-component saved.
template<class VOXEL >
VOXEL MultiGridLevel< VOXEL >::GetRightHandSide ( size_t  rhsIndex,
size_t  itemIndex 
) [inline]

Get the value of the particular item in the right hand side vector.

Parameters:
[in] rhsIndex index of the right hand side vector [0 - x, 1 - y, 2 - z].
[in] itemIndex index of the item in the solution vector. [0 - number of unknowns].
Returns:
The value on position itemIndex in the right hand side component rhsIndex.
template<class VOXEL >
i3d::Image3d<VOXEL>* MultiGridLevel< VOXEL >::GetRightHandSideBackup ( size_t  i  )  [inline]

Returns pointer to the backup of the right hand side of the nonlinear system.

The backup is needed in the nonlinear optic flow multigrid computations, which are more complex than linear computations. In fact, it return the x,y or z component of the right-hand side vector.

Parameters:
[in] i which component should be returned. [0 - x, 1 - y, 2 - z].
Returns:
Pointer to the i3d::Image3d. In this image is the ith-component saved.
template<class VOXEL >
void MultiGridLevel< VOXEL >::SaveRightHandSide ( char *  FName,
size_t  ind 
)

Save the ith-component of the right hand side of the linear or nonlinear system.

This routine serves mainly for debuging purposes. It has no sense in the production enviroment.

Parameters:
[in] FName Full name of the image file. The indth-component is saved to the image file.
[in] ind which component should be saved. [0 - x, 1 - y, 2 - z]
template<class VOXEL >
i3d::Image3d<VOXEL>* MultiGridLevel< VOXEL >::GetTemp ( size_t  i  )  [inline]

Get the temporal space.

The temporal space is used for restriction, prolongation and residual computations. The results of this computations are saved in this data structure.

Parameters:
[in] i Index of the temporal space which should be returned. [0 - x, 1 - y, 2 - z]
Returns:
Pointer to the Image3d. In this image the temporal space is saved.
template<class VOXEL >
size_t MultiGridLevel< VOXEL >::GetTotalSize (  )  [inline]

Get the total size (in voxels) of the underlying images.

It is also the number of unknowns in the underlying linear or nonlinear system.

Returns:
The number of unknowns in the [non]linear system at this multi-grid level.
template<class VOXEL >
i3d::Image3d<VOXEL>* MultiGridLevel< VOXEL >::GetSolution ( size_t  i  )  [inline]

Returns pointer to the actual solution of the linear (or nonlinear) system at this level.

In fact, it return the x,y or z component of the actual solution vector.

Parameters:
[in] i which component should be returned. [0 - x, 1 - y, 2 - z].
Returns:
Pointer to the i3d::Image3d. In this image is the ith-component saved.
template<class VOXEL >
i3d::Image3d<VOXEL>* MultiGridLevel< VOXEL >::GetSolutionBackup ( size_t  i  )  [inline]

Returns pointer to the actual solution backup of the nonlinear system at this level.

The backup of the solution is neede in the nonlinear case which is more complex to solve. In fact, it return the x,y or z component of the actual backup solution vector.

Parameters:
[in] i which component should be returned. [0 - x, 1 - y, 2 - z].
Returns:
Pointer to the i3d::Image3d. In this image is the ith-component saved.
template<class VOXEL >
size_t MultiGridLevel< VOXEL >::GetLevelIndex (  )  [inline]

Get the index of this level.

The levels in the multigrid frameword are identified by the level index.

Returns:
Index of this level.
template<class VOXEL >
SparseMatrixDiagStorage<VOXEL>* MultiGridLevel< VOXEL >::GetMatrix ( size_t  i,
size_t  j 
) [inline]

Get the (i,j) submatrix of the matrix of the [non]linear system.

The matrix is composed of 2x2 sobmatrices in 2D and 3x3 in 3D.

Parameters:
[in] i index of the row of the submatrix.
[in] j index of the column of the submatrix.
Returns:
the pointer to the submatrix.
template<class VOXEL >
void MultiGridLevel< VOXEL >::SetSolution ( size_t  SolIndex,
size_t  ItemIndex,
VOXEL  Value 
) [inline]

Set the value of the solution in the solution vector.

Parameters:
[in] SolIndex index of the solution vector [0 - x, 1 - y, 2 - z].
[in] ItemIndex index of the item in the solution vector. [0 - number of unknowns].
[in] Value the value which should be saved in the solution vector.
template<class VOXEL >
VOXEL MultiGridLevel< VOXEL >::GetSolution ( size_t  SolIndex,
size_t  ItemIndex 
) [inline]

Get the value of the solution in the solution vector.

Parameters:
[in] SolIndex index of the solution vector [0 - x, 1 - y, 2 - z].
[in] ItemIndex index of the item in the solution vector. [0 - number of unknowns].
Returns:
The value on position ItemIndex in the solution component SolIndex.
template<class VOXEL >
i3d::Image3d<VOXEL>* MultiGridLevel< VOXEL >::GetInverseMatrix ( size_t  i,
size_t  j 
) [inline]

Get the (i,j) submatrix of the inversed matrix of the [non]linear system.

The inversed matrix is computed only in the linear case. The matrix is composed of 2x2 sobmatrices in 2D and 3x3 in 3D.

Parameters:
[in] i index of the row of the submatrix.
[in] j index of the column of the submatrix.
Returns:
the pointer to the submatrix.
template<class VOXEL >
i3d::Image3d<VOXEL>* MultiGridLevel< VOXEL >::GetAdditionalSpace ( size_t  i  )  [inline]

Returns the pointer to i3d::Image3d which serves as an additional space.

The additional space is neede in the warping cases of the variational optic flow methods. The additional space has the size of the number of unknowns.

Parameters:
[in] i Index of the additional space.
Returns:
Pointer to the additional space.
template<class VOXEL >
void MultiGridLevel< VOXEL >::SetAdditionalSpace ( size_t  i,
i3d::Image3d< VOXEL > *  img 
)

Set the pointer of the i3d::Image3d which serves as an additional space.

The additional space is neede in the warping cases of the variational optic flow methods. The additional space has the size of the number of unknowns.

Parameters:
[in] i Index of the additional space.
[in] img Pointer to the i3d::Image3d which should be saved in the additional space array.
template<class VOXEL >
void MultiGridLevel< VOXEL >::AllocateAdditionalSpace ( size_t  count,
size_t  m = std::numeric_limits<size_t>::max() 
)

Allocate the needed additional space.

Unified methods which allocates the additional space for the warping variants of the variational optical flow methods.

Parameters:
[in] count The number of additional images where can be something saved.
[in] m the index of the additional image. Images with index smaller than this number are fully allocated. The pointers for the images with index greater or equal to this number are only allocated and initialized to NULL.
template<class VOXEL >
void MultiGridLevel< VOXEL >::SetTensorBackup ( MotionTensor< VOXEL > *  mt  ) 

Set the pointer to the backup of the motion tensor.

The backup of the motion tensor is neeed in the fully nonlinear optical flow methods (the data and smoothing term is nonlinear).

Parameters:
[in] mt Pointer to the motion tensor.
template<class VOXEL >
MotionTensor< VOXEL > * MultiGridLevel< VOXEL >::GetTensorBackup (  ) 

Get the pointer to the motion tensor backup.

The backup of the motion tensor is neeed in the fully nonlinear optical flow methods (the data and smoothing term is nonlinear).

Returns:
The pointer to the backup of the motion tensor at this level.
template<class VOXEL >
void MultiGridLevel< VOXEL >::SetVisited ( bool  v  ) 

Set whether this level was already visited by the multigrid computation framework.

Parameters:
[in] v True if this level was visited. False if the levels was not visited.
template<class VOXEL >
bool MultiGridLevel< VOXEL >::GetVisited (  ) 

Get whether this level was already visited by the multigrid computation framework.

Returns:
True if this level was visited. False if the levels was not visited.
template<class VOXEL >
void MultiGridLevel< VOXEL >::SetMatrixComputed ( bool  mc  ) 

Set whether the matrix which belong to this level was already computed.

Parameters:
[in] mc True if the matrix was already computed. False otherwise.
template<class VOXEL >
bool MultiGridLevel< VOXEL >::GetMatrixComputed (  ) 

Get whether the matrix which belongs to this level was already computed.

Returns:
True whether the matrix was already computed. False otherwise.
template<class VOXEL >
i3d::Vector3d<float>& MultiGridLevel< VOXEL >::GetSpacing (  )  [inline]

Get the spacing of the images at this level.

Returns:
The spacing of the images (unknowns etc.) at this level.
template<class VOXEL >
i3d::Vector3d<size_t>& MultiGridLevel< VOXEL >::GetSize (  )  [inline]

Get the size of the images and unknown arrays, etc.

at this level.

Returns:
The size of the images at this level.
template<class VOXEL >
size_t MultiGridLevel< VOXEL >::GetDimensions (  )  [inline]

Get the number of dimensions of the underlying image sequence.

Returns:
The number of dimensions of the underlying image sequence [2 for 2D 3 for 3D].
template<class VOXEL >
std::valarray< i3d::Image3d <VOXEL> *>& MultiGridLevel< VOXEL >::GetResults (  )  [inline]

Get the valarray with the computation results at this level.

Returns:
the valarray with pointers to the i3d::Image3d components of the solution.
template<class VOXEL >
Image3d< VOXEL > * MultiGridLevel< VOXEL >::GetResults ( size_t  axe  ) 

Get the x,y or z component with the computation results at this level.

Parameters:
[in] axe Index of the component which should be returned. [0 - x, 1 - y, 2 - z].
Returns:
the ointer to the i3d::Image3d component of the solution.
template<class VOXEL >
void MultiGridLevel< VOXEL >::SetResults ( i3d::Image3d< VOXEL > *  w,
size_t  axe 
)

Set the x,y or z component with the computation results at this level.

Parameters:
[in] w Pointer to the i3d::Image3d with the solution.
[in] axe Onto whic axe should be the solution altered with the new one. [0 -x, 1 - y, 2 - z].
template<class VOXEL >
bool MultiGridLevel< VOXEL >::GetLinear (  )  [inline]

Get whether this level is level of linear multigrid or level of nonlinear multigrid.

Returns:
True if level is part of linear multigrid. False otherwise.

Member Data Documentation

template<class VOXEL >
std::valarray< i3d::Image3d <VOXEL> *> MultiGridLevel< VOXEL >::m_solution [private]

std::valarray with the pointers to the vectors of the solution

template<class VOXEL >
std::valarray< i3d::Image3d <VOXEL> *> MultiGridLevel< VOXEL >::m_solutionBackup [private]

std::valarray with the pointers to the vectors of the solution backup

template<class VOXEL >
std::valarray< i3d::Image3d <VOXEL> *> MultiGridLevel< VOXEL >::m_rightHandSide [private]

std::valarray with the pointers to the vectors with the right hand side

template<class VOXEL >
std::valarray< i3d::Image3d <VOXEL> *> MultiGridLevel< VOXEL >::m_rightHandSideBackup [private]

std::valarray with the pointers to the vectors with the right hand side backup

template<class VOXEL >
std::valarray< i3d::Image3d <VOXEL> *> MultiGridLevel< VOXEL >::m_temp [private]

std::valarray with pointers to the temporal space which is used in the restriction, prolongation and residual computations

template<class VOXEL >
std::valarray< SparseMatrixDiagStorage <VOXEL> *> MultiGridLevel< VOXEL >::m_matrices [private]

std::valarray with pointers to the submatrices

template<class VOXEL >
std::valarray< i3d::Image3d <VOXEL> *> MultiGridLevel< VOXEL >::m_additionalSpace [private]

std::valarray with the pointers to the additional space

template<class VOXEL >
MotionTensor<VOXEL>* MultiGridLevel< VOXEL >::m_tensorBackup [private]

pointer to the motion tensor backup.

template<class VOXEL >
size_t MultiGridLevel< VOXEL >::m_dimensions [private]

number of the dimensions of the solved problem (2 or 3).

template<class VOXEL >
i3d::Vector3d<float> MultiGridLevel< VOXEL >::m_spacing [private]

spacing of the underlying images (tensors unknown arrays, ...).

template<class VOXEL >
i3d::Vector3d<size_t> MultiGridLevel< VOXEL >::m_size [private]

size of the images.

template<class VOXEL >
size_t MultiGridLevel< VOXEL >::m_totalSize [private]

the total number of unknowns (voxels) at this level.

template<class VOXEL >
size_t MultiGridLevel< VOXEL >::m_levelIndex [private]

The index of this level at the multigrid framework.

template<class VOXEL >
size_t MultiGridLevel< VOXEL >::m_numberOfMatrices [private]

Number of matrices (3 for 2D, 6 for 3D).

template<class VOXEL >
bool MultiGridLevel< VOXEL >::m_linearData [private]

Is the data term linear (true) or not (false).

template<class VOXEL >
bool MultiGridLevel< VOXEL >::m_linearSmooth [private]

Is the smoothing term linear (true) or not (false).

template<class VOXEL >
bool MultiGridLevel< VOXEL >::m_visited [private]

Was this level already visited by the multigrid computation framework?

template<class VOXEL >
bool MultiGridLevel< VOXEL >::m_matrixComputed [private]

Was the matrix already computed at this level?


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