cmtkMultiChannelHistogramRegistrationFunctional.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 __cmtkMultiChannelHistogramRegistrationFunctional_h_included_
00034 #define __cmtkMultiChannelHistogramRegistrationFunctional_h_included_
00035 
00036 #include <cmtkconfig.h>
00037 
00038 #include <Registration/cmtkMultiChannelRegistrationFunctional.h>
00039 
00040 #include <Base/cmtkHashMapSTL.h>
00041 #include <Base/cmtkUniformVolume.h>
00042 #include <Base/cmtkUniformVolumeInterpolator.h>
00043 #include <Base/cmtkLinearInterpolator.h>
00044 
00045 #include <System/cmtkSmartPtr.h>
00046 
00047 #include <vector>
00048 
00049 namespace
00050 cmtk
00051 {
00052 
00056 template<class TDataType = float, 
00057          class TInterpolator = cmtk::UniformVolumeInterpolator<cmtk::Interpolators::Linear>,
00058          class THashKeyType = unsigned int, 
00059          char NBitsPerChannel=6>
00060 class MultiChannelHistogramRegistrationFunctional :
00062   public MultiChannelRegistrationFunctional<TInterpolator>
00063 {
00064 public:
00066   static const char m_HistogramBitsPerChannel = NBitsPerChannel;
00067 
00069   typedef MultiChannelHistogramRegistrationFunctional<TDataType,THashKeyType> Self;
00070 
00072   typedef SmartPointer<Self> SmartPtr;
00073 
00075   typedef MultiChannelRegistrationFunctional<TInterpolator> Superclass;
00076 
00078   typedef TDataType DataType;
00079 
00081   typedef THashKeyType HashKeyType;
00082 
00084   virtual void AddReferenceChannel( UniformVolume::SmartPtr& channel );
00085 
00087   virtual void AddFloatingChannel( UniformVolume::SmartPtr& channel );
00088 
00090   virtual void ClearAllChannels();
00091 
00092 protected:
00094   class MetricData
00095   {
00096   private:
00098     typedef MultiChannelHistogramRegistrationFunctional<TDataType,TInterpolator,THashKeyType,NBitsPerChannel> Parent;
00099 
00101     Parent* m_Parent;
00102 
00103   public:
00105     typedef MetricData Self;
00106 
00108     void Init( Parent *const parent );
00109 
00111     typedef HashMapSTL<HashKeyType, int> HashTableType;
00112 
00114     HashTableType m_JointHash;
00115 
00117     HashTableType m_ReferenceHash;
00118 
00120     HashTableType m_FloatingHash;
00121 
00123     size_t m_TotalNumberOfSamples;
00124 
00126     Self& operator=( const Self& source );
00127 
00129     Self& operator+=( const Self& other );
00130 
00132     Self& operator-=( const Self& other );
00133 
00135     void operator+=( const Types::DataItem* values );
00136 
00138     void operator-=( const Types::DataItem* values );
00139   };
00140 
00142   MetricData m_MetricData;
00143 
00145   virtual void ContinueMetric( MetricData& metricData, const size_t rindex, const Vector3D& fvector );
00146 
00148   virtual Functional::ReturnType GetMetric( const MetricData& metricData ) const;
00149 
00150 private:
00152   std::vector<TDataType> m_HashKeyScaleRef;
00153 
00155   std::vector<TDataType> m_HashKeyScaleFlt;
00156 
00158   std::vector<TDataType> m_HashKeyOffsRef;
00159 
00161   std::vector<TDataType> m_HashKeyOffsFlt;
00162 
00164   size_t m_HashKeyShiftRef;
00165 };
00166 
00168 
00169 } // namespace cmtk
00170 
00171 #include "cmtkMultiChannelHistogramRegistrationFunctional.txx"
00172 #include "cmtkMultiChannelHistogramRegistrationFunctionalMetricData.txx"
00173 
00174 #endif // #ifndef __cmtkMultiChannelHistogramRegistrationFunctional_h_included_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines