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 "cmtkEntropyMinimizationIntensityCorrectionFunctionalDevice.h"
00034
00035 #include <System/cmtkConsole.h>
00036
00037 namespace
00038 cmtk
00039 {
00040
00043 template<unsigned int NDegreeMul>
00044 EntropyMinimizationIntensityCorrectionFunctionalBase::SmartPtr
00045 CreateEntropyMinimizationIntensityCorrectionFunctionalDevice
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 EntropyMinimizationIntensityCorrectionFunctionalDevice<0,NDegreeMul> );
00055 break;
00056 case 1 :
00057 functional = FunctionalPointer( new EntropyMinimizationIntensityCorrectionFunctionalDevice<1,NDegreeMul> );
00058 break;
00059 case 2 :
00060 functional = FunctionalPointer( new EntropyMinimizationIntensityCorrectionFunctionalDevice<2,NDegreeMul> );
00061 break;
00062 case 3 :
00063 functional = FunctionalPointer( new EntropyMinimizationIntensityCorrectionFunctionalDevice<3,NDegreeMul> );
00064 break;
00065 case 4 :
00066 functional = FunctionalPointer( new EntropyMinimizationIntensityCorrectionFunctionalDevice<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 CreateEntropyMinimizationIntensityCorrectionFunctionalDevice
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 = CreateEntropyMinimizationIntensityCorrectionFunctionalDevice<0>( polynomialDegreeAdd );
00087 break;
00088 case 1 :
00089 functional = CreateEntropyMinimizationIntensityCorrectionFunctionalDevice<1>( polynomialDegreeAdd );
00090 break;
00091 case 2 :
00092 functional = CreateEntropyMinimizationIntensityCorrectionFunctionalDevice<2>( polynomialDegreeAdd );
00093 break;
00094 case 3 :
00095 functional = CreateEntropyMinimizationIntensityCorrectionFunctionalDevice<3>( polynomialDegreeAdd );
00096 break;
00097 case 4 :
00098 functional = CreateEntropyMinimizationIntensityCorrectionFunctionalDevice<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 CreateEntropyMinimizationIntensityCorrectionFunctionalDevice
00110 ( const unsigned int polynomialDegreeAdd, const unsigned int polynomialDegreeMul,
00111 EntropyMinimizationIntensityCorrectionFunctionalBase::SmartPtr oldFunctional )
00112 {
00113 EntropyMinimizationIntensityCorrectionFunctionalBase::SmartPtr newFunctional = CreateEntropyMinimizationIntensityCorrectionFunctionalDevice( 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