MCPcopy Create free account
hub / github.com/ANTsX/ANTs / CorrectImageVectorDirection

Function CorrectImageVectorDirection

Examples/antsApplyTransforms.cxx:77–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75
76template <typename DisplacementFieldType, typename ImageType>
77void
78CorrectImageVectorDirection(DisplacementFieldType * movingVectorImage, ImageType * referenceImage)
79{
80 using DirectionType = typename DisplacementFieldType::DirectionType;
81
82 // Assume vectors are initially described in the voxel space of the moving image, like tensors
83 typename DirectionType::InternalMatrixType direction =
84 referenceImage->GetDirection().GetTranspose() * movingVectorImage->GetDirection().GetVnlMatrix();
85
86 using VectorType = typename DisplacementFieldType::PixelType;
87
88 const unsigned int dimension = ImageType::ImageDimension;
89
90 if (!direction.is_identity(0.00001))
91 {
92 itk::ImageRegionIterator<DisplacementFieldType> It(movingVectorImage, movingVectorImage->GetBufferedRegion());
93 for (It.GoToBegin(); !It.IsAtEnd(); ++It)
94 {
95 VectorType vector = It.Get();
96
97 vnl_vector<double> internalVector(dimension);
98 for (unsigned int d = 0; d < dimension; d++)
99 {
100 internalVector[d] = vector[d];
101 }
102
103 internalVector.pre_multiply(direction.as_matrix());
104 for (unsigned int d = 0; d < dimension; d++)
105 {
106 vector[d] = internalVector[d];
107 }
108
109 It.Set(vector);
110 }
111 }
112}
113
114template <unsigned int NDim>
115unsigned int

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected