Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef __cmtkImagePairRegistration_h_included_
00034 #define __cmtkImagePairRegistration_h_included_
00035
00036 #include <cmtkconfig.h>
00037
00038 #include <System/cmtkTimers.h>
00039 #include <System/cmtkCommandLine.h>
00040
00041 #include <Base/cmtkMacros.h>
00042 #include <Base/cmtkTypes.h>
00043 #include <Base/cmtkXform.h>
00044 #include <Base/cmtkAffineXform.h>
00045 #include <Base/cmtkFunctional.h>
00046 #include <Base/cmtkUniformVolume.h>
00047 #include <Base/cmtkVector.h>
00048 #include <Base/cmtkInterpolator.h>
00049
00050 #include <Registration/cmtkRegistrationCallback.h>
00051 #include <Registration/cmtkOptimizer.h>
00052
00053 #include <IO/cmtkClassStream.h>
00054
00055 #include <stack>
00056 #include <string.h>
00057
00058 namespace
00059 cmtk
00060 {
00061
00064
00070 class ImagePairRegistration
00071 {
00072 public:
00074 typedef ImagePairRegistration Self;
00075
00077 typedef SmartPointer<Self> SmartPtr;
00078
00079 protected:
00081 int m_Metric;
00082
00088 cmtkGetSetMacro(Interpolators::InterpolationEnum,FloatingImageInterpolation);
00089
00091 cmtkGetSetMacro(int,Algorithm);
00092
00094 unsigned int m_AutoMultiLevels;
00095
00097 double m_MaxStepSize;
00098
00100 double m_MinStepSize;
00101
00107 double m_CoarsestResolution;
00108
00110 bool m_UseOriginalData;
00111
00113 double m_OptimizerStepFactor;
00114
00116 bool m_UseMaxNorm;
00117
00119 Optimizer::ReturnType m_DeltaFThreshold;
00120
00125 Types::Coordinate m_Sampling;
00126
00128 bool m_ForceOutsideFlag;
00129
00131 Types::DataItem m_ForceOutsideValue;
00132
00134 cmtkGetSetMacro(UniformVolume::SmartPtr,Volume_1);
00135
00137 cmtkGetSetMacro(UniformVolume::SmartPtr,Volume_2);
00138
00143 cmtkGetSetMacro(UniformVolume::SmartPtr,ReferenceVolume);
00144
00149 cmtkGetSetMacro(UniformVolume::SmartPtr,FloatingVolume);
00150
00152 virtual void SetForceOutside( const bool flag = true, const Types::DataItem value = 0 )
00153 {
00154 this->m_ForceOutsideFlag = flag;
00155 this->m_ForceOutsideValue = value;
00156 }
00157
00159 class ImagePreprocessor
00160 {
00161 public:
00163 const char* m_DataClassString;
00164
00166 DataClass m_DataClass;
00167
00169 bool m_PaddingFlag;
00170
00172 Types::DataItem m_PaddingValue;
00173
00175 bool m_LowerThresholdActive;
00176
00178 Types::DataItem m_LowerThresholdValue;
00179
00181 bool m_UpperThresholdActive;
00182
00184 Types::DataItem m_UpperThresholdValue;
00185
00187 bool m_UsePruneHistogramBins;
00188
00190 unsigned int m_PruneHistogramBins;
00191
00193 bool m_HistogramEqualization;
00194
00196 int m_MedianFilterRadius;
00197
00199 bool m_SobelFilter;
00200
00202 const char* m_CropIndex;
00203
00205 const char* m_CropWorld;
00206
00208 bool m_AutoCropFlag;
00209
00211 Types::DataItem m_AutoCropLevel;
00212
00214 ImagePreprocessor( const char* name,
00215 const char* key
00216 );
00217
00219 void AttachToCommandLine( CommandLine& cl
00220 );
00221
00223 UniformVolume::SmartPtr GetProcessedImage( const UniformVolume* original );
00224
00226 void WriteSettings( ClassStream& stream ) const;
00227
00228 private:
00230 const char* m_Name;
00231
00233 const char* m_Key;
00234 };
00235
00237 ImagePreprocessor m_PreprocessorRef;
00238
00240 ImagePreprocessor m_PreprocessorFlt;
00241
00243 cmtkGetSetMacro(RegistrationCallback::SmartPtr,Callback);
00244
00246 cmtkGetSetMacro(AffineXform::SmartPtr,InitialTransformation);
00247
00249 cmtkGetSetMacro(bool,InitialXformIsInverse);
00250
00252 Xform::SmartPtr m_Xform;
00253
00255 class LevelParameters
00256 {
00257 public:
00259 typedef LevelParameters Self;
00260
00262 typedef SmartPointer<Self> SmartPtr;
00263
00265 virtual ~LevelParameters() {}
00266 };
00267
00269 std::stack<Self::LevelParameters::SmartPtr> m_ParameterStack;
00270
00272 virtual Functional* MakeFunctional( const int level, const Self::LevelParameters* levelParameters ) = 0;
00273
00275 Optimizer::SmartPtr m_Optimizer;
00276
00286 virtual CallbackResult InitRegistration ();
00287
00294 virtual void OutputResult ( const CoordinateVector* v ) { UNUSED(v); }
00295
00301 virtual void DoneRegistration ( const CoordinateVector* v = NULL);
00302
00312 virtual void EnterResolution( CoordinateVector::SmartPtr& v, Functional::SmartPtr& f, const int idx, const int total );
00313
00323 virtual int DoneResolution( CoordinateVector::SmartPtr&, Functional::SmartPtr&, const int, const int ) { return 1; }
00325
00326 public:
00328 class ConstructorFailed {};
00329
00332 ImagePairRegistration ();
00333
00336 virtual ~ImagePairRegistration () {}
00337
00344 virtual CallbackResult Register ();
00345
00348 double GetTotalElapsedTime() const
00349 {
00350 return cmtk::Timers::GetTimeProcess() - this->m_TimeStartRegistration;
00351 }
00352
00355 double GetLevelElapsedTime() const
00356 {
00357 return cmtk::Timers::GetTimeProcess() - this->m_TimeStartLevel;
00358 }
00359
00362 double GetTotalElapsedWalltime() const
00363 {
00364 return cmtk::Timers::GetWalltime() - this->m_WalltimeStartRegistration;
00365 }
00366
00369 double GetLevelElapsedWalltime() const
00370 {
00371 return cmtk::Timers::GetWalltime() - this->m_WalltimeStartLevel;
00372 }
00373
00376 double GetThreadTotalElapsedTime() const
00377 {
00378 return cmtk::Timers::GetTimeThread() - this->m_ThreadTimeStartRegistration;
00379 }
00380
00383 double GetThreadLevelElapsedTime() const
00384 {
00385 return cmtk::Timers::GetTimeThread() - this->m_ThreadTimeStartLevel;
00386 }
00387
00388 private:
00392 double m_TimeStartRegistration;
00393
00397 double m_TimeStartLevel;
00398
00402 double m_WalltimeStartRegistration;
00403
00407 double m_WalltimeStartLevel;
00408
00412 double m_ThreadTimeStartRegistration;
00413
00417 double m_ThreadTimeStartLevel;
00418 };
00419
00421
00422 }
00423
00424 #endif // #ifndef __cmtkImagePairRegistration_h_included_