ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkSymmetricEigenAnalysisImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 
24 namespace itk
25 {
26 // This functor class invokes the computation of Eigen Analysis for
27 // every pixel. The input pixel type must provide the API for the [][]
28 // operator, while the output pixel type must provide the API for the
29 // [] operator. Input pixel matrices should be symmetric.
30 //
31 // The default operation is to order eigen values in ascending order.
32 // You may also use OrderEigenValuesBy( ) to order eigen values by
33 // magnitude as is common with use of tensors in vessel extraction.
34 namespace Functor
35 {
36 template< typename TInput, typename TOutput >
38 {
39 public:
40  using RealValueType = typename TInput::RealValueType;
45  {
46  return false;
47  }
48 
49  bool operator==(const SymmetricEigenAnalysisFunction & other) const
50  {
51  return !( *this != other );
52  }
53 
54  inline TOutput operator()(const TInput & x) const
55  {
56  TOutput eigenValues;
57 
58  m_Calculator.ComputeEigenValues(x, eigenValues);
59  return eigenValues;
60  }
61 
63  void SetDimension(unsigned int n)
64  {
66  }
67  unsigned int GetDimension() const
68  {
69  return m_Calculator.GetDimension();
70  }
72 
78  typedef enum {
83 
87  {
88  if ( order == OrderByMagnitude )
89  {
91  }
92  else if ( order == DoNotOrder )
93  {
95  }
96  }
98 
99 private:
101 };
102 
103 template< unsigned int TMatrixDimension, typename TInput, typename TOutput >
105 {
106 public:
107  using RealValueType = typename TInput::RealValueType;
112  {
113  return false;
114  }
115 
117  {
118  return !( *this != other );
119  }
120 
121  inline TOutput operator()(const TInput & x) const
122  {
123  TOutput eigenValues;
124 
125  m_Calculator.ComputeEigenValues(x, eigenValues);
126  return eigenValues;
127  }
128 
130  unsigned int GetDimension() const
131  {
132  return m_Calculator.GetDimension();
133  }
134 
140  typedef enum {
145 
149  {
150  if ( order == OrderByMagnitude )
151  {
153  }
154  else if ( order == DoNotOrder )
155  {
157  }
158  }
160 
161 private:
163 };
164 } // end namespace Functor
165 
186 template< typename TInputImage, typename TOutputImage = TInputImage >
188  public
189  UnaryFunctorImageFilter< TInputImage, TOutputImage,
190  Functor::SymmetricEigenAnalysisFunction<
191  typename TInputImage::PixelType,
192  typename TOutputImage::PixelType > >
193 {
194 public:
195  ITK_DISALLOW_COPY_AND_ASSIGN(SymmetricEigenAnalysisImageFilter);
196 
200  TInputImage, TOutputImage,
202  typename TInputImage::PixelType,
203  typename TOutputImage::PixelType > >;
204 
207 
209  using OutputPixelType = typename TOutputImage::PixelType;
210  using InputPixelType = typename TInputImage::PixelType;
211  using InputValueType = typename InputPixelType::ValueType;
213 
219  using EigenValueOrderType = typename FunctorType::EigenValueOrderType;
220 
224  {
225  this->GetFunctor().OrderEigenValuesBy(order);
226  }
227 
230 
232  itkNewMacro(Self);
233 
235  void PrintSelf(std::ostream & os, Indent indent) const override
236  { this->Superclass::PrintSelf(os, indent); }
237 
240  void SetDimension(unsigned int p)
241  {
242  this->GetFunctor().SetDimension(p);
243  }
244  unsigned int GetDimension() const
245  {
246  return this->GetFunctor().GetDimension();
247  }
249 
250 #ifdef ITK_USE_CONCEPT_CHECKING
251  // Begin concept checking
252  itkConceptMacro( InputHasNumericTraitsCheck,
254  // End concept checking
255 #endif
256 
257 protected:
259  ~SymmetricEigenAnalysisImageFilter() override = default;
260 };
261 
279 template< unsigned int TMatrixDimension, typename TInputImage, typename TOutputImage = TInputImage >
281  public
282  UnaryFunctorImageFilter< TInputImage, TOutputImage,
283  Functor::SymmetricEigenAnalysisFixedDimensionFunction<
284  TMatrixDimension,
285  typename TInputImage::PixelType,
286  typename TOutputImage::PixelType > >
287 {
288 public:
289  ITK_DISALLOW_COPY_AND_ASSIGN(SymmetricEigenAnalysisFixedDimensionImageFilter);
290 
294  TInputImage, TOutputImage,
296  TMatrixDimension,
297  typename TInputImage::PixelType,
298  typename TOutputImage::PixelType > >;
299 
302 
304  using OutputPixelType = typename TOutputImage::PixelType;
305  using InputPixelType = typename TInputImage::PixelType;
306  using InputValueType = typename InputPixelType::ValueType;
308 
314  using EigenValueOrderType = typename FunctorType::EigenValueOrderType;
315 
319  {
320  this->GetFunctor().OrderEigenValuesBy(order);
321  }
322 
325 
327  itkNewMacro(Self);
328 
330  void PrintSelf(std::ostream & os, Indent indent) const override
331  { this->Superclass::PrintSelf(os, indent); }
332 
334  unsigned int GetDimension() const
335  {
336  return this->GetFunctor().GetDimension();
337  }
338 
339 #ifdef ITK_USE_CONCEPT_CHECKING
340  // Begin concept checking
341  itkConceptMacro( InputHasNumericTraitsCheck,
343  // End concept checking
344 #endif
345 
346 protected:
349 };
350 } // end namespace itk
351 
352 #endif
void PrintSelf(std::ostream &os, Indent indent) const override
typename FunctorType::EigenValueOrderType EigenValueOrderType
bool operator!=(const SymmetricEigenAnalysisFunction &) const
bool operator==(const SymmetricEigenAnalysisFunction &other) const
Computes the eigen-values of every input symmetric matrix pixel.
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
unsigned int ComputeEigenValues(const TMatrix &A, TVector &EigenValues) const
Base class for all process objects that output image data.
TOutputImage OutputImageType
void PrintSelf(std::ostream &os, Indent indent) const override
unsigned int ComputeEigenValues(const TMatrix &A, TVector &EigenValues) const
void SetDimension(const unsigned int n)
~SymmetricEigenAnalysisImageFilter() override=default
void PrintSelf(std::ostream &os, Indent indent) const override
Implements pixel-wise generic operation on one image.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
#define itkConceptMacro(name, concept)
bool operator!=(const SymmetricEigenAnalysisFixedDimensionFunction &) const
bool operator==(const SymmetricEigenAnalysisFixedDimensionFunction &other) const
Computes the eigen-values of every input symmetric matrix pixel.