cmtkMultiChannelRegistrationFunctionalBase.h

Go to the documentation of this file.
00001 /*
00002 //
00003 //  Copyright 1997-2010 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 #ifndef __cmtkMultiChannelRegistrationFunctionalBase_h_included_
00034 #define __cmtkMultiChannelRegistrationFunctionalBase_h_included_
00035 
00036 #include <cmtkconfig.h>
00037 
00038 #include <Base/cmtkFunctional.h>
00039 
00040 #include <Base/cmtkUniformVolume.h>
00041 #include <System/cmtkSmartPtr.h>
00042 
00043 #include <Base/cmtkUniformVolumeInterpolator.h>
00044 #include <Base/cmtkLinearInterpolator.h>
00045 
00046 #include <vector>
00047 
00048 namespace
00049 cmtk
00050 {
00051 
00054 
00056 class MultiChannelRegistrationFunctionalBase :
00058   public Functional
00059 {
00060 public:
00062   typedef MultiChannelRegistrationFunctionalBase Self;
00063   
00065   typedef SmartPointer<Self> SmartPtr;
00066 
00068   typedef Functional Superclass;
00069 
00071   MultiChannelRegistrationFunctionalBase() : m_NumberOfChannels( 0 ), m_NormalizedMI( false ) {}
00072   
00074   virtual ~MultiChannelRegistrationFunctionalBase()
00075   {
00076     this->ClearAllChannels();
00077   }
00078 
00080   void SetNormalizedMI( const bool nmi = true )
00081   {
00082     this->m_NormalizedMI = nmi;
00083   }
00084 
00086   virtual void ClearAllChannels();
00087 
00089   virtual void AddReferenceChannel( UniformVolume::SmartPtr& channel );
00090 
00092   template <class ForwardIterator>
00093   void AddReferenceChannels( ForwardIterator first, ForwardIterator last )
00094   {
00095     while ( first != last )
00096       {
00097       this->AddReferenceChannel( *first );
00098       ++first;
00099       }
00100   }
00101 
00103   size_t GetNumberOfReferenceChannels() const { return this->m_ReferenceChannels.size(); }
00104 
00106   UniformVolume::SmartPtr& GetReferenceChannel( const size_t idx ) { return this->m_ReferenceChannels[idx]; }
00107 
00109   const UniformVolume* GetReferenceChannel( const size_t idx ) const { return this->m_ReferenceChannels[idx]; }
00110 
00112   virtual void AddFloatingChannel( UniformVolume::SmartPtr& channel );
00113 
00115   template <class ForwardIterator>
00116   void AddFloatingChannels( ForwardIterator first, ForwardIterator last )
00117   {
00118     while ( first != last )
00119       {
00120       this->AddFloatingChannel( *first );
00121       ++first;
00122       }
00123   }
00124 
00126   size_t GetNumberOfFloatingChannels() const { return this->m_FloatingChannels.size(); }
00127 
00129   UniformVolume::SmartPtr& GetFloatingChannel( const size_t idx ) { return this->m_FloatingChannels[idx]; }
00130 
00132   const UniformVolume* GetFloatingChannel( const size_t idx ) const { return this->m_FloatingChannels[idx]; }
00133 
00135   std::vector<UniformVolume::SmartPtr> m_ReferenceChannels;
00136 
00138   std::vector<UniformVolume::SmartPtr> m_FloatingChannels;
00139 
00140 protected:
00142   size_t m_NumberOfChannels;
00143 
00145   DataGrid::IndexType m_ReferenceDims;
00146 
00148   UniformVolume::CoordinateVectorType m_ReferenceSize;
00149 
00151   UniformVolume::CoordinateVectorType m_ReferenceInvDelta;
00152 
00154   DataGrid::RegionType m_ReferenceCropRegion;
00155   
00157   DataGrid::IndexType m_FloatingDims;
00158 
00160   UniformVolume::CoordinateVectorType m_FloatingSize;
00161 
00163   UniformVolume::CoordinateVectorType m_FloatingInverseDelta;
00164 
00166   UniformVolume::CoordinateRegionType m_FloatingCropRegion;
00167  
00169   virtual void NewReferenceChannelGeometry() {}
00170 
00171 protected:
00173   bool m_NormalizedMI;
00174 
00175 private:
00177   void VerifyImageSize( const UniformVolume* imgA, const UniformVolume* imgB );
00178 };
00179 
00181 
00182 } // namespace cmtk
00183 
00184 #endif // #ifndef __cmtkMultiChannelRegistrationFunctionalBase_h_included_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines