ITK  6.0.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  * 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 #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;
48  bool
50  {
51  return true;
52  }
53 
55 
56  inline TOutput
57  operator()(const TInput & x) const
58  {
59  TOutput eigenValues{};
60 
61  m_Calculator.ComputeEigenValues(x, eigenValues);
62  return eigenValues;
63  }
64 
66  void
67  SetDimension(unsigned int n)
68  {
70  }
71  unsigned int
72  GetDimension() const
73  {
74  return m_Calculator.GetDimension();
75  }
78 #if !defined(ITK_LEGACY_REMOVE)
79 
80  using EigenValueOrderType = EigenValueOrderEnum;
81 #endif
82 #if !defined(ITK_LEGACY_REMOVE)
83  // We need to expose the enum values at the class level
84  // for backwards compatibility
85  static constexpr EigenValueOrderEnum OrderByValue = EigenValueOrderEnum::OrderByValue;
86  static constexpr EigenValueOrderEnum OrderByMagnitude = EigenValueOrderEnum::OrderByMagnitude;
87  static constexpr EigenValueOrderEnum DoNotOrder = EigenValueOrderEnum::DoNotOrder;
88 #endif
89 
92  void
94  {
96  {
98  }
99  else if (order == EigenValueOrderEnum::DoNotOrder)
100  {
102  }
103  }
104  void
106  {
107  this->OrderEigenValuesBy(order);
108  }
111  {
113  {
115  }
117  {
119  }
121  }
125 private:
127 };
128 
129 template <unsigned int TMatrixDimension, typename TInput, typename TOutput>
131 {
132 public:
133  using RealValueType = typename TInput::RealValueType;
135  bool
137  {
138  return true;
139  }
140 
142 
143  inline TOutput
144  operator()(const TInput & x) const
145  {
146  TOutput eigenValues;
147 
148  m_Calculator.ComputeEigenValues(x, eigenValues);
149  return eigenValues;
150  }
151 
153  unsigned int
154  GetDimension() const
155  {
156  return m_Calculator.GetDimension();
157  }
158 
159 #if !defined(ITK_LEGACY_REMOVE)
160 
161  using EigenValueOrderType = EigenValueOrderEnum;
162 #endif
163 #if !defined(ITK_LEGACY_REMOVE)
164  // We need to expose the enum values at the class level
165  // for backwards compatibility
166  static constexpr EigenValueOrderEnum OrderByValue = EigenValueOrderEnum::OrderByValue;
167  static constexpr EigenValueOrderEnum OrderByMagnitude = EigenValueOrderEnum::OrderByMagnitude;
168  static constexpr EigenValueOrderEnum DoNotOrder = EigenValueOrderEnum::DoNotOrder;
169 #endif
170 
173  void
175  {
177  {
179  }
180  else if (order == EigenValueOrderEnum::DoNotOrder)
181  {
183  }
184  }
187 private:
189 };
190 
192 extern ITKImageIntensity_EXPORT std::ostream &
193  operator<<(std::ostream & out, const EigenValueOrderEnum value);
194 
195 } // end namespace Functor
196 
215 template <typename TInputImage, typename TOutputImage>
217  : public UnaryFunctorImageFilter<
218  TInputImage,
219  TOutputImage,
220  Functor::SymmetricEigenAnalysisFunction<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
221 {
222 public:
223  ITK_DISALLOW_COPY_AND_MOVE(SymmetricEigenAnalysisImageFilter);
224 
228  TInputImage,
229  TOutputImage,
231 
234 
235  using typename Superclass::OutputImageType;
236  using OutputPixelType = typename TOutputImage::PixelType;
237  using InputPixelType = typename TInputImage::PixelType;
238  using InputValueType = typename InputPixelType::ValueType;
239  using typename Superclass::FunctorType;
240 
241 #if !defined(ITK_LEGACY_REMOVE)
242 
243  using EigenValueOrderType = EigenValueOrderEnum;
244 #endif
245 
248  void
250  {
251  this->GetFunctor().OrderEigenValuesBy(order);
252  }
253  void
255  {
256  this->OrderEigenValuesBy(order);
257  }
260  {
261  return this->GetFunctor().GetOrderEigenValuesBy();
262  }
266  itkOverrideGetNameOfClassMacro(SymmetricEigenAnalysisImageFilter);
267 
269  itkNewMacro(Self);
270 
272  void
273  PrintSelf(std::ostream & os, Indent indent) const override
274  {
275  this->Superclass::PrintSelf(os, indent);
276  }
277 
280  void
281  SetDimension(unsigned int p)
282  {
283  this->GetFunctor().SetDimension(p);
284  }
285  unsigned int
286  GetDimension() const
287  {
288  return this->GetFunctor().GetDimension();
289  }
292 #ifdef ITK_USE_CONCEPT_CHECKING
293  // Begin concept checking
294  itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputValueType>));
295  // End concept checking
296 #endif
297 
298 protected:
299  SymmetricEigenAnalysisImageFilter() { this->SetDimension(TInputImage::ImageDimension); }
300  ~SymmetricEigenAnalysisImageFilter() override = default;
301 };
302 
321 template <unsigned int TMatrixDimension, typename TInputImage, typename TOutputImage = TInputImage>
323  : public UnaryFunctorImageFilter<
324  TInputImage,
325  TOutputImage,
326  Functor::SymmetricEigenAnalysisFixedDimensionFunction<TMatrixDimension,
327  typename TInputImage::PixelType,
328  typename TOutputImage::PixelType>>
329 {
330 public:
331  ITK_DISALLOW_COPY_AND_MOVE(SymmetricEigenAnalysisFixedDimensionImageFilter);
332 
335  using Superclass =
336  UnaryFunctorImageFilter<TInputImage,
337  TOutputImage,
339  typename TInputImage::PixelType,
340  typename TOutputImage::PixelType>>;
341 
344 
345  using typename Superclass::OutputImageType;
346  using OutputPixelType = typename TOutputImage::PixelType;
347  using InputPixelType = typename TInputImage::PixelType;
348  using InputValueType = typename InputPixelType::ValueType;
349  using typename Superclass::FunctorType;
350 
353 
356  void
358  {
359  this->GetFunctor().OrderEigenValuesBy(order);
360  }
361 
363  itkOverrideGetNameOfClassMacro(SymmetricEigenAnalysisFixedDimensionImageFilter);
364 
366  itkNewMacro(Self);
367 
369  void
370  PrintSelf(std::ostream & os, Indent indent) const override
371  {
372  this->Superclass::PrintSelf(os, indent);
373  }
374 
376  unsigned int
377  GetDimension() const
378  {
379  return this->GetFunctor().GetDimension();
380  }
381 
382 #ifdef ITK_USE_CONCEPT_CHECKING
383  // Begin concept checking
384  itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputValueType>));
385  // End concept checking
386 #endif
387 
388 protected:
391 };
392 } // end namespace itk
393 
394 #endif
itk::Functor::SymmetricEigenAnalysisFixedDimensionFunction::m_Calculator
CalculatorType m_Calculator
Definition: itkSymmetricEigenAnalysisImageFilter.h:188
itk::Functor::SymmetricEigenAnalysisFixedDimensionFunction::GetDimension
unsigned int GetDimension() const
Definition: itkSymmetricEigenAnalysisImageFilter.h:154
itk::SymmetricEigenAnalysisImageFilter
Computes the eigen-values of every input symmetric matrix pixel.
Definition: itkSymmetricEigenAnalysisImageFilter.h:216
itkUnaryFunctorImageFilter.h
itk::SymmetricEigenAnalysis::SetDimension
void SetDimension(const unsigned int n)
Definition: itkSymmetricEigenAnalysis.h:331
itk::Concept::HasNumericTraits
Definition: itkConceptChecking.h:717
itk::SymmetricEigenAnalysisImageFilter::GetDimension
unsigned int GetDimension() const
Definition: itkSymmetricEigenAnalysisImageFilter.h:286
itk::Functor::SymmetricEigenAnalysisFunction
Definition: itkSymmetricEigenAnalysisImageFilter.h:43
itk::Functor::SymmetricEigenAnalysisFunction::operator()
TOutput operator()(const TInput &x) const
Definition: itkSymmetricEigenAnalysisImageFilter.h:57
itk::Functor::SymmetricEigenAnalysisFixedDimensionFunction
Definition: itkSymmetricEigenAnalysisImageFilter.h:130
itk::UnaryFunctorImageFilter
Implements pixel-wise generic operation on one image.
Definition: itkUnaryFunctorImageFilter.h:50
itk::Functor::SymmetricEigenAnalysisFixedDimensionFunction::operator==
bool operator==(const SymmetricEigenAnalysisFixedDimensionFunction &) const
Definition: itkSymmetricEigenAnalysisImageFilter.h:136
itk::SymmetricEigenAnalysisImageFilter::OrderEigenValuesBy
void OrderEigenValuesBy(EigenValueOrderEnum order)
Definition: itkSymmetricEigenAnalysisImageFilter.h:249
itk::SymmetricEigenAnalysisFixedDimensionImageFilter::~SymmetricEigenAnalysisFixedDimensionImageFilter
~SymmetricEigenAnalysisFixedDimensionImageFilter() override=default
itk::Functor::SymmetricEigenAnalysisFunction::SetDimension
void SetDimension(unsigned int n)
Definition: itkSymmetricEigenAnalysisImageFilter.h:67
itk::SymmetricEigenAnalysisImageFilter::InputValueType
typename InputPixelType::ValueType InputValueType
Definition: itkSymmetricEigenAnalysisImageFilter.h:238
itk::Functor::SymmetricEigenAnalysisFunction::OrderEigenValuesBy
void OrderEigenValuesBy(EigenValueOrderEnum order)
Definition: itkSymmetricEigenAnalysisImageFilter.h:93
itk::SymmetricEigenAnalysisEnums::EigenValueOrder::OrderByMagnitude
itk::SymmetricEigenAnalysisFixedDimensionImageFilter::OrderEigenValuesBy
void OrderEigenValuesBy(EigenValueOrderEnum order)
Definition: itkSymmetricEigenAnalysisImageFilter.h:357
itk::SymmetricEigenAnalysisImageFilter::SymmetricEigenAnalysisImageFilter
SymmetricEigenAnalysisImageFilter()
Definition: itkSymmetricEigenAnalysisImageFilter.h:299
itk::SymmetricEigenAnalysisFixedDimension::SetOrderEigenValues
void SetOrderEigenValues(const bool b)
Definition: itkSymmetricEigenAnalysis.h:823
itk::SymmetricEigenAnalysisEnums::EigenValueOrder::OrderByValue
itk::SmartPointer< Self >
itk::SymmetricEigenAnalysisFixedDimensionImageFilter::GetDimension
unsigned int GetDimension() const
Definition: itkSymmetricEigenAnalysisImageFilter.h:377
itkSymmetricEigenAnalysis.h
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::SymmetricEigenAnalysisImageFilter::OutputPixelType
typename TOutputImage::PixelType OutputPixelType
Definition: itkSymmetricEigenAnalysisImageFilter.h:236
itk::SymmetricEigenAnalysis::GetOrderEigenValues
bool GetOrderEigenValues() const
Definition: itkSymmetricEigenAnalysis.h:300
itk::Functor::SymmetricEigenAnalysisFunction::GetDimension
unsigned int GetDimension() const
Definition: itkSymmetricEigenAnalysisImageFilter.h:72
itk::SymmetricEigenAnalysis::ComputeEigenValues
unsigned int ComputeEigenValues(const TMatrix &A, TVector &D) const
itk::EigenValueOrderEnum
SymmetricEigenAnalysisEnums::EigenValueOrder EigenValueOrderEnum
Definition: itkSymmetricEigenAnalysis.h:142
itk::SymmetricEigenAnalysisImageFilter::GetOrderEigenValuesBy
EigenValueOrderEnum GetOrderEigenValuesBy() const
Definition: itkSymmetricEigenAnalysisImageFilter.h:259
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:174
itk::SymmetricEigenAnalysisImageFilter::InputPixelType
typename TInputImage::PixelType InputPixelType
Definition: itkSymmetricEigenAnalysisImageFilter.h:237
itk::SymmetricEigenAnalysisEnums::EigenValueOrder
EigenValueOrder
Definition: itkSymmetricEigenAnalysis.h:131
itk::InPlaceImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
itk::SymmetricEigenAnalysisEnums::EigenValueOrder::DoNotOrder
itk::SymmetricEigenAnalysis::GetDimension
unsigned int GetDimension() const
Definition: itkSymmetricEigenAnalysis.h:344
itk::SymmetricEigenAnalysisFixedDimensionImageFilter::OutputPixelType
typename TOutputImage::PixelType OutputPixelType
Definition: itkSymmetricEigenAnalysisImageFilter.h:346
itk::SymmetricEigenAnalysisFixedDimensionImageFilter
Computes the eigen-values of every input symmetric matrix pixel.
Definition: itkSymmetricEigenAnalysisImageFilter.h:322
itk::SymmetricEigenAnalysisFixedDimension::SetOrderEigenMagnitudes
void SetOrderEigenMagnitudes(const bool b)
Definition: itkSymmetricEigenAnalysis.h:840
itk::SymmetricEigenAnalysis::SetOrderEigenMagnitudes
void SetOrderEigenMagnitudes(const bool b)
Definition: itkSymmetricEigenAnalysis.h:309
itk::Functor::SymmetricEigenAnalysisFunction::operator==
bool operator==(const SymmetricEigenAnalysisFunction &) const
Definition: itkSymmetricEigenAnalysisImageFilter.h:49
itk::UnaryFunctorImageFilter::FunctorType
TFunction FunctorType
Definition: itkUnaryFunctorImageFilter.h:68
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:862
itk::SymmetricEigenAnalysisFixedDimensionImageFilter::InputValueType
typename InputPixelType::ValueType InputValueType
Definition: itkSymmetricEigenAnalysisImageFilter.h:348
itk::SymmetricEigenAnalysisImageFilter::~SymmetricEigenAnalysisImageFilter
~SymmetricEigenAnalysisImageFilter() override=default
itk::SymmetricEigenAnalysisFixedDimension< TMatrixDimension, TInputImage::PixelType, TOutputImage::PixelType >
itk::SymmetricEigenAnalysis::SetOrderEigenValues
void SetOrderEigenValues(const bool b)
Definition: itkSymmetricEigenAnalysis.h:286
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: itkAnatomicalOrientation.h:29
itk::Functor::SymmetricEigenAnalysisFixedDimensionFunction::ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(SymmetricEigenAnalysisFixedDimensionFunction)
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::SymmetricEigenAnalysisImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkSymmetricEigenAnalysisImageFilter.h:273
itk::SymmetricEigenAnalysisFixedDimensionImageFilter::InputPixelType
typename TInputImage::PixelType InputPixelType
Definition: itkSymmetricEigenAnalysisImageFilter.h:347
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:105
itk::Functor::SymmetricEigenAnalysisFunction::GetOrderEigenValuesBy
EigenValueOrderEnum GetOrderEigenValuesBy() const
Definition: itkSymmetricEigenAnalysisImageFilter.h:110
itk::SymmetricEigenAnalysisImageFilter::SetOrderEigenValuesBy
void SetOrderEigenValuesBy(EigenValueOrderEnum order)
Definition: itkSymmetricEigenAnalysisImageFilter.h:254
AddImageFilter
Definition: itkAddImageFilter.h:81
itk::Functor::SymmetricEigenAnalysisFunction::m_Calculator
CalculatorType m_Calculator
Definition: itkSymmetricEigenAnalysisImageFilter.h:126
itk::SymmetricEigenAnalysisFixedDimensionImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkSymmetricEigenAnalysisImageFilter.h:370
itk::SymmetricEigenAnalysis::GetOrderEigenMagnitudes
bool GetOrderEigenMagnitudes() const
Definition: itkSymmetricEigenAnalysis.h:323
itk::SymmetricEigenAnalysisFixedDimension::ComputeEigenValues
unsigned int ComputeEigenValues(const TMatrix &A, TVector &EigenValues) const
Definition: itkSymmetricEigenAnalysis.h:791
itk::Functor::SymmetricEigenAnalysisFunction::ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(SymmetricEigenAnalysisFunction)
itk::SymmetricEigenAnalysisImageFilter::SetDimension
void SetDimension(unsigned int p)
Definition: itkSymmetricEigenAnalysisImageFilter.h:281
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:144
itk::Functor::SymmetricEigenAnalysisFixedDimensionFunction< TMatrixDimension, TInputImage::PixelType, TOutputImage::PixelType >::RealValueType
typename TInputImage::PixelType ::RealValueType RealValueType
Definition: itkSymmetricEigenAnalysisImageFilter.h:133