Medical Imaging Interaction Toolkit  2018.4.99-4c24e3cb
Medical Imaging Interaction Toolkit
mitkPALinearSpectralUnmixingFilter.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
14 
15 // Testing algorithms
16 #include <eigen3/Eigen/src/SVD/JacobiSVD.h>
17 
18 // ImageAccessor
19 #include <mitkImageReadAccessor.h>
20 #include <mitkImageWriteAccessor.h>
21 
23 {
24 }
25 
27 {
28 }
29 
31 {
32  algorithmName = inputAlgorithmName;
33 }
34 
36  Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic> endmemberMatrix, Eigen::VectorXf inputVector)
37 {
38  Eigen::VectorXf resultVector;
39 
40  if (mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType::HOUSEHOLDERQR == algorithmName)
41  resultVector = endmemberMatrix.householderQr().solve(inputVector);
42 
43  else if (mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType::LDLT == algorithmName)
44  {
45  Eigen::LLT<Eigen::MatrixXf> lltOfA(endmemberMatrix);
46  if (lltOfA.info() == Eigen::NumericalIssue)
47  {
48  mitkThrow() << "Possibly non semi-positive definitie endmembermatrix!";
49  }
50  else
51  resultVector = endmemberMatrix.ldlt().solve(inputVector);
52  }
53 
54  else if (mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType::LLT == algorithmName)
55  {
56  Eigen::LLT<Eigen::MatrixXf> lltOfA(endmemberMatrix);
57  if (lltOfA.info() == Eigen::NumericalIssue)
58  {
59  mitkThrow() << "Possibly non semi-positive definitie endmembermatrix!";
60  }
61  else
62  resultVector = endmemberMatrix.llt().solve(inputVector);
63  }
64 
65  else if (mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType::COLPIVHOUSEHOLDERQR == algorithmName)
66  resultVector = endmemberMatrix.colPivHouseholderQr().solve(inputVector);
67 
68  else if (mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType::JACOBISVD == algorithmName)
69  resultVector = endmemberMatrix.jacobiSvd(Eigen::ComputeFullU | Eigen::ComputeFullV).solve(inputVector);
70 
71  else if (mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType::FULLPIVLU == algorithmName)
72  resultVector = endmemberMatrix.fullPivLu().solve(inputVector);
73 
74  else if (mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType::FULLPIVHOUSEHOLDERQR == algorithmName)
75  resultVector = endmemberMatrix.fullPivHouseholderQr().solve(inputVector);
76  else
77  mitkThrow() << "404 VIGRA ALGORITHM NOT FOUND";
78 
79  return resultVector;
80 }
void SetAlgorithm(AlgortihmType inputAlgorithmName)
Takes a mitk::pa::LinearSpectralUnmixingFilter::AlgortihmType and fix it for usage at the "SpectralUn...
Eigen::VectorXf SpectralUnmixingAlgorithm(Eigen::Matrix< float, Eigen::Dynamic, Eigen::Dynamic > endmemberMatrix, Eigen::VectorXf inputVector) override
overrides the baseclass method with a mehtod to calculate the spectral unmixing result vector...
AlgortihmType
Contains all implemented Eigen algorithms for spectral unmixing. For detailed information of the algo...
#define mitkThrow()