cmtkInverseInterpolationVolumeReconstruction.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 __cmtkInverseInterpolationVolumeReconstruction_h_included_
00034 #define __cmtkInverseInterpolationVolumeReconstruction_h_included_
00035 
00036 #include <cmtkconfig.h>
00037 
00038 #include <Recon/cmtkInverseInterpolationVolumeReconstructionBase.h>
00039 
00040 #include <Base/cmtkAffineXform.h>
00041 #include <Base/cmtkUniformVolume.h>
00042 
00043 #include <Registration/cmtkAffineRegistration.h>
00044 
00045 #include <System/cmtkProgress.h>
00046 
00047 #include "Numerics/ap.h"
00048 
00049 #include <vector>
00050 
00051 namespace
00052 cmtk
00053 {
00054 
00057 
00061 template<class TInterpolator> 
00062 class InverseInterpolationVolumeReconstruction :
00064   public InverseInterpolationVolumeReconstructionBase
00065 {
00066 public:
00068   typedef InverseInterpolationVolumeReconstruction<TInterpolator> Self;
00069 
00071   typedef InverseInterpolationVolumeReconstructionBase Superclass;
00072 
00079   InverseInterpolationVolumeReconstruction( const UniformVolume* originalImage, const int numberOfPasses, const int interleaveAxis )
00080     : InverseInterpolationVolumeReconstructionBase( originalImage, numberOfPasses, interleaveAxis )
00081   { 
00082     this->m_FunctionAndGradient = new typename Self::FunctionAndGradient( this );
00083   }
00084 
00087   InverseInterpolationVolumeReconstruction( const UniformVolume* reconstructionGrid, std::vector<UniformVolume::SmartPtr>& images )
00088     : InverseInterpolationVolumeReconstructionBase( reconstructionGrid, images )
00089   { 
00090     this->m_FunctionAndGradient = new typename Self::FunctionAndGradient( this );
00091   }
00092   
00094   virtual ~InverseInterpolationVolumeReconstruction()
00095   {
00096     delete this->m_FunctionAndGradient;
00097   }
00098 
00099 private:
00101   void Interpolation( const ap::real_1d_array& reconstructedPixelArray );
00102   
00104   void ComputeErrorGradientImage( ap::real_1d_array& g );
00105 
00107   void GetPassImageDependentPixelRegion
00108   ( int* region, const UniformVolume* correctedImage, const int* currentCorrectedGridPoint, 
00109     const UniformVolume* passImage, const AffineXform* transformationToPassImage, const DataGrid::IndexType& passImageDims );
00110 
00112   class FunctionAndGradient : 
00114     public ap::FunctionAndGradient
00115   {
00116   public:
00118     typedef InverseInterpolationVolumeReconstruction<TInterpolator> FunctionType;
00119 
00121     FunctionAndGradient( FunctionType* function )
00122     {
00123       this->m_Function = function;
00124     }
00125 
00127     virtual void Evaluate( const ap::real_1d_array& x, ap::real_value_type& f, ap::real_1d_array& g );
00128 
00130     virtual void NextIteration( const int iteration )
00131     {
00132       Progress::SetProgress( iteration );
00133     }
00134 
00135   private:
00137     FunctionType* m_Function;
00138   };
00139 
00141   friend class Self::FunctionAndGradient;
00142 };
00143 
00145 
00146 } // namespace cmtk
00147 
00148 #include "cmtkInverseInterpolationVolumeReconstruction.txx"
00149 
00150 #endif // #ifndef __cmtkInverseInterpolationVolumeReconstruction_h_included_
00151 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines