ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkImageRegistrationMethodv4.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 __itkImageRegistrationMethodv4_h
19 #define __itkImageRegistrationMethodv4_h
20 
21 #include "itkProcessObject.h"
22 
23 #include "itkCompositeTransform.h"
24 #include "itkDataObjectDecorator.h"
29 #include "itkShrinkImageFilter.h"
30 #include "itkTransform.h"
32 
33 #include <vector>
34 
35 namespace itk
36 {
37 
88 template<typename TFixedImage, typename TMovingImage, typename TOutputTransform>
89 class ITK_EXPORT ImageRegistrationMethodv4
90 :public ProcessObject
91 {
92 public:
98 
100  itkNewMacro( Self );
101 
103  itkStaticConstMacro( ImageDimension, unsigned int, TFixedImage::ImageDimension );
104 
107 
109  typedef TFixedImage FixedImageType;
110  typedef typename FixedImageType::Pointer FixedImagePointer;
111  typedef std::vector<FixedImagePointer> FixedImagesContainerType;
112  typedef TMovingImage MovingImageType;
113  typedef typename MovingImageType::Pointer MovingImagePointer;
114  typedef std::vector<MovingImagePointer> MovingImagesContainerType;
115 
119 
123 
124  typedef TOutputTransform OutputTransformType;
125  typedef typename OutputTransformType::Pointer OutputTransformPointer;
126  typedef typename OutputTransformType::ScalarType RealType;
127  typedef typename OutputTransformType::DerivativeType DerivativeType;
128  typedef typename DerivativeType::ValueType DerivativeValueType;
129 
132 
135 
142 
145 
147 
150 
154  typedef std::vector<TransformParametersAdaptorPointer> TransformParametersAdaptorsContainerType;
155 
159 
161  enum MetricSamplingStrategyType { NONE, REGULAR, RANDOM };
162 
164 
166  virtual void SetFixedImage( const FixedImageType *image )
167  {
168  this->SetFixedImage( 0, image );
169  }
170  virtual const FixedImageType * GetFixedImage() const
171  {
172  return this->GetFixedImage( 0 );
173  }
174  virtual void SetFixedImage( SizeValueType, const FixedImageType * );
175  virtual const FixedImageType * GetFixedImage( SizeValueType ) const;
177 
179  virtual void SetMovingImage( const MovingImageType *image )
180  {
181  this->SetMovingImage( 0, image );
182  }
183  virtual const MovingImageType * GetMovingImage() const
184  {
185  return this->GetMovingImage( 0 );
186  }
187  virtual void SetMovingImage( SizeValueType, const MovingImageType * );
188  virtual const MovingImageType * GetMovingImage( SizeValueType ) const;
190 
192  itkSetObjectMacro( Optimizer, OptimizerType );
193  itkGetModifiableObjectMacro(Optimizer, OptimizerType );
195 
197  itkSetObjectMacro( Metric, MetricType );
198  itkGetModifiableObjectMacro(Metric, MetricType );
200 
202  itkSetMacro( MetricSamplingStrategy, MetricSamplingStrategyType );
203  itkGetConstMacro( MetricSamplingStrategy, MetricSamplingStrategyType );
205 
207  void SetMetricSamplingPercentage( const RealType );
208 
210  itkSetMacro( MetricSamplingPercentagePerLevel, MetricSamplingPercentageArrayType );
211  itkGetConstMacro( MetricSamplingPercentagePerLevel, MetricSamplingPercentageArrayType );
213 
215  itkSetObjectMacro( FixedInitialTransform, InitialTransformType );
216  itkGetModifiableObjectMacro(FixedInitialTransform, InitialTransformType );
218 
220  itkSetObjectMacro( MovingInitialTransform, InitialTransformType );
221  itkGetModifiableObjectMacro(MovingInitialTransform, InitialTransformType );
223 
225  void SetTransformParametersAdaptorsPerLevel( TransformParametersAdaptorsContainerType & );
226  const TransformParametersAdaptorsContainerType & GetTransformParametersAdaptorsPerLevel() const;
228 
236  void SetNumberOfLevels( const SizeValueType );
237  itkGetConstMacro( NumberOfLevels, SizeValueType );
239 
247  void SetShrinkFactorsPerLevel( ShrinkFactorsArrayType factors )
248  {
249  for( unsigned int level = 0; level < factors.Size(); ++level )
250  {
252  shrinkFactors.Fill( factors[level] );
253  this->SetShrinkFactorsPerDimension( level, shrinkFactors );
254  }
255  }
257 
261  ShrinkFactorsPerDimensionContainerType GetShrinkFactorsPerDimension( const unsigned int level ) const
262  {
263  if( level >= this->m_ShrinkFactorsPerLevel.size() )
264  {
265  itkExceptionMacro( "Requesting level greater than the number of levels." );
266  }
267  return this->m_ShrinkFactorsPerLevel[level];
268  }
270 
274  void SetShrinkFactorsPerDimension( unsigned int level, ShrinkFactorsPerDimensionContainerType factors )
275  {
276  if( level >= this->m_ShrinkFactorsPerLevel.size() )
277  {
278  this->m_ShrinkFactorsPerLevel.resize( level + 1 );
279  }
280  this->m_ShrinkFactorsPerLevel[level] = factors;
281  this->Modified();
282  }
284 
290  itkSetMacro( SmoothingSigmasPerLevel, SmoothingSigmasArrayType );
291  itkGetConstMacro( SmoothingSigmasPerLevel, SmoothingSigmasArrayType );
293 
298  itkSetMacro( SmoothingSigmasAreSpecifiedInPhysicalUnits, bool );
299  itkGetConstMacro( SmoothingSigmasAreSpecifiedInPhysicalUnits, bool );
300  itkBooleanMacro( SmoothingSigmasAreSpecifiedInPhysicalUnits );
302 
305  using Superclass::MakeOutput;
307 
309  virtual const DecoratedOutputTransformType * GetOutput() const;
310 
312  itkGetConstMacro( CurrentLevel, SizeValueType );
313 
315  itkGetConstReferenceMacro( CurrentIteration, SizeValueType );
316 
317  /* Get the current metric value. This is a helper function for reporting observations. */
318  itkGetConstReferenceMacro( CurrentMetricValue, RealType );
319 
321  itkGetConstReferenceMacro( CurrentConvergenceValue, RealType );
322 
324  itkGetConstReferenceMacro( IsConverged, bool );
325 
326 #ifdef ITKV3_COMPATIBILITY
327 
342  void StartRegistration(void) { this->Update(); }
343 #endif
344 
345 protected:
347  virtual ~ImageRegistrationMethodv4();
348  virtual void PrintSelf( std::ostream & os, Indent indent ) const;
349 
351  virtual void GenerateData();
352 
354  virtual void InitializeRegistrationAtEachLevel( const SizeValueType );
355 
357  virtual void SetMetricSamplePoints();
358 
365 
370 
372 
376 
377  std::vector<ShrinkFactorsPerDimensionContainerType> m_ShrinkFactorsPerLevel;
380 
383 
385 
387 
389 
390 private:
391  ImageRegistrationMethodv4( const Self & ); //purposely not implemented
392  void operator=( const Self & ); //purposely not implemented
393 };
394 } // end namespace itk
395 
396 #ifndef ITK_MANUAL_INSTANTIATION
397 #include "itkImageRegistrationMethodv4.hxx"
398 #endif
399 
400 #endif
401