ITK  4.9.0
Insight Segmentation and Registration Toolkit
itkStructureTensorImageFilter.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 //
19 // Created by Jean-Marie Mirebeau on 05/03/2014.
20 //
21 //
22 
23 #ifndef itkStructureTensorImageFilter_h
24 #define itkStructureTensorImageFilter_h
25 
26 #include "itkCastImageFilter.h"
28 #include "itkAddImageFilter.h"
30 #include "itkGradientImageFilter.h"
32 
33 namespace itk
34 {
49 template< typename TImage,
50  typename TTensorImage =
51  Image< SymmetricSecondRankTensor< typename TImage::PixelType,TImage::ImageDimension >, TImage::ImageDimension > >
53  public ImageToImageFilter< TImage, TTensorImage >
54 {
55 public:
60 
62  itkNewMacro(Self);
65 
66  typedef TImage ImageType;
67  typedef typename ImageType::PixelType PixelType;
68  static const unsigned int Dimension = ImageType::ImageDimension;
69  typedef TTensorImage TensorImageType;
70  typedef typename TensorImageType::PixelType TensorType;
71  typedef typename TensorType::ComponentType ScalarType;
73 
75  itkSetMacro(NoiseScale, ScalarType);
77  itkSetMacro(FeatureScale, ScalarType);
79  itkSetMacro(RescaleForUnitMaximumTrace, bool);
80 
81  itkGetConstMacro(NoiseScale, ScalarType);
82  itkGetConstMacro(FeatureScale, ScalarType);
83  itkGetConstMacro(RescaleForUnitMaximumTrace, bool);
84  itkGetConstMacro(PostRescaling, ScalarType);
85 
86 protected:
87  virtual void GenerateData() ITK_OVERRIDE;
88 
94 
95  struct DispatchBase {};
96  template< bool >
97  struct Dispatch: public DispatchBase {};
98 
99  void IntermediateFilter( const Dispatch< true > & );
100  void IntermediateFilter( const Dispatch< false > & );
101  typename TensorImageType::Pointer m_IntermediateResult;
102 
105 
107  {
109  {
110  TensorType m;
111  for( unsigned int i = 0; i < Dimension; ++i )
112  {
113  for( unsigned int j = i; j < Dimension; ++j)
114  {
115  m(i,j) = u[i]*u[j];
116  }
117  }
118  return m;
119  }
120  };
122  {
123  ScalarType operator()(const TensorType & t) const {
124  return t.GetTrace();
125  }
126  };
128  {
130  TensorType operator()(const TensorType & t) const {
131  return t*scaling;
132  }
133  };
134 
136 };
137 
138 } // end namespace itk
139 
140 #ifndef ITK_MANUAL_INSTANTIATION
141 #include "itkStructureTensorImageFilter.hxx"
142 #endif
143 
144 #endif
Light weight base class for most itk classes.
Image< ScalarType, Dimension > ScalarImageType
void IntermediateFilter(const Dispatch< true > &)
ImageToImageFilter< TImage, TImage > Superclass
Image< CovariantVectorType, Dimension > CovariantImageType
CovariantVector< ScalarType, Dimension > CovariantVectorType
Base class for filters that take an image as input and produce an image as output.
TensorType operator()(const CovariantVectorType &u) const
A templated class holding a n-Dimensional covariant vector.
Templated n-dimensional image class.
Definition: itkImage.h:75
virtual void GenerateData() override
Global rescaling constant used.