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 "cmtkMultiChannelRegistrationFunctionalBase.h"
00034
00035 #include <System/cmtkException.h>
00036 #include <Base/cmtkMathUtil.h>
00037 #include <Base/cmtkTypes.h>
00038
00039 #include <algorithm>
00040
00041 namespace
00042 cmtk
00043 {
00044
00047
00048 void
00049 MultiChannelRegistrationFunctionalBase
00050 ::ClearAllChannels()
00051 {
00052 this->m_ReferenceChannels.resize( 0 );
00053 this->m_FloatingChannels.resize( 0 );
00054 }
00055
00056 void
00057 MultiChannelRegistrationFunctionalBase
00058 ::AddReferenceChannel( UniformVolume::SmartPtr& channel )
00059 {
00060 if ( this->m_ReferenceChannels.size() )
00061 {
00062 this->VerifyImageSize( this->m_ReferenceChannels[0], channel );
00063 }
00064 else
00065 {
00066 this->m_ReferenceDims = channel->GetDims();
00067 this->m_ReferenceSize = channel->Size;
00068 this->m_ReferenceCropRegion = channel->CropRegion();
00069 }
00070 this->m_ReferenceChannels.push_back( channel );
00071 this->m_NumberOfChannels = this->m_ReferenceChannels.size() + this->m_FloatingChannels.size();
00072
00073 if ( this->m_ReferenceChannels.size() == 1 )
00074 {
00075 this->NewReferenceChannelGeometry();
00076 }
00077 }
00078
00079 void
00080 MultiChannelRegistrationFunctionalBase
00081 ::AddFloatingChannel( UniformVolume::SmartPtr& channel )
00082 {
00083 if ( this->m_FloatingChannels.size() )
00084 {
00085 this->VerifyImageSize( this->m_FloatingChannels[0], channel );
00086 }
00087 else
00088 {
00089 this->m_FloatingDims = channel->GetDims();
00090 this->m_FloatingSize = channel->Size;
00091 this->m_FloatingCropRegion = channel->GetHighResCropRegion();
00092 for ( int dim = 0; dim < 3; ++dim )
00093 {
00094 this->m_FloatingInverseDelta[dim] = 1.0 / channel->m_Delta[dim];
00095 }
00096 }
00097 this->m_FloatingChannels.push_back( channel );
00098 this->m_NumberOfChannels = this->m_ReferenceChannels.size() + this->m_FloatingChannels.size();
00099 }
00100
00101 void
00102 MultiChannelRegistrationFunctionalBase
00103 ::VerifyImageSize( const UniformVolume* imgA, const UniformVolume* imgB )
00104 {
00105 for ( int dim = 0; dim < 3; ++dim )
00106 {
00107 if ( imgA->GetDims()[dim] != imgB->GetDims()[dim] )
00108 {
00109 throw Exception( "MultiChannelRegistrationFunctionalBase::VerifyImageSize(): Image dimension mismatch" );
00110 }
00111 if ( fabs( imgA->Size[dim] - imgB->Size[dim] ) > 1e-6 )
00112 {
00113 throw Exception( "MultiChannelRegistrationFunctionalBase::VerifyImageSize(): Image size mismatch" );
00114 }
00115 }
00116 }
00117
00118 }