ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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
25namespace 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.
35namespace Functor
36{
37
38#if !defined(ITK_LEGACY_REMOVE)
39using OrderTypeOfEigenValue = EigenValueOrderEnum;
40#endif
41
42template <typename TInput, typename TOutput>
44{
45public:
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 {
69 m_Calculator.SetDimension(n);
70 }
71 unsigned int
73 {
74 return m_Calculator.GetDimension();
75 }
76
77
78#if !defined(ITK_LEGACY_REMOVE)
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 {
95 if (order == EigenValueOrderEnum::OrderByMagnitude)
96 {
97 m_Calculator.SetOrderEigenMagnitudes(true);
98 }
99 else if (order == EigenValueOrderEnum::DoNotOrder)
100 {
101 m_Calculator.SetOrderEigenValues(false);
102 }
103 }
104 void
111 {
112 if (m_Calculator.GetOrderEigenMagnitudes())
113 {
114 return EigenValueOrderEnum::OrderByMagnitude;
115 }
116 if (m_Calculator.GetOrderEigenValues())
117 {
118 return EigenValueOrderEnum::OrderByValue;
119 }
120 return EigenValueOrderEnum::DoNotOrder;
121 }
122
123
124
125private:
127};
128
129template <unsigned int TMatrixDimension, typename TInput, typename TOutput>
131{
132public:
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
155 {
156 return m_Calculator.GetDimension();
157 }
158
159#if !defined(ITK_LEGACY_REMOVE)
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 {
176 if (order == EigenValueOrderEnum::OrderByMagnitude)
177 {
178 m_Calculator.SetOrderEigenMagnitudes(true);
179 }
180 else if (order == EigenValueOrderEnum::DoNotOrder)
181 {
182 m_Calculator.SetOrderEigenValues(false);
183 }
184 }
185
186
187private:
189};
190
192extern ITKImageIntensity_EXPORT std::ostream &
193 operator<<(std::ostream & out, const EigenValueOrderEnum value);
194
195} // end namespace Functor
196
215template <typename TInputImage, typename TOutputImage>
218 TInputImage,
219 TOutputImage,
220 Functor::SymmetricEigenAnalysisFunction<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
221{
222public:
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)
243 using EigenValueOrderType = EigenValueOrderEnum;
244#endif
245
248 void
253 void
260 {
261 return this->GetFunctor().GetOrderEigenValuesBy();
262 }
263
264
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
287 {
288 return this->GetFunctor().GetDimension();
289 }
290
291
292 itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputValueType>));
293
294protected:
295 SymmetricEigenAnalysisImageFilter() { this->SetDimension(TInputImage::ImageDimension); }
297};
298
317template <unsigned int TMatrixDimension, typename TInputImage, typename TOutputImage = TInputImage>
320 TInputImage,
321 TOutputImage,
322 Functor::SymmetricEigenAnalysisFixedDimensionFunction<TMatrixDimension,
323 typename TInputImage::PixelType,
324 typename TOutputImage::PixelType>>
325{
326public:
327 ITK_DISALLOW_COPY_AND_MOVE(SymmetricEigenAnalysisFixedDimensionImageFilter);
328
332 UnaryFunctorImageFilter<TInputImage,
333 TOutputImage,
335 typename TInputImage::PixelType,
336 typename TOutputImage::PixelType>>;
337
340
341 using typename Superclass::OutputImageType;
342 using OutputPixelType = typename TOutputImage::PixelType;
343 using InputPixelType = typename TInputImage::PixelType;
344 using InputValueType = typename InputPixelType::ValueType;
345 using typename Superclass::FunctorType;
346
349
352 void
357
359 itkOverrideGetNameOfClassMacro(SymmetricEigenAnalysisFixedDimensionImageFilter);
360
362 itkNewMacro(Self);
363
365 void
366 PrintSelf(std::ostream & os, Indent indent) const override
367 {
368 this->Superclass::PrintSelf(os, indent);
369 }
370
372 unsigned int
374 {
375 return this->GetFunctor().GetDimension();
376 }
377
378 itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputValueType>));
379
380protected:
383};
384} // end namespace itk
385
386#endif
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(SymmetricEigenAnalysisFixedDimensionFunction)
SymmetricEigenAnalysisFixedDimension< TMatrixDimension, TInput, TOutput > CalculatorType
bool operator==(const SymmetricEigenAnalysisFixedDimensionFunction &) const
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(SymmetricEigenAnalysisFunction)
bool operator==(const SymmetricEigenAnalysisFunction &) const
void PrintSelf(std::ostream &os, Indent indent) const override
Control indentation during Print() invocation.
Definition itkIndent.h:50
Implements transparent reference counting.
UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::SymmetricEigenAnalysisFixedDimensionFunction< TMatrixDimension, typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
void PrintSelf(std::ostream &os, Indent indent) const override
~SymmetricEigenAnalysisImageFilter() override=default
void PrintSelf(std::ostream &os, Indent indent) const override
UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::SymmetricEigenAnalysisFunction< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
Find Eigen values of a real 2D symmetric matrix. It serves as a thread-safe alternative to the class:...
#define itkConceptMacro(name, concept)
ITKImageIntensity_EXPORT std::ostream & operator<<(std::ostream &out, const EigenValueOrderEnum value)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
SymmetricEigenAnalysisEnums::EigenValueOrder EigenValueOrderEnum