16 #include <itkMatrix.h>
30 template <
class T,
unsigned int NRows = 3,
unsigned int NColumns = 3>
31 class Matrix :
public itk::Matrix<T, NRows, NColumns>
44 Matrix(
const itk::Matrix<T, NRows, NColumns> &matrix) :
itk::
Matrix<T, NRows, NColumns>(matrix)
48 inline Matrix(
const vnl_matrix<T> &matrix) :
itk::
Matrix<T, NRows, NColumns>(matrix) {}
54 using itk::Matrix<T, NRows, NColumns>::operator=;
63 template <
typename ArrayType>
66 for (
unsigned i = 0; i < NRows; i++)
68 for (
unsigned j = 0; j < NColumns; j++)
70 (*this)[i][j] = array[i][j];
80 template <
typename MatrixType>
83 for (
unsigned i = 0; i < NRows; i++)
85 for (
unsigned j = 0; j < NColumns; j++)
87 matrix[i][j] = (*this)[i][j];
105 template <
typename TCoordRep,
unsigned int NRows,
unsigned int NCols>
106 inline bool MatrixEqualRMS(
const vnl_matrix_fixed<TCoordRep, NRows, NCols> &matrix1,
107 const vnl_matrix_fixed<TCoordRep, NRows, NCols> &matrix2,
110 if ((matrix1.rows() == matrix2.rows()) && (matrix1.cols() == matrix2.cols()))
112 vnl_matrix_fixed<TCoordRep, NRows, NCols> differenceMatrix = matrix1 - matrix2;
113 if (differenceMatrix.rms() < epsilon)
138 template <
typename TCoordRep,
unsigned int NRows,
unsigned int NCols>
140 const itk::Matrix<TCoordRep, NRows, NCols> &matrix2,
154 template <
typename TCoordRep,
unsigned int NRows,
unsigned int NCols>
156 const vnl_matrix_fixed<TCoordRep, NRows, NCols> &matrix2,
159 if ((matrix1.rows() == matrix2.rows()) && (matrix1.cols() == matrix2.cols()))
161 for (
unsigned int r = 0; r < NRows; r++)
163 for (
unsigned int c = 0; c < NCols; c++)
165 TCoordRep difference = matrix1(r, c) - matrix2(r, c);
190 template <
typename TCoordRep,
unsigned int NRows,
unsigned int NCols>
192 const itk::Matrix<TCoordRep, NRows, NCols> &matrix2,
MITK matrix type extending itk::Matrix with additional constructors and utility methods.
void ToArray(MatrixType matrix) const
Copy the elements of this matrix into a 2D array.
Matrix(InternalMatrixType &matrix)
Constructor from internal matrix type.
Matrix(const vnl_matrix< T > &matrix)
Constructor from vnl_matrix.
Matrix Self
Standard class typedefs.
Matrix()
Default constructor.
itk::Matrix< T, NRows, NColumns >::InternalMatrixType InternalMatrixType
Matrix(const itk::Matrix< T, NRows, NColumns > &matrix)
Copy constructor for itk compatibility.
void FillMatrix(const ArrayType &array)
Copy elements from a 2D array into this matrix.
Matrix(const Matrix &matrix)
Copy constructor.
Find image slices visible on a given plane.
bool MatrixEqualElementWise(const vnl_matrix_fixed< TCoordRep, NRows, NCols > &matrix1, const vnl_matrix_fixed< TCoordRep, NRows, NCols > &matrix2, mitk::ScalarType epsilon=mitk::eps)
Check for element-wise matrix equality with a user-defined accuracy.
MITKCORE_EXPORT const ScalarType eps
Epsilon value for floating point comparison (vnl_math::eps * 100).
Matrix< ScalarType, 2, 2 > Matrix2D
Matrix< ScalarType, 3, 3 > Matrix3D
bool MatrixEqualRMS(const vnl_matrix_fixed< TCoordRep, NRows, NCols > &matrix1, const vnl_matrix_fixed< TCoordRep, NRows, NCols > &matrix2, mitk::ScalarType epsilon=mitk::eps)
Check for matrix equality using root mean squared error (RMS) of all elements.
bool DifferenceBiggerOrEqualEps(DifferenceType diff, mitk::ScalarType epsilon=mitk::eps)
Check if the absolute difference is bigger than or equal to a given epsilon.
double ScalarType
Scalar type used throughout MITK for geometric computations.
Matrix< ScalarType, 4, 4 > Matrix4D