cmtkVolumeInjectionReconstruction.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 __cmtkVolumeInjectionReconstruction_h_included_
00034 #define __cmtkVolumeInjectionReconstruction_h_included_
00035 
00036 #include <cmtkconfig.h>
00037 
00038 #include <Registration/cmtkAffineRegistration.h>
00039 #include <Base/cmtkAffineXform.h>
00040 #include <Base/cmtkXform.h>
00041 #include <Base/cmtkUniformVolume.h>
00042 
00043 #include "Numerics/ap.h"
00044 
00045 #include <vector>
00046 
00047 namespace
00048 cmtk
00049 {
00050 
00053 
00064 class VolumeInjectionReconstruction
00065 {
00066 public:
00068   typedef VolumeInjectionReconstruction Self;
00069 
00076   VolumeInjectionReconstruction( const UniformVolume* originalImage, const int numberOfPasses, const int interleaveAxis );
00077 
00080   VolumeInjectionReconstruction( const UniformVolume* reconstructionGrid, std::vector<UniformVolume::SmartPtr>& images );
00081 
00083   virtual ~VolumeInjectionReconstruction() {}
00084 
00092   static int GuessInterleaveAxis( 
00093     const UniformVolume* image, 
00094     const int defaultAxis = 2 
00095     );
00096 
00104   void ComputeTransformationsToPassImages( const int registrationMetric = 0 );
00105 
00107   void SetTransformationsToPassImages( std::vector<Xform::SmartPtr>& transformations )
00108   {
00109     this->m_TransformationsToPassImages = transformations;
00110   }
00111 
00113   Xform::SmartPtr& GetTransformationToPassImage( const size_t passIdx )
00114   {
00115     if ( passIdx < this->m_TransformationsToPassImages.size() )
00116       return this->m_TransformationsToPassImages[passIdx];
00117     else
00118       return Xform::SmartPtr::Null;
00119   }
00120 
00122   std::vector<Xform::SmartPtr>& GetTransformationsToPassImages()
00123   {
00124     return this->m_TransformationsToPassImages;
00125   }
00126 
00128   void VolumeInjectionIsotropic
00129   ( const Types::Coordinate kernelSigma, 
00130     const Types::Coordinate kernelRadius 
00131     );
00132 
00134   void VolumeInjectionAnisotropic
00135   ( const Types::Coordinate kernelSigmaFactor, 
00136     const Types::Coordinate kernelRadiusFactor 
00137     );
00138 
00140   UniformVolume::SmartPtr& GetCorrectedImage();
00141   
00143   void SetReferenceImage( UniformVolume::SmartPtr& referenceImage );  
00144 
00153   void SetPassWeight( const size_t pass, const Types::Coordinate weight )
00154   {
00155     this->m_PassWeights[pass] = weight;
00156   }
00157 
00159   ap::real_value_type GetOriginalToCorrectedImageKLD( const ap::real_1d_array& x );
00160   
00161 protected:
00163   int m_NumberOfPasses;
00164 
00166   std::vector<Types::Coordinate> m_PassWeights;
00167 
00169   Types::DataItemRange m_OriginalImageRange;
00170 
00172   std::vector<UniformVolume::SmartPtr> m_OriginalPassImages;
00173 
00175   typedef Histogram<double> HistogramType;
00176 
00178   HistogramType::SmartPtr m_OriginalImageHistogram;
00179 
00181   HistogramType::SmartPtr m_CorrectedImageHistogram;
00182 
00184   std::vector<HistogramType::BinType> m_OriginalImageIntensityNoiseKernel;
00185 
00187   UniformVolume::SmartPtr m_ReferenceImage;
00188 
00190   std::vector<Xform::SmartPtr> m_TransformationsToPassImages;
00191 
00193   UniformVolume::SmartPtr m_CorrectedImage;
00194 
00196   std::vector<ap::real_value_type> m_CorrectedImageLaplacians;  
00197 
00202   ap::real_value_type ComputeCorrectedImageLaplacianNorm( 
00203     const ap::real_1d_array& correctedImagePixels 
00204     );
00205   
00207   void AddLaplacianGradientImage( 
00208     ap::real_1d_array& g, 
00209     const ap::real_1d_array& correctedImagePixels,
00210     const ap::real_value_type weight ) const;
00211 
00213   ap::real_1d_array m_NeighorhoodMaxPixelValues;
00214   
00216   ap::real_1d_array m_NeighorhoodMinPixelValues;
00217   
00218 private:
00220   static const unsigned int NumberOfHistogramBins = 64;
00221 
00223   void SetupHistogramKernels( const TypedArray* originalData );
00224 };
00225 
00227 
00228 } // namespace cmtk
00229 
00230 #endif // #ifndef __cmtkVolumeInjectionReconstruction_h_included_
00231 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines