ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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 <itkImage.h>
23#include <itkMatrix.h>
24
25namespace rtk
26{
27
28//--------------------------------------------------------------------
37// template <class TPixel, unsigned int VImageDimension>
38template <class TImageType>
40GetIndexToPhysicalPointMatrix(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>
75template <class TImageType>
77GetPhysicalPointToIndexMatrix(const TImageType * image)
78{
80 return MatrixType(GetIndexToPhysicalPointMatrix<TImageType>(image).GetInverse());
81};
82
83} // namespace rtk
84
85#endif // rtkHomogeneousMatrix_h
A templated class holding a M x N size Matrix.
Definition itkMatrix.h:71
void Fill(const T &value)
Definition itkMatrix.h:262
A templated class holding a geometric point in n-Dimensional space.
Definition itkPoint.h:54
itk::Matrix< double, TImageType::ImageDimension+1, TImageType::ImageDimension+1 > GetPhysicalPointToIndexMatrix(const TImageType *image)
Get PhysicalPointToIndex matrix from an image (no accessor provided by ITK).
itk::Matrix< double, TImageType::ImageDimension+1, TImageType::ImageDimension+1 > GetIndexToPhysicalPointMatrix(const TImageType *image)
Get IndexToPhysicalPoint matrix from an image (no accessor provided by ITK).
Represent a n-dimensional index in a n-dimensional image.
Definition itkIndex.h:69
void Fill(IndexValueType value)
Definition itkIndex.h:269