![]() |
ITK
4.2.0
Insight Segmentation and Registration Toolkit
|
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 TOutputTransform = 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 TOutputTransform OutputTransformType; 00120 typedef typename OutputTransformType::Pointer OutputTransformPointer; 00121 typedef typename OutputTransformType::ScalarType RealType; 00122 typedef typename OutputTransformType::DerivativeType DerivativeType; 00123 typedef typename DerivativeType::ValueType DerivativeValueType; 00124 00125 typedef Transform<RealType, ImageDimension, ImageDimension> InitialTransformType; 00126 typedef typename InitialTransformType::Pointer InitialTransformPointer; 00127 00128 typedef CompositeTransform<RealType, ImageDimension> CompositeTransformType; 00129 typedef typename CompositeTransformType::Pointer CompositeTransformPointer; 00130 00135 typedef DataObjectDecorator<OutputTransformType> DecoratedOutputTransformType; 00136 typedef typename DecoratedOutputTransformType::Pointer DecoratedOutputTransformPointer; 00137 00139 typedef Array<SizeValueType> ShrinkFactorsArrayType; 00140 typedef Array<RealType> SmoothingSigmasArrayType; 00141 00143 typedef InterpolateImageFunction<FixedImageType, RealType> FixedInterpolatorType; 00144 typedef typename FixedInterpolatorType::Pointer FixedInterpolatorPointer; 00145 typedef InterpolateImageFunction<MovingImageType, RealType> MovingInterpolatorType; 00146 typedef typename MovingInterpolatorType::Pointer MovingInterpolatorPointer; 00147 00149 typedef TransformParametersAdaptor<OutputTransformType> TransformParametersAdaptorType; 00150 typedef typename TransformParametersAdaptorType::Pointer TransformParametersAdaptorPointer; 00151 typedef std::vector<TransformParametersAdaptorPointer> TransformParametersAdaptorsContainerType; 00152 00154 typedef ObjectToObjectOptimizerBase OptimizerType; 00155 typedef typename OptimizerType::Pointer OptimizerPointer; 00156 00158 enum MetricSamplingStrategyType { NONE, REGULAR, RANDOM }; 00159 00160 typedef typename MetricType::FixedSampledPointSetType MetricSamplePointSetType; 00161 00163 itkSetInputMacro( FixedImage, FixedImageType ); 00164 itkGetInputMacro( FixedImage, FixedImageType ); 00166 00168 itkSetInputMacro( MovingImage, MovingImageType ); 00169 itkGetInputMacro( MovingImage, MovingImageType ); 00171 00173 itkSetObjectMacro( FixedInitialTransform, InitialTransformType ); 00174 itkGetConstObjectMacro( FixedInitialTransform, InitialTransformType ); 00176 00178 itkSetObjectMacro( MovingInitialTransform, InitialTransformType ); 00179 itkGetConstObjectMacro( MovingInitialTransform, InitialTransformType ); 00181 00183 itkSetObjectMacro( FixedInterpolator, FixedInterpolatorType ); 00184 itkGetConstObjectMacro( FixedInterpolator, FixedInterpolatorType ); 00186 00188 itkSetObjectMacro( MovingInterpolator, MovingInterpolatorType ); 00189 itkGetConstObjectMacro( MovingInterpolator, MovingInterpolatorType ); 00191 00193 itkSetObjectMacro( Metric, MetricType ); 00194 itkGetObjectMacro( Metric, MetricType ); 00196 00198 itkSetMacro( MetricSamplingStrategy, MetricSamplingStrategyType ); 00199 itkGetConstMacro( MetricSamplingStrategy, MetricSamplingStrategyType ); 00201 00203 itkSetClampMacro( MetricSamplingPercentage, RealType, 0.0, 1.0 ); 00204 itkGetConstMacro( MetricSamplingPercentage, RealType ); 00206 00208 itkSetObjectMacro( Optimizer, OptimizerType ); 00209 itkGetObjectMacro( Optimizer, OptimizerType ); 00211 00213 void SetTransformParametersAdaptorsPerLevel( TransformParametersAdaptorsContainerType & ); 00214 const TransformParametersAdaptorsContainerType & GetTransformParametersAdaptorsPerLevel() const; 00216 00224 void SetNumberOfLevels( const SizeValueType ); 00225 itkGetConstMacro( NumberOfLevels, SizeValueType ); 00227 00233 itkSetMacro( ShrinkFactorsPerLevel, ShrinkFactorsArrayType ); 00234 itkGetConstMacro( ShrinkFactorsPerLevel, ShrinkFactorsArrayType ); 00236 00242 itkSetMacro( SmoothingSigmasPerLevel, SmoothingSigmasArrayType ); 00243 itkGetConstMacro( SmoothingSigmasPerLevel, SmoothingSigmasArrayType ); 00245 00247 void StartRegistration() { this->GenerateData(); } 00248 00250 typedef ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType; 00251 using Superclass::MakeOutput; 00252 virtual DataObjectPointer MakeOutput( DataObjectPointerArraySizeType ); 00253 00255 virtual const DecoratedOutputTransformType * GetOutput() const; 00256 00258 itkGetConstMacro( CurrentLevel, SizeValueType ); 00259 00261 itkGetConstReferenceMacro( CurrentIteration, SizeValueType ); 00262 00263 /* Get the current metric value. This is a helper function for reporting observations. */ 00264 itkGetConstReferenceMacro( CurrentMetricValue, RealType ); 00265 00267 itkGetConstReferenceMacro( CurrentConvergenceValue, RealType ); 00268 00270 itkGetConstReferenceMacro( IsConverged, bool ); 00271 00272 protected: 00273 ImageRegistrationMethodv4(); 00274 virtual ~ImageRegistrationMethodv4(); 00275 virtual void PrintSelf( std::ostream & os, Indent indent ) const; 00276 00278 virtual void GenerateData(); 00279 00281 virtual void InitializeRegistrationAtEachLevel( const SizeValueType ); 00282 00284 virtual void SetMetricSamplePoints(); 00285 00286 SizeValueType m_CurrentLevel; 00287 SizeValueType m_NumberOfLevels; 00288 SizeValueType m_CurrentIteration; 00289 RealType m_CurrentMetricValue; 00290 RealType m_CurrentConvergenceValue; 00291 bool m_IsConverged; 00292 00293 MovingImagePointer m_MovingSmoothImage; 00294 FixedImagePointer m_FixedSmoothImage; 00295 00296 InitialTransformPointer m_MovingInitialTransform; 00297 InitialTransformPointer m_FixedInitialTransform; 00298 00299 FixedInterpolatorPointer m_FixedInterpolator; 00300 MovingInterpolatorPointer m_MovingInterpolator; 00301 00302 OptimizerPointer m_Optimizer; 00303 00304 MetricPointer m_Metric; 00305 MetricSamplingStrategyType m_MetricSamplingStrategy; 00306 RealType m_MetricSamplingPercentage; 00307 00308 ShrinkFactorsArrayType m_ShrinkFactorsPerLevel; 00309 SmoothingSigmasArrayType m_SmoothingSigmasPerLevel; 00310 00311 TransformParametersAdaptorsContainerType m_TransformParametersAdaptorsPerLevel; 00312 00313 CompositeTransformPointer m_CompositeTransform; 00314 00315 OutputTransformPointer m_OutputTransform; 00316 00317 private: 00318 ImageRegistrationMethodv4( const Self & ); //purposely not implemented 00319 void operator=( const Self & ); //purposely not implemented 00320 }; 00321 } // end namespace itk 00322 00323 #ifndef ITK_MANUAL_INSTANTIATION 00324 #include "itkImageRegistrationMethodv4.hxx" 00325 #endif 00326 00327 #endif 00328
1.7.6.1