ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkJointHistogramMutualInformationGetValueAndDerivativeThreader.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkJointHistogramMutualInformationGetValueAndDerivativeThreader_h
00019 #define __itkJointHistogramMutualInformationGetValueAndDerivativeThreader_h
00020 
00021 #include "itkImageToImageMetricv4GetValueAndDerivativeThreader.h"
00022 
00023 namespace itk
00024 {
00025 
00033 template < class TDomainPartitioner, class TImageToImageMetric, class TJointHistogramMetric >
00034 class JointHistogramMutualInformationGetValueAndDerivativeThreader
00035   : public ImageToImageMetricv4GetValueAndDerivativeThreader< TDomainPartitioner, TImageToImageMetric >
00036 {
00037 public:
00039   typedef JointHistogramMutualInformationGetValueAndDerivativeThreader Self;
00040   typedef ImageToImageMetricv4GetValueAndDerivativeThreader< TDomainPartitioner, TImageToImageMetric >
00041                                                                        Superclass;
00042   typedef SmartPointer< Self >                                         Pointer;
00043   typedef SmartPointer< const Self >                                   ConstPointer;
00044 
00045   itkTypeMacro( JointHistogramMutualInformationGetValueAndDerivativeThreader, ImageToImageMetricv4GetValueAndDerivativeThreader );
00046 
00047   itkNewMacro( Self );
00048 
00049   typedef typename Superclass::DomainType    DomainType;
00050   typedef typename Superclass::AssociateType AssociateType;
00051 
00052   typedef typename Superclass::VirtualPointType        VirtualPointType;
00053   typedef typename Superclass::FixedImagePointType     FixedImagePointType;
00054   typedef typename Superclass::FixedImagePixelType     FixedImagePixelType;
00055   typedef typename Superclass::FixedImageGradientType  FixedImageGradientType;
00056   typedef typename Superclass::MovingImagePointType    MovingImagePointType;
00057   typedef typename Superclass::MovingImagePixelType    MovingImagePixelType;
00058   typedef typename Superclass::MovingImageGradientType MovingImageGradientType;
00059   typedef typename Superclass::MeasureType             MeasureType;
00060   typedef typename Superclass::DerivativeType          DerivativeType;
00061   typedef typename Superclass::DerivativeValueType     DerivativeValueType;
00062 
00063   typedef TJointHistogramMetric                                             JointHistogramMetricType;
00064   typedef typename JointHistogramMetricType::InternalComputationValueType   InternalComputationValueType;
00065   typedef typename JointHistogramMetricType::JointPDFInterpolatorType       JointPDFInterpolatorType;
00066   typedef typename JointHistogramMetricType::MarginalPDFInterpolatorType    MarginalPDFInterpolatorType;
00067   typedef typename JointHistogramMetricType::JointPDFInterpolatorPointer    JointPDFInterpolatorPointer;
00068   typedef typename JointHistogramMetricType::MarginalPDFInterpolatorPointer MarginalPDFInterpolatorPointer;
00069   typedef typename JointHistogramMetricType::FixedTransformJacobianType     FixedTransformJacobianType;
00070   typedef typename JointHistogramMetricType::NumberOfParametersType         NumberOfParametersType;
00071   typedef typename JointHistogramMetricType::JointPDFType                   JointPDFType;
00072   typedef typename JointHistogramMetricType::MarginalPDFType                MarginalPDFType;
00073   typedef typename MarginalPDFType::PointType                               MarginalPDFPointType;
00074   typedef typename JointPDFType::PointType                                  JointPDFPointType;
00075   typedef typename JointHistogramMetricType::JointPDFValueType              JointPDFValueType;
00076 
00077 protected:
00078   JointHistogramMutualInformationGetValueAndDerivativeThreader() {}
00079 
00080   typedef Image< SizeValueType, 2 > JointHistogramType;
00081   std::vector< typename JointHistogramType::Pointer > m_JointHistogramPerThread;
00082 
00083   virtual void BeforeThreadedExecution();
00084 
00085   virtual void AfterThreadedExecution();
00086 
00087   virtual bool ProcessPoint(
00088         const VirtualPointType &          virtualPoint,
00089         const FixedImagePointType &       mappedFixedPoint,
00090         const FixedImagePixelType &       mappedFixedPixelValue,
00091         const FixedImageGradientType &    mappedFixedImageGradient,
00092         const MovingImagePointType &      mappedMovingPoint,
00093         const MovingImagePixelType &      mappedMovingPixelValue,
00094         const MovingImageGradientType &   mappedMovingImageGradient,
00095         MeasureType &                     metricValueReturn,
00096         DerivativeType &                  localDerivativeReturn,
00097         const ThreadIdType                threadID ) const;
00098 
00099   inline InternalComputationValueType ComputeFixedImageMarginalPDFDerivative(
00100                                         const MarginalPDFPointType & margPDFpoint,
00101                                         const ThreadIdType threadID ) const;
00102 
00103   inline InternalComputationValueType ComputeMovingImageMarginalPDFDerivative(
00104                                         const MarginalPDFPointType & margPDFpoint,
00105                                         const ThreadIdType threadID ) const;
00106 
00107   inline InternalComputationValueType ComputeJointPDFDerivative(
00108                                           const JointPDFPointType & jointPDFpoint,
00109                                           const ThreadIdType threadID,
00110                                           const SizeValueType ind ) const;
00111 
00112   std::vector< SizeValueType >                  m_JointHistogramCountPerThread;
00113   std::vector< JointPDFInterpolatorPointer >    m_JointPDFInterpolatorPerThread;
00114   std::vector< MarginalPDFInterpolatorPointer > m_FixedImageMarginalPDFInterpolatorPerThread;
00115   std::vector< MarginalPDFInterpolatorPointer > m_MovingImageMarginalPDFInterpolatorPerThread;
00116 
00117 private:
00118   JointHistogramMutualInformationGetValueAndDerivativeThreader( const Self & ); // purposely not implemented
00119   void operator=( const Self & ); // purposely not implemented
00120 };
00121 
00122 } // end namespace itk
00123 
00124 #endif
00125 
00126 #ifndef ITK_MANUAL_INSTANTIATION
00127 #include "itkJointHistogramMutualInformationGetValueAndDerivativeThreader.hxx"
00128 #endif
00129