ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkImageRegistrationMethodv4.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkImageRegistrationMethodv4_h
00019 #define __itkImageRegistrationMethodv4_h
00020 
00021 #include "itkProcessObject.h"
00022 
00023 #include "itkAffineTransform.h"
00024 #include "itkCompositeTransform.h"
00025 #include "itkDataObjectDecorator.h"
00026 #include "itkObjectToObjectOptimizerBase.h"
00027 #include "itkImageToImageMetricv4.h"
00028 #include "itkInterpolateImageFunction.h"
00029 #include "itkTransform.h"
00030 #include "itkTransformParametersAdaptor.h"
00031 
00032 #include <vector>
00033 
00034 namespace itk
00035 {
00036 
00088 template<typename TFixedImage, typename TMovingImage, typename TTransform =
00089   AffineTransform<double, GetImageDimension<TFixedImage>::ImageDimension> >
00090 class ITK_EXPORT ImageRegistrationMethodv4
00091 :public ProcessObject
00092 {
00093 public:
00095   typedef ImageRegistrationMethodv4                 Self;
00096   typedef ProcessObject                             Superclass;
00097   typedef SmartPointer<Self>                        Pointer;
00098   typedef SmartPointer<const Self>                  ConstPointer;
00099 
00101   itkNewMacro( Self );
00102 
00104   itkStaticConstMacro( ImageDimension, unsigned int, TFixedImage::ImageDimension );
00105 
00107   itkTypeMacro( ImageRegistrationMethodv4, ProcessObject );
00108 
00110   typedef TFixedImage                                                 FixedImageType;
00111   typedef typename FixedImageType::Pointer                            FixedImagePointer;
00112   typedef TMovingImage                                                MovingImageType;
00113   typedef typename MovingImageType::Pointer                           MovingImagePointer;
00114 
00116   typedef ImageToImageMetricv4<FixedImageType, MovingImageType>       MetricType;
00117   typedef typename MetricType::Pointer                                MetricPointer;
00118 
00119   typedef TTransform                                                  TransformType;
00120   typedef typename TransformType::Pointer                             TransformPointer;
00121   typedef typename TransformType::ScalarType                          RealType;
00122   typedef typename TransformType::DerivativeType                      DerivativeType;
00123   typedef typename DerivativeType::ValueType                          DerivativeValueType;
00124 
00125   typedef CompositeTransform<RealType, ImageDimension>                CompositeTransformType;
00126   typedef typename CompositeTransformType::Pointer                    CompositeTransformPointer;
00127 
00132   typedef DataObjectDecorator<TransformType>                          TransformOutputType;
00133   typedef typename TransformOutputType::Pointer                       TransformOutputPointer;
00134 
00136   typedef Array<SizeValueType>                                        ShrinkFactorsArrayType;
00137   typedef Array<RealType>                                             SmoothingSigmasArrayType;
00138 
00140   typedef InterpolateImageFunction<FixedImageType, RealType>          FixedInterpolatorType;
00141   typedef typename FixedInterpolatorType::Pointer                     FixedInterpolatorPointer;
00142   typedef InterpolateImageFunction<MovingImageType, RealType>         MovingInterpolatorType;
00143   typedef typename MovingInterpolatorType::Pointer                    MovingInterpolatorPointer;
00144 
00146   typedef TransformParametersAdaptor<TransformType>                   TransformParametersAdaptorType;
00147   typedef typename TransformParametersAdaptorType::Pointer            TransformParametersAdaptorPointer;
00148   typedef std::vector<TransformParametersAdaptorPointer>              TransformParametersAdaptorsContainerType;
00149 
00151   typedef ObjectToObjectOptimizerBase                                 OptimizerType;
00152   typedef typename OptimizerType::Pointer                             OptimizerPointer;
00153 
00155   enum MetricSamplingStrategyType { NONE, REGULAR, RANDOM };
00156 
00157   typedef typename MetricType::FixedSampledPointSetType               MetricSamplePointSetType;
00158 
00159 
00161   itkSetInputMacro( FixedImage, FixedImageType );
00162   itkGetInputMacro( FixedImage, FixedImageType );
00164 
00166   itkSetInputMacro( MovingImage, MovingImageType );
00167   itkGetInputMacro( MovingImage, MovingImageType );
00169 
00171   itkSetObjectMacro( FixedInterpolator, FixedInterpolatorType );
00172   itkGetConstObjectMacro( FixedInterpolator, FixedInterpolatorType );
00174 
00176   itkSetObjectMacro( MovingInterpolator, MovingInterpolatorType );
00177   itkGetConstObjectMacro( MovingInterpolator, MovingInterpolatorType );
00179 
00181   itkSetObjectMacro( Metric, MetricType );
00182   itkGetObjectMacro( Metric, MetricType );
00184 
00186   itkSetMacro( MetricSamplingStrategy, MetricSamplingStrategyType );
00187   itkGetConstMacro( MetricSamplingStrategy, MetricSamplingStrategyType );
00189 
00191   itkSetClampMacro( MetricSamplingPercentage, RealType, 0.0, 1.0 );
00192   itkGetConstMacro( MetricSamplingPercentage, RealType );
00194 
00196   itkSetObjectMacro( Transform, TransformType );
00197   itkGetObjectMacro( Transform, TransformType );
00199 
00201   itkSetObjectMacro( Optimizer, OptimizerType );
00202   itkGetObjectMacro( Optimizer, OptimizerType );
00204 
00206   itkSetObjectMacro( CompositeTransform, CompositeTransformType );
00207   itkGetObjectMacro( CompositeTransform, CompositeTransformType );
00209 
00211   void SetTransformParametersAdaptorsPerLevel( TransformParametersAdaptorsContainerType & );
00212   const TransformParametersAdaptorsContainerType & GetTransformParametersAdaptorsPerLevel() const;
00214 
00222   void SetNumberOfLevels( const SizeValueType );
00223   itkGetConstMacro( NumberOfLevels, SizeValueType );
00225 
00231   itkSetMacro( ShrinkFactorsPerLevel, ShrinkFactorsArrayType );
00232   itkGetConstMacro( ShrinkFactorsPerLevel, ShrinkFactorsArrayType );
00234 
00240   itkSetMacro( SmoothingSigmasPerLevel, SmoothingSigmasArrayType );
00241   itkGetConstMacro( SmoothingSigmasPerLevel, SmoothingSigmasArrayType );
00243 
00245   void StartRegistration() { this->GenerateData(); }
00246 
00248   typedef ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
00249   using Superclass::MakeOutput;
00250   virtual DataObjectPointer MakeOutput( DataObjectPointerArraySizeType );
00251 
00253   virtual const TransformOutputType * GetOutput() const;
00254 
00256   itkGetConstMacro( CurrentLevel, SizeValueType );
00257 
00258 protected:
00259   ImageRegistrationMethodv4();
00260   virtual ~ImageRegistrationMethodv4();
00261   virtual void PrintSelf( std::ostream & os, Indent indent ) const;
00262 
00264   virtual void  GenerateData();
00265 
00267   virtual void InitializeRegistrationAtEachLevel( const SizeValueType );
00268 
00270   virtual void SetMetricSamplePoints();
00271 
00272   SizeValueType                                                   m_CurrentLevel;
00273   SizeValueType                                                   m_NumberOfLevels;
00274 
00275   MovingImagePointer                                              m_MovingSmoothImage;
00276   FixedImagePointer                                               m_FixedSmoothImage;
00277 
00278   FixedInterpolatorPointer                                        m_FixedInterpolator;
00279   MovingInterpolatorPointer                                       m_MovingInterpolator;
00280 
00281   OptimizerPointer                                                m_Optimizer;
00282 
00283   MetricPointer                                                   m_Metric;
00284   MetricSamplingStrategyType                                      m_MetricSamplingStrategy;
00285   RealType                                                        m_MetricSamplingPercentage;
00286 
00287   ShrinkFactorsArrayType                                          m_ShrinkFactorsPerLevel;
00288   SmoothingSigmasArrayType                                        m_SmoothingSigmasPerLevel;
00289 
00290   TransformParametersAdaptorsContainerType                        m_TransformParametersAdaptorsPerLevel;
00291 
00292   CompositeTransformPointer                                       m_CompositeTransform;
00293 
00294   TransformPointer                                                m_Transform;
00295 
00296 private:
00297   ImageRegistrationMethodv4( const Self & );   //purposely not implemented
00298   void operator=( const Self & );                  //purposely not implemented
00299 };
00300 } // end namespace itk
00301 
00302 #ifndef ITK_MANUAL_INSTANTIATION
00303 #include "itkImageRegistrationMethodv4.hxx"
00304 #endif
00305 
00306 #endif
00307