00001 /* 00002 // 00003 // Copyright 1997-2009 Torsten Rohlfing 00004 // 00005 // Copyright 2004-2011 SRI International 00006 // 00007 // This file is part of the Computational Morphometry Toolkit. 00008 // 00009 // http://www.nitrc.org/projects/cmtk/ 00010 // 00011 // The Computational Morphometry Toolkit is free software: you can 00012 // redistribute it and/or modify it under the terms of the GNU General Public 00013 // License as published by the Free Software Foundation, either version 3 of 00014 // the License, or (at your option) any later version. 00015 // 00016 // The Computational Morphometry Toolkit is distributed in the hope that it 00017 // will be useful, but WITHOUT ANY WARRANTY; without even the implied 00018 // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 // GNU General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU General Public License along 00022 // with the Computational Morphometry Toolkit. If not, see 00023 // <http://www.gnu.org/licenses/>. 00024 // 00025 // $Revision: 2752 $ 00026 // 00027 // $LastChangedDate: 2011-01-17 11:33:31 -0800 (Mon, 17 Jan 2011) $ 00028 // 00029 // $LastChangedBy: torstenrohlfing $ 00030 // 00031 */ 00032 00033 #ifndef __cmtkImagePairRegistrationFunctional_h_included_ 00034 #define __cmtkImagePairRegistrationFunctional_h_included_ 00035 00036 #include <cmtkconfig.h> 00037 00038 #include <Base/cmtkMathUtil.h> 00039 #include <Base/cmtkTypes.h> 00040 #include <Base/cmtkFunctional.h> 00041 #include <Base/cmtkVector.h> 00042 #include <Base/cmtkVolume.h> 00043 #include <Base/cmtkUniformVolume.h> 00044 #include <Base/cmtkMatchedLandmarkList.h> 00045 00046 #include <System/cmtkException.h> 00047 #include <System/cmtkLockingPtr.h> 00048 00049 #include <Registration/cmtkImagePairSimilarityMeasure.h> 00050 00051 #include <cassert> 00052 00053 namespace 00054 cmtk 00055 { 00056 00059 00066 class ImagePairRegistrationFunctional : 00068 public Functional 00069 { 00070 public: 00072 typedef ImagePairRegistrationFunctional Self; 00073 00075 typedef Functional Superclass; 00076 00077 protected: 00079 UniformVolume::SmartConstPtr m_ReferenceGrid; 00080 00082 UniformVolume::SmartConstPtr m_FloatingGrid; 00083 00085 DataClass m_ReferenceDataClass; 00086 00088 DataClass m_FloatingDataClass; 00089 00091 DataGrid::RegionType m_ReferenceCropRegion; 00092 00094 cmtkGetSetMacro(MatchedLandmarkList::SmartPtr,MatchedLandmarkList); 00095 00097 cmtkGetSetMacro(Self::ReturnType,LandmarkErrorWeight); 00098 00099 public: 00106 ImagePairRegistrationFunctional( UniformVolume::SmartConstPtr& reference, UniformVolume::SmartConstPtr& floating ) 00107 : m_MatchedLandmarkList( NULL ), 00108 m_ForceOutsideFlag( false ) 00109 { 00110 this->InitFloating( floating ); 00111 this->InitReference( reference ); 00112 this->m_LandmarkErrorWeight = 0; 00113 } 00114 00117 virtual ~ImagePairRegistrationFunctional() {} 00118 00121 virtual void SetForceOutside 00122 ( const bool flag = true, const Types::DataItem value = 0 ) 00123 { 00124 this->m_ForceOutsideFlag = flag; 00125 this->m_ForceOutsideValueRescaled = this->m_Metric->GetFloatingValueScaled( value ); 00126 } 00127 00128 protected: 00130 ImagePairSimilarityMeasure::SmartPtr m_Metric; 00131 00133 DataGrid::IndexType m_FloatingDims; 00134 00136 UniformVolume::CoordinateVectorType m_FloatingSize; 00137 00139 UniformVolume::CoordinateVectorType m_FloatingInverseDelta; 00140 00142 UniformVolume::CoordinateRegionType m_FloatingCropRegionCoordinates; 00143 00145 UniformVolume::CoordinateRegionType m_FloatingCropRegionFractIndex; 00146 00148 DataGrid::IndexType m_ReferenceDims; 00149 00151 UniformVolume::CoordinateVectorType m_ReferenceSize; 00152 00154 UniformVolume::CoordinateVectorType m_ReferenceInverseDelta; 00155 00157 bool m_ForceOutsideFlag; 00158 00160 Types::DataItem m_ForceOutsideValueRescaled; 00161 00167 const DataGrid::RegionType GetReferenceGridRange ( const Vector3D& fromVOI, const Vector3D& toVOI ); 00168 00169 private: 00171 ImagePairRegistrationFunctional ( const ImagePairRegistrationFunctional& ) {} 00172 00174 void InitFloating( UniformVolume::SmartConstPtr& floating ); 00175 00177 void InitReference( UniformVolume::SmartConstPtr& reference ); 00178 }; 00179 00181 00182 } // namespace cmtk 00183 00184 #endif // __cmtkImagePairRegistrationFunctional_h_included_