ITK  5.2.0
Insight Toolkit
itkSymmetricEigenAnalysisImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * http://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 #ifndef itkSymmetricEigenAnalysisImageFilter_h
19 #define itkSymmetricEigenAnalysisImageFilter_h
20 
23 #include "ITKImageIntensityExport.h"
24 
25 namespace itk
26 {
27 // This functor class invokes the computation of Eigen Analysis for
28 // every pixel. The input pixel type must provide the API for the [][]
29 // operator, while the output pixel type must provide the API for the
30 // [] operator. Input pixel matrices should be symmetric.
31 //
32 // The default operation is to order eigen values in ascending order.
33 // You may also use OrderEigenValuesBy( ) to order eigen values by
34 // magnitude as is common with use of tensors in vessel extraction.
35 namespace Functor
36 {
37 
38 #if !defined(ITK_LEGACY_REMOVE)
39 using OrderTypeOfEigenValue = EigenValueOrderEnum;
40 #endif
41 
42 template <typename TInput, typename TOutput>
44 {
45 public:
46  using RealValueType = typename TInput::RealValueType;
50  bool
52  {
53  return false;
54  }
55 
56  bool
58  {
59  return !(*this != other);
60  }
61 
62  inline TOutput
63  operator()(const TInput & x) const
64  {
65  TOutput eigenValues;
66 
67  m_Calculator.ComputeEigenValues(x, eigenValues);
68  return eigenValues;
69  }
70 
72  void
73  SetDimension(unsigned int n)
74  {
76  }
77  unsigned int
78  GetDimension() const
79  {
80  return m_Calculator.GetDimension();
81  }
83 
84 #if !defined(ITK_LEGACY_REMOVE)
85 
86  using EigenValueOrderType = EigenValueOrderEnum;
87 #endif
88 #if !defined(ITK_LEGACY_REMOVE)
89  // We need to expose the enum values at the class level
90  // for backwards compatibility
91  static constexpr EigenValueOrderEnum OrderByValue = EigenValueOrderEnum::OrderByValue;
92  static constexpr EigenValueOrderEnum OrderByMagnitude = EigenValueOrderEnum::OrderByMagnitude;
93  static constexpr EigenValueOrderEnum DoNotOrder = EigenValueOrderEnum::DoNotOrder;
94 #endif
95 
98  void
100  {
102  {
104  }
105  else if (order == EigenValueOrderEnum::DoNotOrder)
106  {
108  }
109  }
110  void
112  {
113  this->OrderEigenValuesBy(order);
114  }
117  {
119  {
121  }
123  {
125  }
127  }
129 
130 
131 private:
133 };
134 
135 template <unsigned int TMatrixDimension, typename TInput, typename TOutput>
137 {
138 public:
139  using RealValueType = typename TInput::RealValueType;
143  bool
145  {
146  return false;
147  }
148 
149  bool
151  {
152  return !(*this != other);
153  }
154 
155  inline TOutput
156  operator()(const TInput & x) const
157  {
158  TOutput eigenValues;
159 
160  m_Calculator.ComputeEigenValues(x, eigenValues);
161  return eigenValues;
162  }
163 
165  unsigned int
166  GetDimension() const
167  {
168  return m_Calculator.GetDimension();
169  }
170 
171 #if !defined(ITK_LEGACY_REMOVE)
172 
173  using EigenValueOrderType = EigenValueOrderEnum;
174 #endif
175 #if !defined(ITK_LEGACY_REMOVE)
176  // We need to expose the enum values at the class level
177  // for backwards compatibility
178  static constexpr EigenValueOrderEnum OrderByValue = EigenValueOrderEnum::OrderByValue;
179  static constexpr EigenValueOrderEnum OrderByMagnitude = EigenValueOrderEnum::OrderByMagnitude;
180  static constexpr EigenValueOrderEnum DoNotOrder = EigenValueOrderEnum::DoNotOrder;
181 #endif
182 
185  void
187  {
189  {
191  }
192  else if (order == EigenValueOrderEnum::DoNotOrder)
193  {
195  }
196  }
198 
199 private:
201 };
202 
204 extern ITKImageIntensity_EXPORT std::ostream &
205  operator<<(std::ostream & out, const EigenValueOrderEnum value);
206 
207 } // end namespace Functor
208 
227 template <typename TInputImage, typename TOutputImage = TInputImage>
229  : public UnaryFunctorImageFilter<
230  TInputImage,
231  TOutputImage,
232  Functor::SymmetricEigenAnalysisFunction<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
233 {
234 public:
235  ITK_DISALLOW_COPY_AND_MOVE(SymmetricEigenAnalysisImageFilter);
236 
240  TInputImage,
241  TOutputImage,
243 
246 
248  using OutputPixelType = typename TOutputImage::PixelType;
249  using InputPixelType = typename TInputImage::PixelType;
250  using InputValueType = typename InputPixelType::ValueType;
252 
253 #if !defined(ITK_LEGACY_REMOVE)
254 
255  using EigenValueOrderType = EigenValueOrderEnum;
256 #endif
257 
260  void
262  {
263  this->GetFunctor().OrderEigenValuesBy(order);
264  }
265  void
267  {
268  this->OrderEigenValuesBy(order);
269  }
272  {
273  return this->GetFunctor().GetOrderEigenValuesBy();
274  }
276 
279 
281  itkNewMacro(Self);
282 
284  void
285  PrintSelf(std::ostream & os, Indent indent) const override
286  {
287  this->Superclass::PrintSelf(os, indent);
288  }
289 
292  void
293  SetDimension(unsigned int p)
294  {
295  this->GetFunctor().SetDimension(p);
296  }
297  unsigned int
298  GetDimension() const
299  {
300  return this->GetFunctor().GetDimension();
301  }
303 
304 #ifdef ITK_USE_CONCEPT_CHECKING
305  // Begin concept checking
306  itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputValueType>));
307  // End concept checking
308 #endif
309 
310 protected:
311  SymmetricEigenAnalysisImageFilter() { this->SetDimension(TInputImage::ImageDimension); }
312  ~SymmetricEigenAnalysisImageFilter() override = default;
313 };
314 
333 template <unsigned int TMatrixDimension, typename TInputImage, typename TOutputImage = TInputImage>
335  : public UnaryFunctorImageFilter<
336  TInputImage,
337  TOutputImage,
338  Functor::SymmetricEigenAnalysisFixedDimensionFunction<TMatrixDimension,
339  typename TInputImage::PixelType,
340  typename TOutputImage::PixelType>>
341 {
342 public:
343  ITK_DISALLOW_COPY_AND_MOVE(SymmetricEigenAnalysisFixedDimensionImageFilter);
344 
347  using Superclass =
348  UnaryFunctorImageFilter<TInputImage,
349  TOutputImage,
351  typename TInputImage::PixelType,
352  typename TOutputImage::PixelType>>;
353 
356 
358  using OutputPixelType = typename TOutputImage::PixelType;
359  using InputPixelType = typename TInputImage::PixelType;
360  using InputValueType = typename InputPixelType::ValueType;
362 
365 
368  void
370  {
371  this->GetFunctor().OrderEigenValuesBy(order);
372  }
373 
376 
378  itkNewMacro(Self);
379 
381  void
382  PrintSelf(std::ostream & os, Indent indent) const override
383  {
384  this->Superclass::PrintSelf(os, indent);
385  }
386 
388  unsigned int
389  GetDimension() const
390  {
391  return this->GetFunctor().GetDimension();
392  }
393 
394 #ifdef ITK_USE_CONCEPT_CHECKING
395  // Begin concept checking
396  itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputValueType>));
397  // End concept checking
398 #endif
399 
400 protected:
403 };
404 } // end namespace itk
405 
406 #endif
itk::Functor::SymmetricEigenAnalysisFixedDimensionFunction::m_Calculator
CalculatorType m_Calculator
Definition: itkSymmetricEigenAnalysisImageFilter.h:200
itk::Functor::SymmetricEigenAnalysisFixedDimensionFunction::GetDimension
unsigned int GetDimension() const
Definition: itkSymmetricEigenAnalysisImageFilter.h:166
itk::SymmetricEigenAnalysisImageFilter
Computes the eigen-values of every input symmetric matrix pixel.
Definition: itkSymmetricEigenAnalysisImageFilter.h:228
itkUnaryFunctorImageFilter.h
itk::SymmetricEigenAnalysis::SetDimension
void SetDimension(const unsigned int n)
Definition: itkSymmetricEigenAnalysis.h:330
itk::Concept::HasNumericTraits
Definition: itkConceptChecking.h:714
itk::SymmetricEigenAnalysisImageFilter::GetDimension
unsigned int GetDimension() const
Definition: itkSymmetricEigenAnalysisImageFilter.h:298
itk::Functor::SymmetricEigenAnalysisFunction
Definition: itkSymmetricEigenAnalysisImageFilter.h:43
itk::Functor::SymmetricEigenAnalysisFunction::operator()
TOutput operator()(const TInput &x) const
Definition: itkSymmetricEigenAnalysisImageFilter.h:63
itk::SymmetricEigenAnalysisEnums::EigenValueOrder::OrderByValue
itk::Functor::SymmetricEigenAnalysisFixedDimensionFunction
Definition: itkSymmetricEigenAnalysisImageFilter.h:136
itk::UnaryFunctorImageFilter
Implements pixel-wise generic operation on one image.
Definition: itkUnaryFunctorImageFilter.h:50
itk::SymmetricEigenAnalysisImageFilter::OrderEigenValuesBy
void OrderEigenValuesBy(EigenValueOrderEnum order)
Definition: itkSymmetricEigenAnalysisImageFilter.h:261
itk::SymmetricEigenAnalysisFixedDimensionImageFilter::~SymmetricEigenAnalysisFixedDimensionImageFilter
~SymmetricEigenAnalysisFixedDimensionImageFilter() override=default
itk::Functor::SymmetricEigenAnalysisFunction::SetDimension
void SetDimension(unsigned int n)
Definition: itkSymmetricEigenAnalysisImageFilter.h:73
itk::SymmetricEigenAnalysisImageFilter::InputValueType
typename InputPixelType::ValueType InputValueType
Definition: itkSymmetricEigenAnalysisImageFilter.h:250
itk::Functor::SymmetricEigenAnalysisFunction::OrderEigenValuesBy
void OrderEigenValuesBy(EigenValueOrderEnum order)
Definition: itkSymmetricEigenAnalysisImageFilter.h:99
itk::Functor::SymmetricEigenAnalysisFunction::operator!=
bool operator!=(const SymmetricEigenAnalysisFunction &) const
Definition: itkSymmetricEigenAnalysisImageFilter.h:51
itk::SymmetricEigenAnalysisFixedDimensionImageFilter::OrderEigenValuesBy
void OrderEigenValuesBy(EigenValueOrderEnum order)
Definition: itkSymmetricEigenAnalysisImageFilter.h:369
itk::SymmetricEigenAnalysisEnums::EigenValueOrder::OrderByMagnitude
itk::Functor::SymmetricEigenAnalysisFunction::SymmetricEigenAnalysisFunction
SymmetricEigenAnalysisFunction()=default
itk::SymmetricEigenAnalysisImageFilter::SymmetricEigenAnalysisImageFilter
SymmetricEigenAnalysisImageFilter()
Definition: itkSymmetricEigenAnalysisImageFilter.h:311
itk::SymmetricEigenAnalysisFixedDimension::SetOrderEigenValues
void SetOrderEigenValues(const bool b)
Definition: itkSymmetricEigenAnalysis.h:827
itk::SymmetricEigenAnalysisImageFilter::FunctorType
typename Superclass::FunctorType FunctorType
Definition: itkSymmetricEigenAnalysisImageFilter.h:251
itk::SmartPointer< Self >
itk::SymmetricEigenAnalysisFixedDimensionImageFilter::GetDimension
unsigned int GetDimension() const
Definition: itkSymmetricEigenAnalysisImageFilter.h:389
itkSymmetricEigenAnalysis.h
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::SymmetricEigenAnalysisImageFilter::OutputPixelType
typename TOutputImage::PixelType OutputPixelType
Definition: itkSymmetricEigenAnalysisImageFilter.h:248
itk::SymmetricEigenAnalysis::GetOrderEigenValues
bool GetOrderEigenValues() const
Definition: itkSymmetricEigenAnalysis.h:299
itk::Functor::SymmetricEigenAnalysisFunction::GetDimension
unsigned int GetDimension() const
Definition: itkSymmetricEigenAnalysisImageFilter.h:78
itk::SymmetricEigenAnalysis::ComputeEigenValues
unsigned int ComputeEigenValues(const TMatrix &A, TVector &D) const
itk::EigenValueOrderEnum
SymmetricEigenAnalysisEnums::EigenValueOrder EigenValueOrderEnum
Definition: itkSymmetricEigenAnalysis.h:141
itk::SymmetricEigenAnalysisImageFilter::Self
SymmetricEigenAnalysisImageFilter Self
Definition: itkSymmetricEigenAnalysisImageFilter.h:238
itk::SymmetricEigenAnalysisImageFilter::GetOrderEigenValuesBy
EigenValueOrderEnum GetOrderEigenValuesBy() const
Definition: itkSymmetricEigenAnalysisImageFilter.h:271
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::UnaryFunctorImageFilter::OutputImageType
TOutputImage OutputImageType
Definition: itkUnaryFunctorImageFilter.h:75
itk::Functor::SymmetricEigenAnalysisFixedDimensionFunction::OrderEigenValuesBy
void OrderEigenValuesBy(EigenValueOrderEnum order)
Definition: itkSymmetricEigenAnalysisImageFilter.h:186
itk::SymmetricEigenAnalysisImageFilter::InputPixelType
typename TInputImage::PixelType InputPixelType
Definition: itkSymmetricEigenAnalysisImageFilter.h:249
itk::SymmetricEigenAnalysisFixedDimensionImageFilter::FunctorType
typename Superclass::FunctorType FunctorType
Definition: itkSymmetricEigenAnalysisImageFilter.h:361
itk::InPlaceImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
itk::SymmetricEigenAnalysis::GetDimension
unsigned int GetDimension() const
Definition: itkSymmetricEigenAnalysis.h:343
itk::SymmetricEigenAnalysisFixedDimensionImageFilter::OutputPixelType
typename TOutputImage::PixelType OutputPixelType
Definition: itkSymmetricEigenAnalysisImageFilter.h:358
itk::SymmetricEigenAnalysisFixedDimensionImageFilter
Computes the eigen-values of every input symmetric matrix pixel.
Definition: itkSymmetricEigenAnalysisImageFilter.h:334
itk::SymmetricEigenAnalysisFixedDimension::SetOrderEigenMagnitudes
void SetOrderEigenMagnitudes(const bool b)
Definition: itkSymmetricEigenAnalysis.h:844
itk::SymmetricEigenAnalysis::SetOrderEigenMagnitudes
void SetOrderEigenMagnitudes(const bool b)
Definition: itkSymmetricEigenAnalysis.h:308
itk::SymmetricEigenAnalysisEnums::EigenValueOrder::DoNotOrder
itk::Functor::SymmetricEigenAnalysisFunction::~SymmetricEigenAnalysisFunction
~SymmetricEigenAnalysisFunction()=default
itk::UnaryFunctorImageFilter::FunctorType
TFunction FunctorType
Definition: itkUnaryFunctorImageFilter.h:68
itk::Functor::SymmetricEigenAnalysisFixedDimensionFunction::SymmetricEigenAnalysisFixedDimensionFunction
SymmetricEigenAnalysisFixedDimensionFunction()=default
itk::Functor::operator<<
ITKImageIntensity_EXPORT std::ostream & operator<<(std::ostream &out, const EigenValueOrderEnum value)
itk::SymmetricEigenAnalysisFixedDimension::GetDimension
constexpr unsigned int GetDimension() const
Definition: itkSymmetricEigenAnalysis.h:866
itk::SymmetricEigenAnalysisFixedDimensionImageFilter::InputValueType
typename InputPixelType::ValueType InputValueType
Definition: itkSymmetricEigenAnalysisImageFilter.h:360
itk::SymmetricEigenAnalysisImageFilter::~SymmetricEigenAnalysisImageFilter
~SymmetricEigenAnalysisImageFilter() override=default
itk::SymmetricEigenAnalysisFixedDimension< TMatrixDimension, TInputImage::PixelType, TOutputImage::PixelType >
itk::SymmetricEigenAnalysis::SetOrderEigenValues
void SetOrderEigenValues(const bool b)
Definition: itkSymmetricEigenAnalysis.h:285
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk::SymmetricEigenAnalysisFixedDimensionImageFilter::SymmetricEigenAnalysisFixedDimensionImageFilter
SymmetricEigenAnalysisFixedDimensionImageFilter()=default
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::SymmetricEigenAnalysisImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkSymmetricEigenAnalysisImageFilter.h:285
itk::SymmetricEigenAnalysisFixedDimensionImageFilter::InputPixelType
typename TInputImage::PixelType InputPixelType
Definition: itkSymmetricEigenAnalysisImageFilter.h:359
itk::UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::SymmetricEigenAnalysisFunction< TInputImage::PixelType, TOutputImage::PixelType > >::GetFunctor
FunctorType & GetFunctor()
Definition: itkUnaryFunctorImageFilter.h:85
itk::Functor::SymmetricEigenAnalysisFunction::SetOrderEigenValuesBy
void SetOrderEigenValuesBy(EigenValueOrderEnum order)
Definition: itkSymmetricEigenAnalysisImageFilter.h:111
itk::Functor::SymmetricEigenAnalysisFunction::GetOrderEigenValuesBy
EigenValueOrderEnum GetOrderEigenValuesBy() const
Definition: itkSymmetricEigenAnalysisImageFilter.h:116
itk::SymmetricEigenAnalysisImageFilter::SetOrderEigenValuesBy
void SetOrderEigenValuesBy(EigenValueOrderEnum order)
Definition: itkSymmetricEigenAnalysisImageFilter.h:266
itk::Functor::SymmetricEigenAnalysisFunction::operator==
bool operator==(const SymmetricEigenAnalysisFunction &other) const
Definition: itkSymmetricEigenAnalysisImageFilter.h:57
itk::Functor::SymmetricEigenAnalysisFixedDimensionFunction::operator!=
bool operator!=(const SymmetricEigenAnalysisFixedDimensionFunction &) const
Definition: itkSymmetricEigenAnalysisImageFilter.h:144
itk::Functor::SymmetricEigenAnalysisFixedDimensionFunction::operator==
bool operator==(const SymmetricEigenAnalysisFixedDimensionFunction &other) const
Definition: itkSymmetricEigenAnalysisImageFilter.h:150
itk::Functor::SymmetricEigenAnalysisFunction::m_Calculator
CalculatorType m_Calculator
Definition: itkSymmetricEigenAnalysisImageFilter.h:132
itk::SymmetricEigenAnalysisFixedDimensionImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkSymmetricEigenAnalysisImageFilter.h:382
itk::Functor::SymmetricEigenAnalysisFixedDimensionFunction::~SymmetricEigenAnalysisFixedDimensionFunction
~SymmetricEigenAnalysisFixedDimensionFunction()=default
itk::SymmetricEigenAnalysis::GetOrderEigenMagnitudes
bool GetOrderEigenMagnitudes() const
Definition: itkSymmetricEigenAnalysis.h:322
itk::SymmetricEigenAnalysisFixedDimensionImageFilter::Self
SymmetricEigenAnalysisFixedDimensionImageFilter Self
Definition: itkSymmetricEigenAnalysisImageFilter.h:346
itk::SymmetricEigenAnalysisFixedDimension::ComputeEigenValues
unsigned int ComputeEigenValues(const TMatrix &A, TVector &EigenValues) const
Definition: itkSymmetricEigenAnalysis.h:795
itk::SymmetricEigenAnalysisEnums::EigenValueOrder
EigenValueOrder
Definition: itkSymmetricEigenAnalysis.h:130
itk::SymmetricEigenAnalysisImageFilter::SetDimension
void SetDimension(unsigned int p)
Definition: itkSymmetricEigenAnalysisImageFilter.h:293
itk::SymmetricEigenAnalysis< TInputImage::PixelType, TOutputImage::PixelType >
itk::Functor::SymmetricEigenAnalysisFunction< TInputImage::PixelType, TOutputImage::PixelType >::RealValueType
typename TInputImage::PixelType ::RealValueType RealValueType
Definition: itkSymmetricEigenAnalysisImageFilter.h:46
itk::Functor::SymmetricEigenAnalysisFixedDimensionFunction::operator()
TOutput operator()(const TInput &x) const
Definition: itkSymmetricEigenAnalysisImageFilter.h:156
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90
itk::Functor::SymmetricEigenAnalysisFixedDimensionFunction< TMatrixDimension, TInputImage::PixelType, TOutputImage::PixelType >::RealValueType
typename TInputImage::PixelType ::RealValueType RealValueType
Definition: itkSymmetricEigenAnalysisImageFilter.h:139