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 #include <Base/cmtkMathUtil.h>
00033
00034 namespace
00035 cmtk
00036 {
00037
00040
00041 template<class TMetricFunctional>
00042 void
00043 SplineWarpMultiChannelIntensityCorrectionRegistrationFunctional<TMetricFunctional>
00044 ::ContinueMetric( MetricData& metricData, const size_t rindex, const Vector3D& fvector )
00045 {
00046 #ifdef CMTK_VAR_AUTO_ARRAYSIZE
00047 Types::DataItem values[ this->m_NumberOfChannels ];
00048 #else
00049 std::vector<Types::DataItem> values( this->m_NumberOfChannels );
00050 #endif
00051
00052 size_t idx = 0;
00053 for ( size_t ref = 0; ref < this->m_ReferenceChannels.size(); ++ref )
00054 {
00055 if ( !this->m_ReferenceChannels[ref]->GetDataAt( values[idx++], rindex ) ) return;
00056 }
00057
00058 for ( size_t flt = 0; flt < this->m_FloatingChannels.size(); ++flt )
00059 {
00060 if ( !this->m_FloatingInterpolators[flt]->GetDataAt( fvector, values[idx++] ) )
00061 return;
00062 }
00063
00064 const int planeSize = this->m_ReferenceDims[0] * this->m_ReferenceDims[1];
00065 const int z = rindex / planeSize;
00066 const int y = (rindex % planeSize) / this->m_ReferenceDims[0];
00067 const int x = rindex % this->m_ReferenceDims[0];
00068 const Types::DataItem jacobian = static_cast<Types::DataItem>( this->m_Transformation.GetJacobianDeterminant( x, y, z ) );
00069
00070 for ( size_t flt = 0; flt < this->m_FloatingChannels.size(); ++flt, ++idx )
00071 {
00072 values[idx] *= jacobian;
00073 }
00074
00075 metricData += &(values[0]);
00076 }
00077
00078 template<class TMetricFunctional>
00079 void
00080 SplineWarpMultiChannelIntensityCorrectionRegistrationFunctional<TMetricFunctional>
00081 ::ContinueMetricStoreReformatted( MetricData& metricData, const size_t rindex, const Vector3D& fvector )
00082 {
00083 #ifdef CMTK_VAR_AUTO_ARRAYSIZE
00084 Types::DataItem values[ this->m_NumberOfChannels ];
00085 #else
00086 std::vector<Types::DataItem> values( this->m_NumberOfChannels );
00087 #endif
00088
00089 size_t idx = 0;
00090 for ( size_t ref = 0; ref < this->m_ReferenceChannels.size(); ++ref )
00091 {
00092 if ( !this->m_ReferenceChannels[ref]->GetDataAt( values[idx++], rindex ) ) return;
00093 }
00094
00095 for ( size_t flt = 0; flt < this->m_FloatingChannels.size(); ++flt )
00096 {
00097 if ( !this->m_FloatingInterpolators[flt]->GetDataAt( fvector, values[idx++] ) )
00098 {
00099 for ( size_t f = 0; f < this->m_FloatingChannels.size(); ++f )
00100 this->m_ReformattedFloatingChannels[f][rindex] = MathUtil::GetFloatNaN();
00101 return;
00102 }
00103 }
00104
00105 const int planeSize = this->m_ReferenceDims[0] * this->m_ReferenceDims[1];
00106 const int z = rindex / planeSize;
00107 const int y = (rindex % planeSize) / this->m_ReferenceDims[0];
00108 const int x = rindex % this->m_ReferenceDims[0];
00109 const Types::DataItem jacobian = static_cast<Types::DataItem>( this->m_Transformation.GetJacobianDeterminant( x, y, z ) );
00110 for ( size_t flt = 0; flt < this->m_FloatingChannels.size(); ++flt, ++idx )
00111 {
00112 values[idx] *= jacobian;
00113 this->m_ReformattedFloatingChannels[flt][rindex] = static_cast<float>( values[idx] );
00114 }
00115
00116 metricData += &(values[0]);
00117 }
00118
00119 }