ITK  4.3.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"
23 
24 namespace itk
25 {
26 
38 template <class TInputImage, class TOutputImage = TInputImage>
40  : public ImageToImageFilter<TInputImage, TOutputImage>
41 {
42 public:
47 
49  itkNewMacro( Self );
50 
52  itkStaticConstMacro( ImageDimension, unsigned int, TInputImage::ImageDimension );
53 
54  typedef TInputImage InputFieldType;
55  typedef TOutputImage OutputFieldType;
56 
59 
61  typedef typename OutputFieldType::PixelType PixelType;
62  typedef typename OutputFieldType::PixelType VectorType;
63  typedef typename OutputFieldType::RegionType RegionType;
64  typedef typename OutputFieldType::IndexType IndexType;
65 
66  typedef typename OutputFieldType::PointType PointType;
67  typedef typename OutputFieldType::SpacingType SpacingType;
68  typedef typename OutputFieldType::PointType OriginType;
69  typedef typename OutputFieldType::SizeType SizeType;
70  typedef typename OutputFieldType::DirectionType DirectionType;
71 
73  typedef typename VectorType::ComponentType RealType;
76 
78  itkGetObjectMacro( Interpolator, InterpolatorType );
79 
81  void SetDisplacementField( const InputFieldType *field )
82  {
83  itkDebugMacro( "setting deformation field to " << field );
84  if ( field != this->GetInput( 0 ) )
85  {
86  this->SetInput( 0, field );
87  this->Modified();
88  if( ! this->m_Interpolator.IsNull() )
89  {
90  this->m_Interpolator->SetInputImage( field );
91  }
92  }
93  }
95 
100  {
101  return this->GetInput( 0 );
102  }
103 
105  itkSetInputMacro( InverseFieldInitialEstimate, InverseDisplacementFieldType );
106  itkGetInputMacro( InverseFieldInitialEstimate, InverseDisplacementFieldType );
108 
109  /* Set the interpolator. */
110  virtual void SetInterpolator( InterpolatorType* interpolator );
111 
112  /* Set/Get the number of iterations */
113  itkSetMacro( MaximumNumberOfIterations, unsigned int );
114  itkGetConstMacro( MaximumNumberOfIterations, unsigned int );
115 
116  /* Set/Get the mean stopping criterion */
117  itkSetMacro( MeanErrorToleranceThreshold, RealType );
118  itkGetConstMacro( MeanErrorToleranceThreshold, RealType );
119 
120  /* Set/Get the max stopping criterion */
121  itkSetMacro( MaxErrorToleranceThreshold, RealType );
122  itkGetConstMacro( MaxErrorToleranceThreshold, RealType );
123 
124  /* Get the max norm */
125  itkGetConstMacro( MaxErrorNorm, RealType );
126 
127  /* Get the mean norm */
128  itkGetConstMacro( MeanErrorNorm, RealType );
129 
130 /* Should we force the boundary to have zero displacement? */
131  itkSetMacro( EnforceBoundaryCondition, bool );
132  itkGetMacro( EnforceBoundaryCondition, bool );
133 
134 protected:
135 
138 
141 
143  void PrintSelf( std::ostream& os, Indent indent ) const;
144 
146  void GenerateData();
147 
150 
151 private:
152  InvertDisplacementFieldImageFilter( const Self& ); //purposely not implemented
153  void operator=( const Self& ); //purposely not implemented
154 
157 
159 
162 
163  // internal ivars necessary for multithreading basic operations
164 
165  typename DisplacementFieldType::Pointer m_ComposedField;
167 
174 
175 };
176 
177 } // end namespace itk
178 
179 #ifndef ITK_MANUAL_INSTANTIATION
180 #include "itkInvertDisplacementFieldImageFilter.hxx"
181 #endif
182 
183 #endif
184