| 75 | |
| 76 | template <typename DisplacementFieldType, typename ImageType> |
| 77 | void |
| 78 | CorrectImageVectorDirection(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 | |
| 114 | template <unsigned int NDim> |
| 115 | unsigned int |
nothing calls this directly
no outgoing calls
no test coverage detected