ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkInvertDisplacementFieldImageFilter.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 itkInvertDisplacementFieldImageFilter_h
19 #define itkInvertDisplacementFieldImageFilter_h
20 
21 #include "itkImageToImageFilter.h"
24 #include "itkSimpleFastMutexLock.h"
25 
26 namespace itk
27 {
28 
40 template <typename TInputImage, typename TOutputImage = TInputImage>
41 class ITK_TEMPLATE_EXPORT InvertDisplacementFieldImageFilter
42  : public ImageToImageFilter<TInputImage, TOutputImage>
43 {
44 public:
49 
51  itkNewMacro( Self );
52 
54  itkStaticConstMacro( ImageDimension, unsigned int, TInputImage::ImageDimension );
55 
56  typedef TInputImage InputFieldType;
57  typedef TOutputImage OutputFieldType;
58 
61 
63  typedef typename OutputFieldType::PixelType PixelType;
64  typedef typename OutputFieldType::PixelType VectorType;
65  typedef typename OutputFieldType::RegionType RegionType;
67 
69  typedef typename OutputFieldType::SpacingType SpacingType;
73 
75  typedef typename VectorType::ComponentType RealType;
80 
82  itkGetModifiableObjectMacro( Interpolator, InterpolatorType );
83 
85  void SetDisplacementField( const InputFieldType *field )
86  {
87  itkDebugMacro( "setting deformation field to " << field );
88  if ( field != this->GetInput( 0 ) )
89  {
90  this->SetInput( 0, field );
91  this->Modified();
92  if( ! this->m_Interpolator.IsNull() )
93  {
94  this->m_Interpolator->SetInputImage( field );
95  }
96  }
97  }
99 
104  {
105  return this->GetInput( 0 );
106  }
107 
109  itkSetInputMacro( InverseFieldInitialEstimate, InverseDisplacementFieldType );
110  itkGetInputMacro( InverseFieldInitialEstimate, InverseDisplacementFieldType );
112 
113  /* Set the interpolator. */
114  virtual void SetInterpolator( InterpolatorType* interpolator );
115 
116  /* Set/Get the number of iterations */
117  itkSetMacro( MaximumNumberOfIterations, unsigned int );
118  itkGetConstMacro( MaximumNumberOfIterations, unsigned int );
119 
120  /* Set/Get the mean stopping criterion */
121  itkSetMacro( MeanErrorToleranceThreshold, RealType );
122  itkGetConstMacro( MeanErrorToleranceThreshold, RealType );
123 
124  /* Set/Get the max stopping criterion */
125  itkSetMacro( MaxErrorToleranceThreshold, RealType );
126  itkGetConstMacro( MaxErrorToleranceThreshold, RealType );
127 
128  /* Get the max norm */
129  itkGetConstMacro( MaxErrorNorm, RealType );
130 
131  /* Get the mean norm */
132  itkGetConstMacro( MeanErrorNorm, RealType );
133 
134 /* Should we force the boundary to have zero displacement? */
135  itkSetMacro( EnforceBoundaryCondition, bool );
136  itkGetMacro( EnforceBoundaryCondition, bool );
137 
138 protected:
139 
142 
144  virtual ~InvertDisplacementFieldImageFilter() ITK_OVERRIDE;
145 
147  void PrintSelf( std::ostream& os, Indent indent ) const ITK_OVERRIDE;
148 
150  void GenerateData() ITK_OVERRIDE;
151 
153  void ThreadedGenerateData( const RegionType &, ThreadIdType ) ITK_OVERRIDE;
154 
155 private:
156  ITK_DISALLOW_COPY_AND_ASSIGN(InvertDisplacementFieldImageFilter);
157 
159  typename InterpolatorType::Pointer m_Interpolator;
160 
161  unsigned int m_MaximumNumberOfIterations;
162 
163  RealType m_MaxErrorToleranceThreshold;
164  RealType m_MeanErrorToleranceThreshold;
165 
166  // internal ivars necessary for multithreading basic operations
167 
168  typename DisplacementFieldType::Pointer m_ComposedField;
169  typename RealImageType::Pointer m_ScaledNormImage;
170 
171  RealType m_MaxErrorNorm;
172  RealType m_MeanErrorNorm;
173  RealType m_Epsilon;
174  SpacingType m_DisplacementFieldSpacing;
175  bool m_DoThreadedEstimateInverse;
176  bool m_EnforceBoundaryCondition;
178 
179 };
180 
181 } // end namespace itk
182 
183 #ifndef ITK_MANUAL_INSTANTIATION
184 #include "itkInvertDisplacementFieldImageFilter.hxx"
185 #endif
186 
187 #endif
Critical section locking class that can be allocated on the stack.
ImageToImageFilter< TInputImage, TOutputImage > Superclass
VectorInterpolateImageFunction< InputFieldType, RealType > InterpolatorType
VectorLinearInterpolateImageFunction< InputFieldType, RealType > DefaultInterpolatorType
Base class for all process objects that output image data.
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
Base class for filters that take an image as input and produce an image as output.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Base class for all vector image interpolaters.
Iteratively estimate the inverse field of a displacement field.
Templated n-dimensional image class.
Definition: itkImage.h:75
Linearly interpolate a vector image at specified positions.