freScaleTransformController.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   F.R.E.E. - flexible registration evaluation engine
00004   Version:   v.1.0.0
00005   Date:      $Date: 2006/09/01 12:00:00 $
00006   Module:    $RCSfile: freScaleTransformController.h,v $
00007   Language:  C++
00008 
00009 
00010 
00011   Copyright (c) 2007 Ralf o Floca (Department of Medical Informatics,
00012   Institute for Medical Biometry and Informatics, University of Heidelberg,
00013   Germany). All rights reserved.
00014   See FREECopyright.txt or http://www.mi.med.uni-hd.de/free/copyright.htm
00015   for details.
00016 
00017      This software is distributed WITHOUT ANY WARRANTY; without even 
00018      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00019      PURPOSE.  See the above copyright notices for more information.
00020 
00021 =========================================================================*/
00022 #ifndef __freScaleTransformController_h
00023 #define __freScaleTransformController_h
00024 
00025 #include "freITKTransformControllerBase.h"
00026 #include "freTransformInitializer.h"
00027 #include "freTransformSetupAdaptor.h"
00028 
00029 #include "itkScaleTransform.h"
00030 
00031 namespace FREE
00032 {
00033 
00043   freControllerIDMacro(ScaleTransformControllerBase, "ScaleTransformBase");
00044 template <int iDimension>
00045 class ScaleTransformControllerBase : public ITKTransformControllerBase< itk::ScaleTransform < ScalarType, iDimension >, iDimension >
00046 {
00047 public:  
00048   typedef itk::ScaleTransform < ScalarType, iDimension > ComponentType;
00049   typedef ITKTransformControllerBase<ComponentType, iDimension> Superclass;
00050 
00051   itkTypeMacro(ScaleTransformControllerBase, ITKTransformControllerBase);
00052 
00053 protected:
00056   ScaleTransformControllerBase()
00057   {
00058     //Profile settings
00059     this->UpdateControllerID(ControllerID::ScaleTransformControllerBase);
00060     this->m_Description = "A rigid scale transform.";
00061   };
00062 
00063   virtual void GenerateProfile(CtrlProfile::ControllerProfile& profile,
00064                                const SessionComponentCache* pComponentCache,
00065                                bool bRegardOldSetup) const
00066   {
00067     Superclass::GenerateProfile(profile,pComponentCache,bRegardOldSetup);
00068 
00069         //Parameters
00070     profile.Parameters().AddParameter(cParam_InitialisationMethod,Parameter::PVTInteger,std::string(cParamDsc_InitialisationMethod)+"\n1: scales are set by itv",1,"0");
00071   };
00072 
00073   virtual bool SetInitialTransformValues( ComponentType* pTransformComponent,
00074                                           SessionComponentCache* pComponentCache,
00075                                           SessionInfo* pSessionInfo,
00076                                                                                                                                                             const int& iInitializeByITV) const
00077   {
00078     if (!iInitializeByITV)
00079     {
00080       ComponentSetup* pTransformSetup = pComponentCache->Setup();
00081       TransformSetupAdaptor adaptor(pTransformSetup);
00082       ReferencePointsAccessor<iDimension> pointsAccessor(pComponentCache);
00083 
00084       if (!pointsAccessor.MovingPointsExist()) throwCtrlExceptionMacro("","Cannot estimate scaling via reference points. No moving reference point set defined. Please check media linkage.");
00085       if (!pointsAccessor.FixedPointsExist()) throwCtrlExceptionMacro("","Cannot estimate scaling via via reference points. No fixed reference point set defined. Please check media linkage.");
00086 
00087       ParameterArrayType scaling(iDimension);
00088 
00089       scaling.fill(0);
00090       for (int iIndex = 0; iIndex<pointsAccessor.GetFixedPointsCount(); iIndex++)
00091       {
00092         ParameterArrayType movingRef = pointsAccessor.GetMovingPointArray(iIndex);
00093         ParameterArrayType fixedRef = pointsAccessor.GetFixedPointArray(iIndex);
00094 
00095         for (int iIndex=0; iIndex<iDimension; iIndex++)
00096         {
00097           scaling[iIndex] += movingRef[iIndex]/fixedRef[iIndex];
00098         };
00099       };
00100 
00101       int iCoupleCount = pointsAccessor.GetFixedPointsCount();
00102       if (iCoupleCount<1) iCoupleCount = 1;
00103 
00104       for (int iIndex=0; iIndex<iDimension; iIndex++)
00105       {
00106         scaling[iIndex] = scaling[iIndex]/iCoupleCount;
00107         pTransformSetup->Parameters().SetParameterValue(cParam_CurrentTransformValues,scaling[iIndex],iIndex);
00108       }
00109     };
00110     return true;
00111   };
00112 };
00113 
00123   freControllerIDMacro(Scale2DTransformController, "Scale 2D Transform");
00124 class Scale2DTransformController : public ScaleTransformControllerBase<2>
00125 {
00126 public:  
00127   itkTypeMacro(Scale2DTransformController, ScaleTransformControllerBase);
00128 
00129   Scale2DTransformController();
00130 
00131 protected:
00132   virtual void GenerateProfile(CtrlProfile::ControllerProfile& profile,
00133                                const SessionComponentCache* pComponentCache,
00134                                bool bRegardOldSetup) const;
00135 };
00136 
00146   freControllerIDMacro(Scale3DTransformController, "Scale 3D Transform");
00147 class Scale3DTransformController : public ScaleTransformControllerBase<3>
00148 {
00149 public:  
00150   itkTypeMacro(Scale3DTransformController, ScaleTransformControllerBase);
00151 
00152   Scale3DTransformController();
00153 
00154 protected:
00155   virtual void GenerateProfile(CtrlProfile::ControllerProfile& profile,
00156                                const SessionComponentCache* pComponentCache,
00157                                bool bRegardOldSetup) const;
00158 };
00159 
00160 } //end of namespace free
00161 
00162 #endif

Generated at Sat Oct 13 17:27:13 2007 for f.r.e.e. - Flexible Registration and Evaluation Engine by doxygen 1.5.3 written by Dimitri van Heesch, © 1997-2000