RTK  2.6.0
Reconstruction Toolkit
rtkHomogeneousMatrix.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright RTK Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * https://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 
19 #ifndef rtkHomogeneousMatrix_h
20 #define rtkHomogeneousMatrix_h
21 
22 #include <itkMatrix.h>
23 #include <itkImage.h>
24 
25 namespace rtk
26 {
27 
28 //--------------------------------------------------------------------
37 // template <class TPixel, unsigned int VImageDimension>
38 template <class TImageType>
40 GetIndexToPhysicalPointMatrix(const TImageType * image)
41 {
42  const unsigned int Dimension = TImageType::ImageDimension;
43 
45  matrix.Fill(0.0);
46 
49 
50  for (unsigned int j = 0; j < Dimension; j++)
51  {
52  index.Fill(0);
53  index[j] = 1;
54  image->TransformIndexToPhysicalPoint(index, point);
55  for (unsigned int i = 0; i < Dimension; i++)
56  matrix[i][j] = point[i] - image->GetOrigin()[i];
57  }
58  for (unsigned int i = 0; i < Dimension; i++)
59  matrix[i][Dimension] = image->GetOrigin()[i];
60  matrix[Dimension][Dimension] = 1.0;
61 
62  return matrix;
63 };
64 
65 //--------------------------------------------------------------------
74 // template <class TPixel, unsigned int VImageDimension>
75 template <class TImageType>
77 GetPhysicalPointToIndexMatrix(const TImageType * image)
78 {
80  return MatrixType(GetIndexToPhysicalPointMatrix<TImageType>(image).GetInverse());
81 };
82 
83 } // namespace rtk
84 
85 #endif // rtkHomogeneousMatrix_h
itk::Matrix< double, TImageType::ImageDimension+1, TImageType::ImageDimension+1 > GetIndexToPhysicalPointMatrix(const TImageType *image)
Get IndexToPhysicalPoint matrix from an image (no accessor provided by ITK).
constexpr unsigned int Dimension
itk::Matrix< double, TImageType::ImageDimension+1, TImageType::ImageDimension+1 > GetPhysicalPointToIndexMatrix(const TImageType *image)
Get PhysicalPointToIndex matrix from an image (no accessor provided by ITK).
*par Constraints *The filter requires an image with at least two dimensions and a vector *length of at least The theory supports extension to scalar but *the implementation of the itk vector classes do not **The template parameter TRealType must be floating point(float or double) or *a user-defined "real" numerical type with arithmetic operations defined *sufficient to compute derivatives. **\par Performance *This filter will automatically multithread if run with *SetUsePrincipleComponents