freSpatialRegionOfInterestImageFilterController.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: freSpatialRegionOfInterestImageFilterController.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 __freSpatialRegionOfInterestImageFilterController_h
00023 #define __freSpatialRegionOfInterestImageFilterController_h
00024 
00025 #include "freImageToImageFilterControllerBase.h"
00026 
00027 #include "freSpatialRegionOfInterestImageFilter.h"
00028 #include "itkEllipseSpatialObject.h"
00029 
00030 namespace FREE
00031 {
00032 /*TODO add real spatial object support when got some time. right now it is alwas an ellipse*/
00033 
00043   freControllerIDMacro(SpatialRegionOfInterestImageFilterControllerBase, "SpatialRegionOfInterestImageFilterBase");
00044 template <class TInputImage>
00045 class SpatialRegionOfInterestImageFilterControllerBase : public ImageToImageFilterControllerBase< FREE::SpatialRegionOfInterestImageFilter<TInputImage, TInputImage> >
00046 {
00047 public:  
00048   typedef FREE::SpatialRegionOfInterestImageFilter<TInputImage, TInputImage> ComponentType;
00049   typedef ImageToImageFilterControllerBase<ComponentType> Superclass;
00050   typedef SpatialRegionOfInterestImageFilterControllerBase<TInputImage> Self;
00051 
00052   typedef typename ComponentType::Pointer ComponentPointer;
00053   typedef typename Superclass::GenericComponentType GenericComponentType;
00054   typedef typename Superclass::GenericComponentPointer GenericComponentPointer;
00055   typedef typename Superclass::GenericMediaPointer GenericMediaPointer;
00056   typedef TInputImage InputImage;
00057 
00058   DeclareParameterMacro(OutsideValue);
00059   DeclareParameterMacro(SpatialObject);
00060   DeclareParameterMacro(Origin);
00061 
00062   itkTypeMacro(SpatialRegionOfInterestImageFilterControllerBase, ImageToImageFilterControllerBase);
00063 
00064 protected:
00065   SpatialRegionOfInterestImageFilterControllerBase()
00066   {
00067     //Profile settings
00068     this->UpdateControllerID(ControllerID::SpatialRegionOfInterestImageFilterControllerBase);
00069     this->m_Description = "Basis for FREE::SpatialRegionOfInterestImageFilter";
00070   };
00071 
00072   virtual void GenerateProfile(CtrlProfile::ControllerProfile& profile,
00073                   const SessionComponentCache* pComponentCache,
00074                   bool bRegardOldSetup) const
00075   {
00076     Superclass::GenerateProfile(profile,pComponentCache,bRegardOldSetup);
00077 
00078     //Parameters
00079     profile.Parameters().AddParameter(cParam_OutsideValue,Parameter::PVTDouble,cParamDsc_OutsideValue,1,"0.0");
00080     profile.Parameters().AddParameter(cParam_SpatialObject,Parameter::PVTDouble,cParamDsc_SpatialObject,1,"30.0");
00081     profile.Parameters().AddParameter(cParam_Origin,Parameter::PVTDouble,cParamDsc_Origin,InputImage::ImageDimension,"0.0");
00082   };
00083 
00084         virtual void ActualizeMainComponent(ComponentType* pMainComponent,
00085                                       SessionComponentCache* pComponentCache,
00086                                       SessionInfo* pSessionInfo,
00087                                                                                                                                                         const unsigned int& iActLevel) const
00088   {
00089     Superclass::ActualizeMainComponent(pMainComponent,pComponentCache, pSessionInfo, iActLevel);
00090 
00091     typedef itk::EllipseSpatialObject<InputImage::ImageDimension> SpatialObjectType;
00092     
00093           double dOutsideValue;
00094           double dSpatialObject;
00095           double dOrigin;
00096     
00097     typename ComponentType::SpatialObjectType::TransformType::OffsetType offset;
00098 
00099     try
00100     {
00101       SessionAccessor::GetParameterValue(pComponentCache,cParam_OutsideValue,dOutsideValue);
00102       SessionAccessor::GetParameterValue(pComponentCache,cParam_SpatialObject,dSpatialObject);
00103       for (unsigned int iIndex = 0; iIndex<InputImage::ImageDimension; iIndex++)
00104       {
00105         SessionAccessor::GetParameterValue(pComponentCache,cParam_Origin,dOrigin,iIndex);
00106         offset[iIndex] = dOrigin;
00107       }
00108     }
00109     catchAllNPassMacro("Error while retrieving parameter values.");
00110 
00111           pMainComponent->SetOutsideValue(dOutsideValue);
00112     
00113     typename SpatialObjectType::Pointer object = SpatialObjectType::New();
00114     object->SetRadius(dSpatialObject);
00115     object->GetObjectToParentTransform()->SetOffset(offset);
00116     object->ComputeObjectToWorldTransform();
00117     pMainComponent->SetSpatialRegionOfInterest(object);
00118   };
00119 
00120 };
00121 
00122 template <class TInputImage>
00123 const char* const SpatialRegionOfInterestImageFilterControllerBase<TInputImage> :: cParam_OutsideValue = "OutsideValue";
00124 template <class TInputImage>
00125 const char* const SpatialRegionOfInterestImageFilterControllerBase<TInputImage> :: cParamDsc_OutsideValue = "Value for all pixels that are within the bounding box of the spatial object, but outside the object itself";
00126 template <class TInputImage>
00127 const char* const SpatialRegionOfInterestImageFilterControllerBase<TInputImage> :: cParam_SpatialObject = "SpatialObject";
00128 template <class TInputImage>
00129 const char* const SpatialRegionOfInterestImageFilterControllerBase<TInputImage> :: cParamDsc_SpatialObject = "";
00130 template <class TInputImage>
00131 const char* const SpatialRegionOfInterestImageFilterControllerBase<TInputImage> :: cParam_Origin = "Origin";
00132 template <class TInputImage>
00133 const char* const SpatialRegionOfInterestImageFilterControllerBase<TInputImage> :: cParamDsc_Origin = "";
00134 
00140 freControllerIDMacro(SpatialRegionOfInterest2DImageFilterController, "Spatial ROI 2D Image Filter");
00141 class SpatialRegionOfInterest2DImageFilterController : public SpatialRegionOfInterestImageFilterControllerBase< ImageTypes<2>::InternalImageType >
00142 {
00143 public:  
00144   typedef SpatialRegionOfInterestImageFilterControllerBase< ImageTypes<2>::InternalImageType > Superclass;
00145   typedef SpatialRegionOfInterest2DImageFilterController Self;
00146 
00147   typedef Superclass::ComponentType ComponentType;
00148   typedef ComponentType::Pointer ComponentPointer;
00149   typedef Superclass::GenericComponentType GenericComponentType;
00150   typedef Superclass::GenericComponentPointer GenericComponentPointer;
00151   typedef Superclass::GenericMediaPointer GenericMediaPointer;
00152 
00153   itkTypeMacro(SpatialRegionOfInterest2DImageFilterController, SpatialRegionOfInterestImageFilterControllerBase);
00154 
00155   SpatialRegionOfInterest2DImageFilterController();
00156 };
00157 
00163 freControllerIDMacro(SpatialRegionOfInterest3DImageFilterController, "Spatial ROI 3D Image Filter");
00164 class SpatialRegionOfInterest3DImageFilterController : public SpatialRegionOfInterestImageFilterControllerBase< ImageTypes<3>::InternalImageType >
00165 {
00166 public:  
00167   typedef SpatialRegionOfInterestImageFilterControllerBase< ImageTypes<3>::InternalImageType > Superclass;
00168   typedef SpatialRegionOfInterest3DImageFilterController Self;
00169 
00170   typedef Superclass::ComponentType ComponentType;
00171   typedef ComponentType::Pointer ComponentPointer;
00172   typedef Superclass::GenericComponentType GenericComponentType;
00173   typedef Superclass::GenericComponentPointer GenericComponentPointer;
00174   typedef Superclass::GenericMediaPointer GenericMediaPointer;
00175 
00176   itkTypeMacro(SpatialRegionOfInterest3DImageFilterController, SpatialRegionOfInterestImageFilterControllerBase);
00177 
00178   SpatialRegionOfInterest3DImageFilterController();
00179 };
00180 
00181 } //end of namespace free
00182 
00183 #endif

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