ITK  4.5.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, typename TVirtualImage = TFixedImage>
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 
117  typedef TOutputTransform OutputTransformType;
118  typedef typename OutputTransformType::Pointer OutputTransformPointer;
119  typedef typename OutputTransformType::ScalarType RealType;
120  typedef typename OutputTransformType::DerivativeType DerivativeType;
121  typedef typename DerivativeType::ValueType DerivativeValueType;
122 
125 
128 
131 
132  typedef TVirtualImage VirtualImageType;
133 
136 
143 
146 
148 
151 
155  typedef std::vector<TransformParametersAdaptorPointer> TransformParametersAdaptorsContainerType;
156 
160 
163 
166 
168 
170  virtual void SetFixedImage( const FixedImageType *image )
171  {
172  this->SetFixedImage( 0, image );
173  }
174  virtual const FixedImageType * GetFixedImage() const
175  {
176  return this->GetFixedImage( 0 );
177  }
178  virtual void SetFixedImage( SizeValueType, const FixedImageType * );
179  virtual const FixedImageType * GetFixedImage( SizeValueType ) const;
181 
183  virtual void SetMovingImage( const MovingImageType *image )
184  {
185  this->SetMovingImage( 0, image );
186  }
187  virtual const MovingImageType * GetMovingImage() const
188  {
189  return this->GetMovingImage( 0 );
190  }
191  virtual void SetMovingImage( SizeValueType, const MovingImageType * );
192  virtual const MovingImageType * GetMovingImage( SizeValueType ) const;
194 
196  itkSetObjectMacro( Optimizer, OptimizerType );
197  itkGetModifiableObjectMacro( Optimizer, OptimizerType );
199 
209  itkGetConstMacro( OptimizerWeights, OptimizerWeightsType );
211 
213  itkSetObjectMacro( Metric, MetricType );
214  itkGetModifiableObjectMacro( Metric, MetricType );
216 
218  itkSetMacro( MetricSamplingStrategy, MetricSamplingStrategyType );
219  itkGetConstMacro( MetricSamplingStrategy, MetricSamplingStrategyType );
221 
224 
226  itkSetMacro( MetricSamplingPercentagePerLevel, MetricSamplingPercentageArrayType );
227  itkGetConstMacro( MetricSamplingPercentagePerLevel, MetricSamplingPercentageArrayType );
229 
231  itkSetObjectMacro( FixedInitialTransform, InitialTransformType );
232  itkGetModifiableObjectMacro( FixedInitialTransform, InitialTransformType );
234 
236  itkSetObjectMacro( MovingInitialTransform, InitialTransformType );
237  itkGetModifiableObjectMacro( MovingInitialTransform, InitialTransformType );
239 
244 
252  void SetNumberOfLevels( const SizeValueType );
253  itkGetConstMacro( NumberOfLevels, SizeValueType );
255 
264  {
265  for( unsigned int level = 0; level < factors.Size(); ++level )
266  {
268  shrinkFactors.Fill( factors[level] );
269  this->SetShrinkFactorsPerDimension( level, shrinkFactors );
270  }
271  }
273 
278  {
279  if( level >= this->m_ShrinkFactorsPerLevel.size() )
280  {
281  itkExceptionMacro( "Requesting level greater than the number of levels." );
282  }
283  return this->m_ShrinkFactorsPerLevel[level];
284  }
286 
291  {
292  if( level >= this->m_ShrinkFactorsPerLevel.size() )
293  {
294  this->m_ShrinkFactorsPerLevel.resize( level + 1 );
295  }
296  this->m_ShrinkFactorsPerLevel[level] = factors;
297  this->Modified();
298  }
300 
306  itkSetMacro( SmoothingSigmasPerLevel, SmoothingSigmasArrayType );
307  itkGetConstMacro( SmoothingSigmasPerLevel, SmoothingSigmasArrayType );
309 
314  itkSetMacro( SmoothingSigmasAreSpecifiedInPhysicalUnits, bool );
315  itkGetConstMacro( SmoothingSigmasAreSpecifiedInPhysicalUnits, bool );
316  itkBooleanMacro( SmoothingSigmasAreSpecifiedInPhysicalUnits );
318 
323 
325  virtual const DecoratedOutputTransformType * GetOutput() const;
326 
328  itkGetConstMacro( CurrentLevel, SizeValueType );
329 
331  itkGetConstReferenceMacro( CurrentIteration, SizeValueType );
332 
333  /* Get the current metric value. This is a helper function for reporting observations. */
334  itkGetConstReferenceMacro( CurrentMetricValue, RealType );
335 
337  itkGetConstReferenceMacro( CurrentConvergenceValue, RealType );
338 
340  itkGetConstReferenceMacro( IsConverged, bool );
341 
342 #ifdef ITKV3_COMPATIBILITY
343 
358  void StartRegistration(void) { this->Update(); }
359 #endif
360 
361 protected:
363  virtual ~ImageRegistrationMethodv4();
364  virtual void PrintSelf( std::ostream & os, Indent indent ) const;
365 
367  virtual void GenerateData();
368 
370  virtual void InitializeRegistrationAtEachLevel( const SizeValueType );
371 
373  virtual void SetMetricSamplePoints();
374 
381 
386 
390 
394 
395  std::vector<ShrinkFactorsPerDimensionContainerType> m_ShrinkFactorsPerLevel;
398 
401 
403 
405 
407 
408 private:
409  ImageRegistrationMethodv4( const Self & ); //purposely not implemented
410  void operator=( const Self & ); //purposely not implemented
411 };
412 } // end namespace itk
413 
414 #ifndef ITK_MANUAL_INSTANTIATION
415 #include "itkImageRegistrationMethodv4.hxx"
416 #endif
417 
418 #endif
virtual void Update()
InitialTransformType::Pointer InitialTransformPointer
Light weight base class for most itk classes.
OptimizerType::ScalesType OptimizerWeightsType
virtual void SetFixedImage(const FixedImageType *image)
Base helper class intended for multi-resolution image registration.
virtual void InitializeRegistrationAtEachLevel(const SizeValueType)
const TransformParametersAdaptorsContainerType & GetTransformParametersAdaptorsPerLevel() const
virtual void SetMovingImage(const MovingImageType *image)
MetricSamplingPercentageArrayType m_MetricSamplingPercentagePerLevel
ShrinkImageFilter< FixedImageType, VirtualImageType > ShrinkFilterType
std::vector< TransformParametersAdaptorPointer > TransformParametersAdaptorsContainerType
This class takes one ore more ObjectToObject metrics and assigns weights to their derivatives to comp...
void SetMetricSamplingPercentage(const RealType)
OutputTransformType::ScalarType RealType
void SetOptimizerWeights(OptimizerWeightsType &)
ObjectToObjectOptimizerBaseTemplate< RealType > OptimizerType
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
void SetShrinkFactorsPerDimension(unsigned int level, ShrinkFactorsPerDimensionContainerType factors)
Base class for all object-to-object similarlity metrics added in ITKv4.
unsigned long SizeValueType
Definition: itkIntTypes.h:143
DataObjectDecorator< OutputTransformType > DecoratedOutputTransformType
TransformParametersAdaptor< OutputTransformType > TransformParametersAdaptorType
ImageToImageMetricv4< FixedImageType, MovingImageType, VirtualImageType, RealType > ImageMetricType
CompositeTransformType::Pointer CompositeTransformPointer
CompositeTransform< RealType, ImageDimension > CompositeTransformType
void Fill(const ValueType &)
std::vector< FixedImagePointer > FixedImagesContainerType
ImageMetricType::FixedSampledPointSetType MetricSamplePointSetType
std::vector< ShrinkFactorsPerDimensionContainerType > m_ShrinkFactorsPerLevel
virtual const FixedImageType * GetFixedImage() const
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:82
virtual const MovingImageType * GetMovingImage() const
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
MovingImagesContainerType m_MovingSmoothImages
Class to hold and manage different parameter types used during optimization.
ObjectToObjectMetricBaseTemplate< RealType > MetricType
This class contains a list of transforms and concatenates them by composition.
Decorates any subclass of itkObject with a DataObject API.
A superclass of the N-dimensional mesh structure; supports point (geometric coordinate and attribute)...
Definition: itkPointSet.h:84
virtual void SetMetricSamplePoints()
SmoothingSigmasArrayType m_SmoothingSigmasPerLevel
Generic representation for an optimization method.
Definition: itkOptimizer.h:37
virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType)
ShrinkFilterType::ShrinkFactorsType ShrinkFactorsPerDimensionContainerType
void SetTransformParametersAdaptorsPerLevel(TransformParametersAdaptorsContainerType &)
void SetShrinkFactorsPerLevel(ShrinkFactorsArrayType factors)
virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx)
virtual void Modified() const
virtual void PrintSelf(std::ostream &os, Indent indent) const
InitialTransformPointer m_MovingInitialTransform
MetricSamplingStrategyType m_MetricSamplingStrategy
ShrinkFactorsPerDimensionContainerType GetShrinkFactorsPerDimension(const unsigned int level) const
TransformParametersAdaptorsContainerType m_TransformParametersAdaptorsPerLevel
ObjectToObjectMultiMetricv4< ImageDimension, ImageDimension, VirtualImageType, RealType > MultiMetricType
OutputTransformType::Pointer OutputTransformPointer
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Reduce the size of an image by an integer factor in each dimension.
virtual const DecoratedOutputTransformType * GetOutput() const
void operator=(const Self &)
CompositeTransformPointer m_CompositeTransform
Interface method for the current registration framework.
void SetNumberOfLevels(const SizeValueType)
TransformParametersAdaptorType::Pointer TransformParametersAdaptorPointer
std::vector< MovingImagePointer > MovingImagesContainerType
Abstract base for object-to-object optimizers.
SizeValueType Size(void) const
Definition: itkArray.h:115
Transform< RealType, ImageDimension, ImageDimension > InitialTransformType
DerivativeType::ValueType DerivativeValueType
DecoratedOutputTransformType::Pointer DecoratedOutputTransformPointer
OutputTransformType::DerivativeType DerivativeType