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
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 {
70 }
71 unsigned int
73 {
75 }
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 {
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 }
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 {
177 {
179 }
180 else if (order == EigenValueOrderEnum::DoNotOrder)
181 {
183 }
184 }
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
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
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
298protected:
299 SymmetricEigenAnalysisImageFilter() { this->SetDimension(TInputImage::ImageDimension); }
301};
302
321template <unsigned int TMatrixDimension, typename TInputImage, typename TOutputImage = TInputImage>
324 TInputImage,
325 TOutputImage,
326 Functor::SymmetricEigenAnalysisFixedDimensionFunction<TMatrixDimension,
327 typename TInputImage::PixelType,
328 typename TOutputImage::PixelType>>
329{
330public:
331 ITK_DISALLOW_COPY_AND_MOVE(SymmetricEigenAnalysisFixedDimensionImageFilter);
332
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
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
388protected:
391};
392} // end namespace itk
393
394#endif
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(SymmetricEigenAnalysisFixedDimensionFunction)
bool operator==(const SymmetricEigenAnalysisFixedDimensionFunction &) const
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(SymmetricEigenAnalysisFunction)
bool operator==(const SymmetricEigenAnalysisFunction &) const
Base class for all process objects that output image data.
void PrintSelf(std::ostream &os, Indent indent) const override
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Computes the eigen-values of every input symmetric matrix pixel.
void PrintSelf(std::ostream &os, Indent indent) const override
unsigned int ComputeEigenValues(const TMatrix &A, TVector &EigenValues) const
Computes the eigen-values of every input symmetric matrix pixel.
~SymmetricEigenAnalysisImageFilter() override=default
void PrintSelf(std::ostream &os, Indent indent) const override
void SetDimension(const unsigned int n)
unsigned int ComputeEigenValues(const TMatrix &A, TVector &D) const
Implements pixel-wise generic operation on one image.
#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