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 "cmtkEntropyMinimizationIntensityCorrectionFunctional.h"
00034
00035 #include <System/cmtkConsole.h>
00036
00037 namespace
00038 cmtk
00039 {
00040
00043 template<unsigned int NDegreeMul>
00044 EntropyMinimizationIntensityCorrectionFunctionalBase::SmartPtr
00045 CreateEntropyMinimizationIntensityCorrectionFunctional
00046 ( const unsigned int polynomialDegreeAdd )
00047 {
00048 typedef EntropyMinimizationIntensityCorrectionFunctionalBase::SmartPtr FunctionalPointer;
00049 FunctionalPointer functional;
00050
00051 switch ( polynomialDegreeAdd )
00052 {
00053 case 0 :
00054 functional = FunctionalPointer( new EntropyMinimizationIntensityCorrectionFunctional<0,NDegreeMul> );
00055 break;
00056 case 1 :
00057 functional = FunctionalPointer( new EntropyMinimizationIntensityCorrectionFunctional<1,NDegreeMul> );
00058 break;
00059 case 2 :
00060 functional = FunctionalPointer( new EntropyMinimizationIntensityCorrectionFunctional<2,NDegreeMul> );
00061 break;
00062 case 3 :
00063 functional = FunctionalPointer( new EntropyMinimizationIntensityCorrectionFunctional<3,NDegreeMul> );
00064 break;
00065 case 4 :
00066 functional = FunctionalPointer( new EntropyMinimizationIntensityCorrectionFunctional<4,NDegreeMul> );
00067 break;
00068 default:
00069 StdErr.printf( "ERROR: combination of polynomial degrees %d (add) and %d (mul) not supported.\n", polynomialDegreeAdd, NDegreeMul );
00070 exit( 1 );
00071 }
00072
00073 return functional;
00074 }
00075
00076 EntropyMinimizationIntensityCorrectionFunctionalBase::SmartPtr
00077 CreateEntropyMinimizationIntensityCorrectionFunctional
00078 ( const unsigned int polynomialDegreeAdd, const unsigned int polynomialDegreeMul )
00079 {
00080 typedef EntropyMinimizationIntensityCorrectionFunctionalBase::SmartPtr FunctionalPointer;
00081 FunctionalPointer functional;
00082
00083 switch ( polynomialDegreeMul )
00084 {
00085 case 0 :
00086 functional = CreateEntropyMinimizationIntensityCorrectionFunctional<0>( polynomialDegreeAdd );
00087 break;
00088 case 1 :
00089 functional = CreateEntropyMinimizationIntensityCorrectionFunctional<1>( polynomialDegreeAdd );
00090 break;
00091 case 2 :
00092 functional = CreateEntropyMinimizationIntensityCorrectionFunctional<2>( polynomialDegreeAdd );
00093 break;
00094 case 3 :
00095 functional = CreateEntropyMinimizationIntensityCorrectionFunctional<3>( polynomialDegreeAdd );
00096 break;
00097 case 4 :
00098 functional = CreateEntropyMinimizationIntensityCorrectionFunctional<4>( polynomialDegreeAdd );
00099 break;
00100 default:
00101 StdErr.printf( "ERROR: polynomial degree %d (mul) not supported.\n", polynomialDegreeMul );
00102 exit( 1 );
00103 }
00104
00105 return functional;
00106 }
00107
00108 EntropyMinimizationIntensityCorrectionFunctionalBase::SmartPtr
00109 CreateEntropyMinimizationIntensityCorrectionFunctional
00110 ( const unsigned int polynomialDegreeAdd, const unsigned int polynomialDegreeMul,
00111 EntropyMinimizationIntensityCorrectionFunctionalBase::SmartPtr oldFunctional )
00112 {
00113 EntropyMinimizationIntensityCorrectionFunctionalBase::SmartPtr newFunctional = CreateEntropyMinimizationIntensityCorrectionFunctional( polynomialDegreeAdd, polynomialDegreeMul );
00114
00115 if ( oldFunctional )
00116 {
00117 CoordinateVector vOld;
00118 oldFunctional->GetParamVector( vOld );
00119
00120 CoordinateVector vNew( newFunctional->ParamVectorDim() );
00121 vNew.SetAll( 0.0 );
00122 for ( size_t degreeAdd = 0; degreeAdd < oldFunctional->GetNumberOfMonomialsAdd(); ++degreeAdd )
00123 {
00124 vNew[degreeAdd] = vOld[degreeAdd];
00125 }
00126 for ( size_t degreeMul = 0; degreeMul < oldFunctional->GetNumberOfMonomialsMul(); ++degreeMul )
00127 {
00128 vNew[newFunctional->GetNumberOfMonomialsAdd() + degreeMul] = vOld[oldFunctional->GetNumberOfMonomialsAdd() + degreeMul];
00129 }
00130 }
00131 return newFunctional;
00132 }
00133
00134 }
00135