cmtkFunctionalAffine2D.h

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 #ifndef __cmtkFunctionalAffine2D_h_included_
00034 #define __cmtkFunctionalAffine2D_h_included_
00035 
00036 #include <cmtkconfig.h>
00037 
00038 #include <System/cmtkSmartPtr.h>
00039 
00040 #include <Base/cmtkFunctional.h>
00041 #include <Base/cmtkMacros.h>
00042 #include <Base/cmtkScalarImage.h>
00043 #include <Base/cmtkMatrix3x3.h>
00044 #include <Base/cmtkHistogram.h>
00045 #include <Base/cmtkJointHistogram.h>
00046 
00047 #include <Registration/cmtkScalarImageSimilarity.h>
00048 
00049 #include <vector>
00050 
00051 namespace
00052 cmtk
00053 {
00054 
00057 
00060 class FunctionalAffine2D :
00062   public Functional 
00063 {
00065   cmtkGetSetMacro(int,NumberDOFs);
00066 
00068   cmtkGetSetMacro(ScalarImageSimilarity::ID,SimilarityMeasure);
00069 
00071   cmtkGetSetMacro(bool,HistogramEqualization);
00072 
00073 public:
00075   typedef FunctionalAffine2D Self;
00076 
00078   typedef SmartPointer<Self> SmartPtr;
00079 
00081   typedef Functional Superclass;
00082 
00084   FunctionalAffine2D( ScalarImage::SmartPtr& refImage, ScalarImage::SmartPtr& fltImage, const ScalarImage::RegionType* fltROI = NULL );
00085 
00087   FunctionalAffine2D( std::vector<ScalarImage::SmartPtr>& refImage, std::vector<ScalarImage::SmartPtr>& fltImage, const ScalarImage::RegionType* fltROI = NULL );
00088 
00090   ~FunctionalAffine2D() {};
00091   
00093   virtual void SetRefImage( ScalarImage::SmartPtr& refImage ) 
00094   {
00095     this->RefImages.clear();
00096     this->RefImages.push_back( refImage );
00097   }
00098 
00100   virtual void SetRefImages
00101   ( std::vector<ScalarImage::SmartPtr>& refImages ) 
00102   {
00103     this->RefImages = refImages;
00104   }
00105 
00107   virtual void SetFltImage( ScalarImage::SmartPtr& fltImage ) 
00108   {
00109     this->FltImages.clear();
00110     this->FltImagesROI.clear();
00111     this->FltImages.push_back( fltImage );
00112     this->FltImagesROI.push_back( fltImage );
00113   }
00114 
00116   virtual void SetFltImages
00117   ( std::vector<ScalarImage::SmartPtr>& fltImages ) 
00118   {
00119     this->FltImages = fltImages;
00120     this->FltImagesROI = fltImages;
00121   }
00122 
00124   void SetNumberOfBins( const size_t minBins, const size_t maxBins = 0 );
00125 
00127   virtual Self::ReturnType Evaluate();
00128 
00130   virtual  Self::ReturnType EvaluateAt( CoordinateVector& v );
00131 
00133   virtual  Self::ReturnType EvaluateWithGradient( CoordinateVector&, CoordinateVector&, const Types::Coordinate = 1 )
00134   { return 0; }
00135 
00136 
00138   virtual void SetParamVector( CoordinateVector& v );
00139 
00144   virtual void GetParamVector( CoordinateVector& v );
00145 
00147   virtual size_t ParamVectorDim() const { return 8; }
00148 
00150   virtual size_t VariableParamVectorDim() const { return this->m_NumberDOFs; }
00151 
00153   virtual Types::Coordinate GetParamStep( const size_t idx, const Types::Coordinate mmStep = 1 ) const;
00154 
00155 private:
00157   std::vector<ScalarImage::SmartPtr> RefImages;
00158 
00160   std::vector<ScalarImage::SmartPtr> FltImages;
00161 
00166   std::vector<ScalarImage::SmartPtr> FltImagesROI;
00167 
00169   mutable ScalarImageSimilarityMemory ImageSimilarityMemory;
00170   
00172   Self::ReturnType GetSimilarity( const ScalarImage* img0,  const ScalarImage* img1 ) const;
00173 
00175   Self::ReturnType GetSimilarity( std::vector<const ScalarImage*>& imgs0,  std::vector<const ScalarImage*>& imgs1 ) const;
00176 
00178   CoordinateVector Parameters;
00179 
00181   CoordinateMatrix3x3 Transformation;
00182 };
00183 
00185 
00186 } // namespace cmtk
00187 
00188 #endif // #ifndef __cmtkFunctionalAffine2D_h_included_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines