freDiscreteGaussianImageFilterController.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: freDiscreteGaussianImageFilterController.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 __freDiscreteGaussianImageFilterController_h
00023 #define __freDiscreteGaussianImageFilterController_h
00024 
00025 #include "freImageToImageFilterControllerBase.h"
00026 
00027 #include "itkDiscreteGaussianImageFilter.h"
00028 
00029 namespace FREE
00030 {
00031 
00041   freControllerIDMacro(DiscreteGaussianImageFilterControllerBase, "DiscreteGaussianImageFilterBase");
00042 template <class TInputImage>
00043 class DiscreteGaussianImageFilterControllerBase : public ImageToImageFilterControllerBase< itk::DiscreteGaussianImageFilter<TInputImage, TInputImage> >
00044 {
00045 public:  
00046   typedef itk::DiscreteGaussianImageFilter<TInputImage, TInputImage> ComponentType;
00047   typedef ImageToImageFilterControllerBase<ComponentType> Superclass;
00048   typedef DiscreteGaussianImageFilterControllerBase<TInputImage> Self;
00049 
00050   typedef typename ComponentType::Pointer ComponentPointer;
00051   typedef typename Superclass::GenericComponentType GenericComponentType;
00052   typedef typename Superclass::GenericComponentPointer GenericComponentPointer;
00053   typedef typename Superclass::GenericMediaPointer GenericMediaPointer;
00054 
00055   itkTypeMacro(DiscreteGaussianImageFilterControllerBase, ImageToImageFilterControllerBase);
00056 
00057   DeclareParameterMacro(UseImageSpacing);
00058   DeclareParameterMacro(FilterDimensionality);
00059   DeclareParameterMacro(MaximumError);
00060   DeclareParameterMacro(MaximumKernelWidth);
00061   DeclareParameterMacro(Variance);
00062 
00063 protected:
00064   DiscreteGaussianImageFilterControllerBase()
00065   {
00066     //Profile settings
00067     this->UpdateControllerID(ControllerID::DiscreteGaussianImageFilterControllerBase);
00068     this->m_Description = "Basis for itk::DiscreteGaussianImageFilter";
00069   };
00070 
00071   virtual void GenerateProfile(CtrlProfile::ControllerProfile& profile,
00072                   const SessionComponentCache* pComponentCache,
00073                   bool bRegardOldSetup) const
00074   {
00075     Superclass::GenerateProfile(profile,pComponentCache,bRegardOldSetup);
00076 
00077     //Parameters
00078     profile.Parameters().AddParameter(cParam_UseImageSpacing,Parameter::PVTBool,cParamDsc_UseImageSpacing,1,"true");
00079     profile.Parameters().AddParameter(cParam_FilterDimensionality,Parameter::PVTInteger,cParamDsc_FilterDimensionality,1,Convert::ToStr(TInputImage::GetImageDimension()));
00080     profile.Parameters().AddParameter(cParam_MaximumError,Parameter::PVTDouble,cParamDsc_MaximumError,TInputImage::GetImageDimension(),"0.01");
00081     profile.Parameters().AddParameter(cParam_MaximumKernelWidth,Parameter::PVTLong,cParamDsc_MaximumKernelWidth,1,"32");
00082     profile.Parameters().AddParameter(cParam_Variance,Parameter::PVTDouble,cParamDsc_Variance,TInputImage::GetImageDimension(),"0.0");
00083   };
00084 
00085         virtual void ActualizeMainComponent(ComponentType* pMainComponent,
00086                                       SessionComponentCache* pComponentCache,
00087                                       SessionInfo* pSessionInfo,
00088                                                                                                                                                         const unsigned int& iActLevel) const
00089   {
00090     Superclass::ActualizeMainComponent(pMainComponent,pComponentCache, pSessionInfo, iActLevel);
00091 
00092     bool bUseSpacing;
00093     long lMaxKernel;
00094     int iDim;
00095 
00096     typename ComponentType::ArrayType vars;
00097     typename ComponentType::ArrayType errors;
00098 
00099     try
00100     {
00101       SessionAccessor::GetParameterValue(pComponentCache,cParam_UseImageSpacing,bUseSpacing);
00102       SessionAccessor::GetParameterValue(pComponentCache,cParam_MaximumKernelWidth,lMaxKernel);
00103       SessionAccessor::GetParameterValue(pComponentCache,cParam_FilterDimensionality,iDim);
00104     }
00105     catchAllNPassMacro("Error while getting parameters.");
00106 
00107     try
00108     {
00109       Parameter::Pointer smpVarParam = SessionAccessor::GetParameter(pComponentCache,cParam_Variance);
00110       if (smpVarParam.IsNull()) throwCtrlExceptionMacro("","Error. Parameter "<<cParam_Variance<<" is missing. Please check your setup.");
00111 
00112       for (unsigned int iIndex = 0; iIndex<TInputImage::GetImageDimension(); iIndex++)
00113       {
00114         double dVar;
00115         smpVarParam->GetParameterValue(dVar,iIndex);
00116         vars[iIndex] = dVar;
00117       }
00118     }
00119     catchAllNPassMacro("Error while gettin variances");
00120 
00121     try
00122     {
00123       Parameter::Pointer smpErrorParam = SessionAccessor::GetParameter(pComponentCache,cParam_MaximumError);
00124       if (smpErrorParam.IsNull()) throwCtrlExceptionMacro("","Error. Parameter "<<cParam_MaximumError<<" is missing. Please check your setup.");
00125 
00126       for (unsigned int iIndex = 0; iIndex<TInputImage::GetImageDimension(); iIndex++)
00127       {
00128         double dError;
00129         smpErrorParam->GetParameterValue(dError,iIndex);
00130         errors[iIndex] = dError;
00131       }
00132     }
00133     catchAllNPassMacro("Error while gettin variances");
00134 
00135     pMainComponent->SetUseImageSpacing(bUseSpacing);
00136     pMainComponent->SetMaximumKernelWidth(lMaxKernel);
00137     pMainComponent->SetFilterDimensionality(iDim);
00138     pMainComponent->SetMaximumError(errors);
00139     pMainComponent->SetVariance(vars);
00140   };
00141 
00142 };
00143 
00144 template <class TInputImage>
00145 const char* const DiscreteGaussianImageFilterControllerBase<TInputImage> :: cParam_UseImageSpacing = "UseImageSpacing";
00146 template <class TInputImage>
00147 const char* const DiscreteGaussianImageFilterControllerBase<TInputImage> :: cParamDsc_UseImageSpacing = "Indicates if variance will be evaluated as pixel units (false) or in real world units (true).";
00148 template <class TInputImage>
00149 const char* const DiscreteGaussianImageFilterControllerBase<TInputImage> :: cParam_FilterDimensionality = "FilterDimensionality";
00150 template <class TInputImage>
00151 const char* const DiscreteGaussianImageFilterControllerBase<TInputImage> :: cParamDsc_FilterDimensionality = "Indicates how many dimensions should be filtered.";
00152 template <class TInputImage>
00153 const char* const DiscreteGaussianImageFilterControllerBase<TInputImage> :: cParam_MaximumError = "MaximumError";
00154 template <class TInputImage>
00155 const char* const DiscreteGaussianImageFilterControllerBase<TInputImage> :: cParamDsc_MaximumError = "Maximum error allowed by the trucation of the kernel. The value can be set for each dimension.";
00156 template <class TInputImage>
00157 const char* const DiscreteGaussianImageFilterControllerBase<TInputImage> :: cParam_MaximumKernelWidth = "MaximumKernelWidth";
00158 template <class TInputImage>
00159 const char* const DiscreteGaussianImageFilterControllerBase<TInputImage> :: cParamDsc_MaximumKernelWidth = "Maximum width the kernel may have, even if its error is greater then the maximum error.";
00160 template <class TInputImage>
00161 const char* const DiscreteGaussianImageFilterControllerBase<TInputImage> :: cParam_Variance = "Variance";
00162 template <class TInputImage>
00163 const char* const DiscreteGaussianImageFilterControllerBase<TInputImage> :: cParamDsc_Variance = "Variance of the filter. The value can be set for each dimension.";
00164 
00170 freControllerIDMacro(DiscreteGaussian2DImageFilterController, "Discrete Gaussian 2D Image Filter");
00171 class DiscreteGaussian2DImageFilterController : public DiscreteGaussianImageFilterControllerBase< ImageTypes<2>::InternalImageType >
00172 {
00173 public:  
00174   typedef DiscreteGaussianImageFilterControllerBase< ImageTypes<2>::InternalImageType > Superclass;
00175   typedef DiscreteGaussian2DImageFilterController Self;
00176 
00177   typedef Superclass::ComponentType ComponentType;
00178   typedef ComponentType::Pointer ComponentPointer;
00179   typedef Superclass::GenericComponentType GenericComponentType;
00180   typedef Superclass::GenericComponentPointer GenericComponentPointer;
00181   typedef Superclass::GenericMediaPointer GenericMediaPointer;
00182 
00183   itkTypeMacro(DiscreteGaussian2DImageFilterController, DiscreteGaussianImageFilterControllerBase);
00184 
00185   DiscreteGaussian2DImageFilterController();
00186 };
00187 
00193 freControllerIDMacro(DiscreteGaussian3DImageFilterController, "Discrete Gaussian 3D Image Filter");
00194 class DiscreteGaussian3DImageFilterController : public DiscreteGaussianImageFilterControllerBase< ImageTypes<3>::InternalImageType >
00195 {
00196 public:  
00197   typedef DiscreteGaussianImageFilterControllerBase< ImageTypes<3>::InternalImageType > Superclass;
00198   typedef DiscreteGaussian3DImageFilterController Self;
00199 
00200   typedef Superclass::ComponentType ComponentType;
00201   typedef ComponentType::Pointer ComponentPointer;
00202   typedef Superclass::GenericComponentType GenericComponentType;
00203   typedef Superclass::GenericComponentPointer GenericComponentPointer;
00204   typedef Superclass::GenericMediaPointer GenericMediaPointer;
00205 
00206   itkTypeMacro(DiscreteGaussian3DImageFilterController, DiscreteGaussianImageFilterControllerBase);
00207 
00208   DiscreteGaussian3DImageFilterController();
00209 };
00210 
00211 } //end of namespace free
00212 
00213 #endif

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