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  }
111 
112 private:
114 };
115 
116 template <unsigned int TMatrixDimension, typename TInput, typename TOutput>
118 {
119 public:
120  using RealValueType = typename TInput::RealValueType;
124  bool
126  {
127  return false;
128  }
129 
130  bool
132  {
133  return !(*this != other);
134  }
135 
136  inline TOutput
137  operator()(const TInput & x) const
138  {
139  TOutput eigenValues;
140 
141  m_Calculator.ComputeEigenValues(x, eigenValues);
142  return eigenValues;
143  }
144 
146  unsigned int
147  GetDimension() const
148  {
149  return m_Calculator.GetDimension();
150  }
151 
152 #if !defined(ITK_LEGACY_REMOVE)
153 
154  using EigenValueOrderType = EigenValueOrderEnum;
155 #endif
156 #if !defined(ITK_LEGACY_REMOVE)
157  // We need to expose the enum values at the class level
158  // for backwards compatibility
159  static constexpr EigenValueOrderEnum OrderByValue = EigenValueOrderEnum::OrderByValue;
160  static constexpr EigenValueOrderEnum OrderByMagnitude = EigenValueOrderEnum::OrderByMagnitude;
161  static constexpr EigenValueOrderEnum DoNotOrder = EigenValueOrderEnum::DoNotOrder;
162 #endif
163 
166  void
168  {
170  {
172  }
173  else if (order == EigenValueOrderEnum::DoNotOrder)
174  {
176  }
177  }
179 
180 private:
182 };
183 
185 extern ITKImageIntensity_EXPORT std::ostream &
186  operator<<(std::ostream & out, const EigenValueOrderEnum value);
187 
188 } // end namespace Functor
189 
211 template <typename TInputImage, typename TOutputImage = TInputImage>
213  : public UnaryFunctorImageFilter<
214  TInputImage,
215  TOutputImage,
216  Functor::SymmetricEigenAnalysisFunction<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
217 {
218 public:
219  ITK_DISALLOW_COPY_AND_ASSIGN(SymmetricEigenAnalysisImageFilter);
220 
224  TInputImage,
225  TOutputImage,
227 
230 
232  using OutputPixelType = typename TOutputImage::PixelType;
233  using InputPixelType = typename TInputImage::PixelType;
234  using InputValueType = typename InputPixelType::ValueType;
236 
237 #if !defined(ITK_LEGACY_REMOVE)
238 
239  using EigenValueOrderType = EigenValueOrderEnum;
240 #endif
241 
244  void
246  {
247  this->GetFunctor().OrderEigenValuesBy(order);
248  }
249 
252 
254  itkNewMacro(Self);
255 
257  void
258  PrintSelf(std::ostream & os, Indent indent) const override
259  {
260  this->Superclass::PrintSelf(os, indent);
261  }
262 
265  void
266  SetDimension(unsigned int p)
267  {
268  this->GetFunctor().SetDimension(p);
269  }
270  unsigned int
271  GetDimension() const
272  {
273  return this->GetFunctor().GetDimension();
274  }
276 
277 #ifdef ITK_USE_CONCEPT_CHECKING
278  // Begin concept checking
279  itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputValueType>));
280  // End concept checking
281 #endif
282 
283 protected:
285  ~SymmetricEigenAnalysisImageFilter() override = default;
286 };
287 
306 template <unsigned int TMatrixDimension, typename TInputImage, typename TOutputImage = TInputImage>
308  : public UnaryFunctorImageFilter<
309  TInputImage,
310  TOutputImage,
311  Functor::SymmetricEigenAnalysisFixedDimensionFunction<TMatrixDimension,
312  typename TInputImage::PixelType,
313  typename TOutputImage::PixelType>>
314 {
315 public:
316  ITK_DISALLOW_COPY_AND_ASSIGN(SymmetricEigenAnalysisFixedDimensionImageFilter);
317 
320  using Superclass =
321  UnaryFunctorImageFilter<TInputImage,
322  TOutputImage,
324  typename TInputImage::PixelType,
325  typename TOutputImage::PixelType>>;
326 
329 
331  using OutputPixelType = typename TOutputImage::PixelType;
332  using InputPixelType = typename TInputImage::PixelType;
333  using InputValueType = typename InputPixelType::ValueType;
335 
338 
341  void
343  {
344  this->GetFunctor().OrderEigenValuesBy(order);
345  }
346 
349 
351  itkNewMacro(Self);
352 
354  void
355  PrintSelf(std::ostream & os, Indent indent) const override
356  {
357  this->Superclass::PrintSelf(os, indent);
358  }
359 
361  unsigned int
362  GetDimension() const
363  {
364  return this->GetFunctor().GetDimension();
365  }
366 
367 #ifdef ITK_USE_CONCEPT_CHECKING
368  // Begin concept checking
369  itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputValueType>));
370  // End concept checking
371 #endif
372 
373 protected:
376 };
377 } // end namespace itk
378 
379 #endif
itk::Functor::SymmetricEigenAnalysisFixedDimensionFunction::m_Calculator
CalculatorType m_Calculator
Definition: itkSymmetricEigenAnalysisImageFilter.h:181
itk::Functor::SymmetricEigenAnalysisFixedDimensionFunction::GetDimension
unsigned int GetDimension() const
Definition: itkSymmetricEigenAnalysisImageFilter.h:147
itk::SymmetricEigenAnalysisImageFilter
Computes the eigen-values of every input symmetric matrix pixel.
Definition: itkSymmetricEigenAnalysisImageFilter.h:212
itkUnaryFunctorImageFilter.h
itk::SymmetricEigenAnalysis::SetDimension
void SetDimension(const unsigned int n)
Definition: itkSymmetricEigenAnalysis.h:330
itk::Concept::HasNumericTraits
Definition: itkConceptChecking.h:712
itk::SymmetricEigenAnalysisImageFilter::GetDimension
unsigned int GetDimension() const
Definition: itkSymmetricEigenAnalysisImageFilter.h:271
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:117
itk::UnaryFunctorImageFilter
Implements pixel-wise generic operation on one image.
Definition: itkUnaryFunctorImageFilter.h:50
itk::SymmetricEigenAnalysisImageFilter::OrderEigenValuesBy
void OrderEigenValuesBy(EigenValueOrderEnum order)
Definition: itkSymmetricEigenAnalysisImageFilter.h:245
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:234
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:342
itk::SymmetricEigenAnalysisEnums::EigenValueOrder::OrderByMagnitude
itk::Functor::SymmetricEigenAnalysisFunction::SymmetricEigenAnalysisFunction
SymmetricEigenAnalysisFunction()=default
itk::SymmetricEigenAnalysisFixedDimension::SetOrderEigenValues
void SetOrderEigenValues(const bool b)
Definition: itkSymmetricEigenAnalysis.h:830
itk::SymmetricEigenAnalysisImageFilter::FunctorType
typename Superclass::FunctorType FunctorType
Definition: itkSymmetricEigenAnalysisImageFilter.h:235
itk::SmartPointer< Self >
itk::SymmetricEigenAnalysisFixedDimensionImageFilter::GetDimension
unsigned int GetDimension() const
Definition: itkSymmetricEigenAnalysisImageFilter.h:362
itkSymmetricEigenAnalysis.h
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::SymmetricEigenAnalysisImageFilter::OutputPixelType
typename TOutputImage::PixelType OutputPixelType
Definition: itkSymmetricEigenAnalysisImageFilter.h:232
itk::Functor::SymmetricEigenAnalysisFunction::GetDimension
unsigned int GetDimension() const
Definition: itkSymmetricEigenAnalysisImageFilter.h:78
itk::EigenValueOrderEnum
SymmetricEigenAnalysisEnums::EigenValueOrder EigenValueOrderEnum
Definition: itkSymmetricEigenAnalysis.h:141
itk::SymmetricEigenAnalysisImageFilter::Self
SymmetricEigenAnalysisImageFilter Self
Definition: itkSymmetricEigenAnalysisImageFilter.h:222
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:167
itk::SymmetricEigenAnalysisImageFilter::InputPixelType
typename TInputImage::PixelType InputPixelType
Definition: itkSymmetricEigenAnalysisImageFilter.h:233
itk::SymmetricEigenAnalysisFixedDimensionImageFilter::FunctorType
typename Superclass::FunctorType FunctorType
Definition: itkSymmetricEigenAnalysisImageFilter.h:334
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:331
itk::SymmetricEigenAnalysisFixedDimensionImageFilter
Computes the eigen-values of every input symmetric matrix pixel.
Definition: itkSymmetricEigenAnalysisImageFilter.h:307
itk::SymmetricEigenAnalysis::ComputeEigenValues
unsigned int ComputeEigenValues(const TMatrix &A, TVector &EigenValues) const
itk::SymmetricEigenAnalysisFixedDimension::SetOrderEigenMagnitudes
void SetOrderEigenMagnitudes(const bool b)
Definition: itkSymmetricEigenAnalysis.h:847
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:869
itk::SymmetricEigenAnalysisFixedDimensionImageFilter::InputValueType
typename InputPixelType::ValueType InputValueType
Definition: itkSymmetricEigenAnalysisImageFilter.h:333
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:64
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:258
itk::SymmetricEigenAnalysisFixedDimensionImageFilter::InputPixelType
typename TInputImage::PixelType InputPixelType
Definition: itkSymmetricEigenAnalysisImageFilter.h:332
itk::UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::SymmetricEigenAnalysisFunction< TInputImage::PixelType, TOutputImage::PixelType > >::GetFunctor
FunctorType & GetFunctor()
Definition: itkUnaryFunctorImageFilter.h:85
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:125
itk::Functor::SymmetricEigenAnalysisFixedDimensionFunction::operator==
bool operator==(const SymmetricEigenAnalysisFixedDimensionFunction &other) const
Definition: itkSymmetricEigenAnalysisImageFilter.h:131
itk::Functor::SymmetricEigenAnalysisFunction::m_Calculator
CalculatorType m_Calculator
Definition: itkSymmetricEigenAnalysisImageFilter.h:113
itk::SymmetricEigenAnalysisFixedDimensionImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkSymmetricEigenAnalysisImageFilter.h:355
itk::Functor::SymmetricEigenAnalysisFixedDimensionFunction::~SymmetricEigenAnalysisFixedDimensionFunction
~SymmetricEigenAnalysisFixedDimensionFunction()=default
itk::SymmetricEigenAnalysisFixedDimensionImageFilter::Self
SymmetricEigenAnalysisFixedDimensionImageFilter Self
Definition: itkSymmetricEigenAnalysisImageFilter.h:319
itk::SymmetricEigenAnalysisFixedDimension::ComputeEigenValues
unsigned int ComputeEigenValues(const TMatrix &A, TVector &EigenValues) const
Definition: itkSymmetricEigenAnalysis.h:798
itk::SymmetricEigenAnalysisEnums::EigenValueOrder
EigenValueOrder
Definition: itkSymmetricEigenAnalysis.h:130
itk::SymmetricEigenAnalysisImageFilter::SetDimension
void SetDimension(unsigned int p)
Definition: itkSymmetricEigenAnalysisImageFilter.h:266
itk::SymmetricEigenAnalysisImageFilter::SymmetricEigenAnalysisImageFilter
SymmetricEigenAnalysisImageFilter()=default
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:137
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:120