4 #include <itkImageRegionConstIteratorWithIndex.h> 10 template <
class TFixedImagePixelType,
class TMovingImagePixelType,
unsigned int ImageDimension >
19 template <
class TFixedImagePixelType,
class TMovingImagePixelType,
unsigned int ImageDimension >
24 itkDebugMacro(
"GetValue( " << parameters <<
" ) ");
30 itkExceptionMacro( <<
"Fixed image has not been assigned" );
33 typedef itk::ImageRegionConstIteratorWithIndex<FixedImageType> FixedIteratorType;
35 FixedIteratorType ti( fixedImage, this->GetFixedImageRegion() );
37 typename FixedImageType::IndexType index;
39 MeasureType measure = itk::NumericTraits< MeasureType >::Zero;
41 this->m_NumberOfPixelsCounted = this->GetFixedImageRegion().GetNumberOfPixels();
43 this->SetTransformParameters( parameters );
45 unsigned int vectorSize = fixedImage->GetNumberOfComponentsPerPixel();
49 unsigned int tensorDimension = 3;
50 vnl_matrix <double> tmpMat(tensorDimension, tensorDimension);
51 vnl_matrix <double> currentTensor(tensorDimension, tensorDimension);
52 vnl_matrix <double> ppdOrientationMatrix(tensorDimension, tensorDimension);
53 typedef itk::Matrix <double, 3, 3> EigVecMatrixType;
54 typedef vnl_vector_fixed <double,3> EigValVectorType;
55 itk::SymmetricEigenAnalysis < EigVecMatrixType, EigValVectorType, EigVecMatrixType> eigenComputer(3);
56 EigVecMatrixType eigVecs;
57 EigValVectorType eigVals;
62 index = ti.GetIndex();
63 fixedImage->TransformIndexToPhysicalPoint(index,inputPoint);
65 transformedPoint = this->m_Transform->TransformPoint( inputPoint );
66 this->m_Interpolator->GetInputImage()->TransformPhysicalPointToContinuousIndex(transformedPoint,transformedIndex);
68 if( this->m_Interpolator->IsInsideBuffer( transformedIndex ) )
70 movingValue = this->m_Interpolator->EvaluateAtContinuousIndex(transformedIndex);
72 if (this->GetModelRotation() != Superclass::NONE)
77 if (this->GetModelRotation() == Superclass::FINITE_STRAIN)
81 eigenComputer.ComputeEigenValuesAndVectors(tmpMat,eigVals,eigVecs);
91 movingValue.SetSize(vectorSize);
92 movingValue.Fill(0.0);
96 for (
unsigned int i = 0;i < vectorSize;++i)
98 double diff = movingValue[i] - fixedValue[i];
99 measure += diff * diff;
105 measure /= this->m_NumberOfPixelsCounted;
Superclass::FixedImageConstPointer FixedImageConstPointer
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...
TFixedImage::PixelType PixelType
itk::ContinuousIndex< double, TFixedImage::ImageDimension > ContinuousIndexType
void GetTensorFromVectorRepresentation(const itk::VariableLengthVector< T1 > &vector, vnl_matrix< T2 > &tensor, unsigned int tensDim=0, bool scale=false)
MeasureType GetValue(const TransformParametersType ¶meters) const ITK_OVERRIDE
Superclass::TransformParametersType TransformParametersType
Superclass::MeasureType MeasureType
TensorMeanSquaresImageToImageMetric()
void ExtractPPDRotationFromJacobianMatrix(vnl_matrix< RealType > &jacobianMatrix, vnl_matrix< RealType > &rotationMatrix, MatrixType &eigenVectors)
Superclass::OutputPointType OutputPointType