ANIMA  4.0
animaTensorResampleImageFilter.hxx
Go to the documentation of this file.
1 #pragma once
3 
4 #include <animaBaseTensorTools.h>
5 
6 namespace anima
7 {
8 
9 template <typename TImageType, typename TInterpolatorPrecisionType>
10 void
13 {
14  this->Superclass::BeforeThreadedGenerateData();
15 
16  m_WorkMats.resize(this->GetNumberOfWorkUnits());
17  m_TmpTensors.resize(this->GetNumberOfWorkUnits());
18 
19  for (unsigned int i = 0;i < this->GetNumberOfWorkUnits();++i)
20  {
21  m_WorkMats[i].set_size(m_TensorDimension,m_TensorDimension);
22  m_TmpTensors[i].set_size(m_TensorDimension,m_TensorDimension);
23  }
24 
25  if (!this->GetFiniteStrainReorientation())
26  {
27  m_WorkEigenValues.resize(this->GetNumberOfWorkUnits());
28  m_WorkEigenVectors.resize(this->GetNumberOfWorkUnits());
29  m_WorkPPDOrientationMatrices.resize(this->GetNumberOfWorkUnits());
30  }
31 }
32 
33 template <typename TImageType, typename TInterpolatorPrecisionType>
34 void
36 ::ReorientInterpolatedModel(const InputPixelType &interpolatedModel, vnl_matrix <double> &modelOrientationMatrix,
37  InputPixelType &rotatedModel, itk::ThreadIdType threadId)
38 {
39  anima::GetTensorFromVectorRepresentation(interpolatedModel,m_WorkMats[threadId],m_TensorDimension,true);
40 
41  if (this->GetFiniteStrainReorientation())
42  anima::RotateSymmetricMatrix(m_WorkMats[threadId],modelOrientationMatrix,m_TmpTensors[threadId]);
43  else
44  {
45  typedef itk::Matrix <double,3,3> MatrixType;
46  typedef vnl_vector_fixed <double,3> VectorType;
47  itk::SymmetricEigenAnalysis < MatrixType, VectorType, MatrixType> eigenComputer(3);
48  eigenComputer.ComputeEigenValuesAndVectors(m_WorkMats[threadId],m_WorkEigenValues[threadId],
49  m_WorkEigenVectors[threadId]);
50 
51  anima::ExtractPPDRotationFromJacobianMatrix(modelOrientationMatrix,m_WorkPPDOrientationMatrices[threadId],m_WorkEigenVectors[threadId]);
52  anima::RotateSymmetricMatrix(m_WorkMats[threadId],m_WorkPPDOrientationMatrices[threadId],m_TmpTensors[threadId]);
53  }
54 
55  anima::GetVectorRepresentation(m_TmpTensors[threadId],rotatedModel,m_VectorSize,true);
56 }
57 
58 } // end of namespace anima
virtual void ReorientInterpolatedModel(const InputPixelType &interpolatedModel, vnl_matrix< double > &modelOrientationMatrix, InputPixelType &rotatedModel, itk::ThreadIdType threadId) ITK_OVERRIDE
Needs to be implemented in sub-classes, does the actual re-orientation of the model.
virtual void BeforeThreadedGenerateData() ITK_OVERRIDE
void GetVectorRepresentation(const vnl_matrix< T1 > &tensor, itk::VariableLengthVector< T2 > &vector, unsigned int vecDim=0, bool scale=false)
void RotateSymmetricMatrix(T1 &tensor, T2 &rotationMatrix, T3 &rotated_tensor, unsigned int tensorDim)
Rotates a symmetric matrix by performing R^T D R where R is a rotation matrix and D the symmetric mat...
void GetTensorFromVectorRepresentation(const itk::VariableLengthVector< T1 > &vector, vnl_matrix< T2 > &tensor, unsigned int tensDim=0, bool scale=false)
void ExtractPPDRotationFromJacobianMatrix(vnl_matrix< RealType > &jacobianMatrix, vnl_matrix< RealType > &rotationMatrix, MatrixType &eigenVectors)