cmtkMultiChannelRegistrationFunctionalBase.cxx

Go to the documentation of this file.
00001 /*
00002 //
00003 //  Copyright 1997-2009 Torsten Rohlfing
00004 //
00005 //  Copyright 2004-2010 SRI International
00006 //
00007 //  This file is part of the Computational Morphometry Toolkit.
00008 //
00009 //  http://www.nitrc.org/projects/cmtk/
00010 //
00011 //  The Computational Morphometry Toolkit is free software: you can
00012 //  redistribute it and/or modify it under the terms of the GNU General Public
00013 //  License as published by the Free Software Foundation, either version 3 of
00014 //  the License, or (at your option) any later version.
00015 //
00016 //  The Computational Morphometry Toolkit is distributed in the hope that it
00017 //  will be useful, but WITHOUT ANY WARRANTY; without even the implied
00018 //  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 //  GNU General Public License for more details.
00020 //
00021 //  You should have received a copy of the GNU General Public License along
00022 //  with the Computational Morphometry Toolkit.  If not, see
00023 //  <http://www.gnu.org/licenses/>.
00024 //
00025 //  $Revision: 2398 $
00026 //
00027 //  $LastChangedDate: 2010-10-05 14:54:37 -0700 (Tue, 05 Oct 2010) $
00028 //
00029 //  $LastChangedBy: torstenrohlfing $
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 } // namespace cmtk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines