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

Function GetMatrix

Examples/ConvertTransformFile.cxx:79–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77 */
78template <typename TTransform>
79bool
80GetMatrix(const typename TTransform::Pointer & transform, typename TTransform::MatrixType & matrix, bool outputRAS)
81{
82 const unsigned int ImageDimension = TTransform::InputSpaceDimension;
83
84 using ScalarType = typename TTransform::ScalarType;
85
86 matrix.Fill(itk::NumericTraits<typename TTransform::ScalarType>::ZeroValue());
87 bool done = false;
88
89 // Matrix-offset derived
90 {
91 using CastTransformType = itk::MatrixOffsetTransformBase<ScalarType, ImageDimension, ImageDimension>;
92 typename CastTransformType::Pointer castTransform = dynamic_cast<CastTransformType *>(transform.GetPointer());
93
94 if (castTransform.IsNotNull())
95 {
96 matrix = castTransform->GetMatrix();
97 done = true;
98 }
99 }
100
101 // Translation
102 if (!done)
103 {
104 using CastTransformType = itk::TranslationTransform<ScalarType, ImageDimension>;
105 typename CastTransformType::Pointer castTransform = dynamic_cast<CastTransformType *>(transform.GetPointer());
106
107 if (castTransform.IsNotNull())
108 {
109 for (unsigned int i = 0; i < ImageDimension; i++)
110 {
111 matrix(i, i) = itk::NumericTraits<typename TTransform::ScalarType>::OneValue();
112 }
113 done = true;
114 }
115 }
116
117 // Identity
118 if (!done)
119 {
120 using CastTransformType = itk::IdentityTransform<ScalarType, ImageDimension>;
121 typename CastTransformType::Pointer castTransform = dynamic_cast<CastTransformType *>(transform.GetPointer());
122
123 if (castTransform.IsNotNull())
124 {
125 for (unsigned int i = 0; i < ImageDimension; i++)
126 {
127 matrix(i, i) = itk::NumericTraits<typename TTransform::ScalarType>::OneValue();
128 }
129 done = true;
130 }
131 }
132
133 if (!done)
134 {
135 // Unsupported transform type
136 return false;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected