Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include <Registration/cmtkSymmetricElasticFunctional.h>
00034
00035 #include <Registration/cmtkVoxelMatchingMutInf.h>
00036 #include <Registration/cmtkVoxelMatchingNormMutInf.h>
00037 #include <Registration/cmtkVoxelMatchingCorrRatio.h>
00038 #include <Registration/cmtkVoxelMatchingMeanSquaredDifference.h>
00039 #include <Registration/cmtkVoxelMatchingCrossCorrelation.h>
00040
00041 #include <Base/cmtkSplineWarpXform.h>
00042 #include <Base/cmtkInterpolator.h>
00043 #include <Base/cmtkUniformVolume.h>
00044
00045 namespace
00046 cmtk
00047 {
00048
00051
00052 template<class VM>
00053 void
00054 SymmetricElasticFunctional_Template<VM>::SetWarpXform
00055 ( SplineWarpXform::SmartPtr& warpFwd, SplineWarpXform::SmartPtr& warpBwd )
00056 {
00057 this->FwdFunctional.SetWarpXform( warpFwd );
00058 this->FwdFunctional.SetInverseTransformation( warpBwd );
00059
00060 this->BwdFunctional.SetWarpXform( warpBwd );
00061 this->BwdFunctional.SetInverseTransformation( warpFwd );
00062 }
00063
00064 template<class VM>
00065 typename SymmetricElasticFunctional_Template<VM>::ReturnType
00066 SymmetricElasticFunctional_Template<VM>
00067 ::EvaluateWithGradient( CoordinateVector& v, CoordinateVector& g, const Types::Coordinate step )
00068 {
00069 CoordinateVector vFwd( this->FwdFunctional.ParamVectorDim(), v.Elements, false );
00070 CoordinateVector gFwd( this->FwdFunctional.ParamVectorDim(), g.Elements, false );
00071
00072 CoordinateVector vBwd( this->BwdFunctional.ParamVectorDim(), v.Elements+this->FwdFunctional.ParamVectorDim(), false );
00073 CoordinateVector gBwd( this->BwdFunctional.ParamVectorDim(), g.Elements+this->FwdFunctional.ParamVectorDim(), false );
00074
00075 return this->FwdFunctional.EvaluateWithGradient( vFwd, gFwd, step ) + this->BwdFunctional.EvaluateWithGradient( vBwd, gBwd, step );
00076 }
00077
00078 SymmetricElasticFunctional*
00079 CreateSymmetricElasticFunctional( const int metric, UniformVolume::SmartPtr& refVolume, UniformVolume::SmartPtr& fltVolume )
00080 {
00081 switch ( fltVolume->GetData()->GetDataClass() )
00082 {
00083 case DATACLASS_UNKNOWN :
00084 case DATACLASS_GREY :
00085 switch ( metric )
00086 {
00087 case 0:
00088 return new SymmetricElasticFunctional_Template< VoxelMatchingNormMutInf_Trilinear>( refVolume, fltVolume );
00089 case 1:
00090 return new SymmetricElasticFunctional_Template<VoxelMatchingMutInf_Trilinear>( refVolume, fltVolume );
00091 case 2:
00092 return new SymmetricElasticFunctional_Template<VoxelMatchingCorrRatio_Trilinear>( refVolume, fltVolume );
00093 case 3:
00094 return NULL;
00095 case 4:
00096 return new SymmetricElasticFunctional_Template<VoxelMatchingMeanSquaredDifference>( refVolume, fltVolume );
00097 case 5:
00098 return new SymmetricElasticFunctional_Template<VoxelMatchingCrossCorrelation>( refVolume, fltVolume );
00099 default:
00100 return NULL;
00101 }
00102 case DATACLASS_LABEL:
00103 switch ( metric )
00104 {
00105 case 0:
00106 return new SymmetricElasticFunctional_Template<VoxelMatchingNormMutInf_NearestNeighbor>( refVolume, fltVolume );
00107 case 1:
00108 return new SymmetricElasticFunctional_Template<VoxelMatchingMutInf_NearestNeighbor>( refVolume, fltVolume );
00109 case 2:
00110 return new SymmetricElasticFunctional_Template<VoxelMatchingCorrRatio_NearestNeighbor>( refVolume, fltVolume );
00111 case 3:
00112 return NULL;
00113 case 4:
00114 return new SymmetricElasticFunctional_Template<VoxelMatchingMeanSquaredDifference>( refVolume, fltVolume );
00115 case 5:
00116 return new SymmetricElasticFunctional_Template<VoxelMatchingCrossCorrelation>( refVolume, fltVolume );
00117 default:
00118 return NULL;
00119 }
00120 }
00121
00122 return NULL;
00123 }
00124
00125 }