/vol/vipdata/irtk/packages/registration/include/irtkDemonsRegistration.h

00001 /*=========================================================================
00002 
00003   Library   : Image Registration Toolkit (IRTK)
00004   Module    : $Id: irtkDemonsRegistration.h 8 2009-03-02 16:12:58Z dr $
00005   Copyright : Imperial College, Department of Computing
00006               Visual Information Processing (VIP), 2008 onwards
00007   Date      : $Date: 2009-03-02 16:12:58 +0000 (Mon, 02 Mar 2009) $
00008   Version   : $Revision: 8 $
00009   Changes   : $Author: dr $
00010 
00011 =========================================================================*/
00012 
00013 #ifndef _IRTKDEMONSREGISTRATION_H
00014 
00015 #define _IRTKDEMONSREGISTRATION_H
00016 
00017 #include <irtkImage.h>
00018 
00019 #include <irtkResampling.h>
00020 
00021 #include <irtkImageFunction.h>
00022 
00023 #include <irtkTransformation.h>
00024 
00037 class irtkDemonsRegistration
00038 {
00039 
00041   friend istream& operator>> (istream&, irtkDemonsRegistration*);
00042 
00044   friend ostream& operator<< (ostream&, const irtkDemonsRegistration*);
00045 
00046 protected:
00047 
00051   irtkGreyImage *_target;
00052 
00057   irtkGreyImage *_source;
00058 
00061   irtkGreyImage _tmp;
00062 
00065   irtkGreyImage _targetGradientX, _targetGradientY, _targetGradientZ;
00066 
00069   irtkRealImage _localDX, _localDY, _localDZ;
00070 
00073   irtkRealImage _globalDX, _globalDY, _globalDZ;
00074 
00076   irtkMultiLevelFreeFormTransformation *_transformation;
00077 
00079   irtkLinearFreeFormTransformation *_ffd;
00080 
00082   irtkInterpolateImageFunction *_interpolator;
00083 
00085   double _TargetBlurring;
00086 
00088   double _TargetResolution;
00089 
00091   short  _TargetPadding;
00092 
00094   double _SourceBlurring;
00095 
00097   double _SourceResolution;
00098 
00100   short  _SourcePadding;
00101 
00103   int    _NumberOfLevels;
00104 
00106   int    _NumberOfIterations;
00107 
00109   double _ReductionFactor;
00110 
00112   double _Smoothing;
00113 
00115   irtkInterpolationMode _InterpolationMode;
00116 
00118   double _source_x1, _source_y1, _source_z1;
00119   double _source_x2, _source_y2, _source_z2;
00120 
00122   virtual void Initialize();
00123 
00125   virtual void Initialize(int);
00126 
00128   virtual void Finalize();
00129 
00131   virtual void Finalize(int);
00132 
00133 public:
00134 
00136   irtkDemonsRegistration();
00137 
00139   virtual ~irtkDemonsRegistration();
00140 
00142   virtual void SetInput (irtkGreyImage *, irtkGreyImage *);
00143 
00145   virtual void SetOutput(irtkMultiLevelFreeFormTransformation *);
00146 
00148   virtual void Run();
00149 
00151   virtual void Run(irtkGreyImage, irtkGreyImage, int);
00152 
00154   virtual void SetParameter(const irtkDemonsRegistration *r);
00155 
00157   virtual void Read (char *);
00158 
00160   virtual void Write(char *);
00161 
00162   // Access parameters
00163   virtual SetMacro(TargetBlurring,     double);
00164   virtual GetMacro(TargetBlurring,     double);
00165   virtual SetMacro(TargetResolution,   double);
00166   virtual GetMacro(TargetResolution,   double);
00167   virtual SetMacro(TargetPadding,      short);
00168   virtual GetMacro(TargetPadding,      short);
00169   virtual SetMacro(SourceBlurring,     double);
00170   virtual GetMacro(SourceBlurring,     double);
00171   virtual SetMacro(SourceResolution,   double);
00172   virtual GetMacro(SourceResolution,   double);
00173   virtual SetMacro(SourcePadding,      short);
00174   virtual GetMacro(SourcePadding,      short);
00175   virtual SetMacro(NumberOfLevels,     int);
00176   virtual GetMacro(NumberOfLevels,     int);
00177   virtual SetMacro(NumberOfIterations, int);
00178   virtual GetMacro(NumberOfIterations, int);
00179   virtual SetMacro(ReductionFactor,    double);
00180   virtual GetMacro(ReductionFactor,    double);
00181   virtual SetMacro(Smoothing,          double);
00182   virtual GetMacro(Smoothing,          double);
00183   virtual SetMacro(InterpolationMode,  irtkInterpolationMode);
00184   virtual GetMacro(InterpolationMode,  irtkInterpolationMode);
00185 
00186 };
00187 
00188 inline void irtkDemonsRegistration::SetInput(irtkGreyImage *target, irtkGreyImage *source)
00189 {
00190   _target = target;
00191   _source = source;
00192 }
00193 
00194 inline void irtkDemonsRegistration::SetOutput(irtkMultiLevelFreeFormTransformation *transformation)
00195 {
00196   _transformation = transformation;
00197 }
00198 
00199 // Function to read in a line from an istream, to be used by derived classes
00200 extern int read_line(istream &, char *, char *&);
00201 
00202 #endif