ITK  4.1.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::VirtualIndexType        VirtualIndexType;
00054   typedef typename Superclass::FixedImagePointType     FixedImagePointType;
00055   typedef typename Superclass::FixedImagePixelType     FixedImagePixelType;
00056   typedef typename Superclass::FixedImageGradientType  FixedImageGradientType;
00057   typedef typename Superclass::MovingImagePointType    MovingImagePointType;
00058   typedef typename Superclass::MovingImagePixelType    MovingImagePixelType;
00059   typedef typename Superclass::MovingImageGradientType MovingImageGradientType;
00060   typedef typename Superclass::MeasureType             MeasureType;
00061   typedef typename Superclass::DerivativeType          DerivativeType;
00062   typedef typename Superclass::DerivativeValueType     DerivativeValueType;
00063 
00064   typedef TJointHistogramMetric                                             JointHistogramMetricType;
00065   typedef typename JointHistogramMetricType::InternalComputationValueType   InternalComputationValueType;
00066   typedef typename JointHistogramMetricType::JointPDFInterpolatorType       JointPDFInterpolatorType;
00067   typedef typename JointHistogramMetricType::MarginalPDFInterpolatorType    MarginalPDFInterpolatorType;
00068   typedef typename JointHistogramMetricType::JointPDFInterpolatorPointer    JointPDFInterpolatorPointer;
00069   typedef typename JointHistogramMetricType::MarginalPDFInterpolatorPointer MarginalPDFInterpolatorPointer;
00070   typedef typename JointHistogramMetricType::FixedTransformJacobianType     FixedTransformJacobianType;
00071   typedef typename JointHistogramMetricType::NumberOfParametersType         NumberOfParametersType;
00072   typedef typename JointHistogramMetricType::JointPDFType                   JointPDFType;
00073   typedef typename JointHistogramMetricType::MarginalPDFType                MarginalPDFType;
00074   typedef typename MarginalPDFType::PointType                               MarginalPDFPointType;
00075   typedef typename JointPDFType::PointType                                  JointPDFPointType;
00076   typedef typename JointHistogramMetricType::JointPDFValueType              JointPDFValueType;
00077 
00078 protected:
00079   JointHistogramMutualInformationGetValueAndDerivativeThreader() {}
00080 
00081   typedef Image< SizeValueType, 2 > JointHistogramType;
00082   std::vector< typename JointHistogramType::Pointer > m_JointHistogramPerThread;
00083 
00084   virtual void BeforeThreadedExecution();
00085 
00086   virtual void AfterThreadedExecution();
00087 
00088   virtual bool ProcessPoint(
00089         const VirtualIndexType &          virtualIndex,
00090         const VirtualPointType &          virtualPoint,
00091         const FixedImagePointType &       mappedFixedPoint,
00092         const FixedImagePixelType &       mappedFixedPixelValue,
00093         const FixedImageGradientType &    mappedFixedImageGradient,
00094         const MovingImagePointType &      mappedMovingPoint,
00095         const MovingImagePixelType &      mappedMovingPixelValue,
00096         const MovingImageGradientType &   mappedMovingImageGradient,
00097         MeasureType &                     metricValueReturn,
00098         DerivativeType &                  localDerivativeReturn,
00099         const ThreadIdType                threadID ) const;
00100 
00101   inline InternalComputationValueType ComputeFixedImageMarginalPDFDerivative(
00102                                         const MarginalPDFPointType & margPDFpoint,
00103                                         const ThreadIdType threadID ) const;
00104 
00105   inline InternalComputationValueType ComputeMovingImageMarginalPDFDerivative(
00106                                         const MarginalPDFPointType & margPDFpoint,
00107                                         const ThreadIdType threadID ) const;
00108 
00109   inline InternalComputationValueType ComputeJointPDFDerivative(
00110                                           const JointPDFPointType & jointPDFpoint,
00111                                           const ThreadIdType threadID,
00112                                           const SizeValueType ind ) const;
00113 
00114   std::vector< SizeValueType >                  m_JointHistogramCountPerThread;
00115   std::vector< JointPDFInterpolatorPointer >    m_JointPDFInterpolatorPerThread;
00116   std::vector< MarginalPDFInterpolatorPointer > m_FixedImageMarginalPDFInterpolatorPerThread;
00117   std::vector< MarginalPDFInterpolatorPointer > m_MovingImageMarginalPDFInterpolatorPerThread;
00118 
00119 private:
00120   JointHistogramMutualInformationGetValueAndDerivativeThreader( const Self & ); // purposely not implemented
00121   void operator=( const Self & ); // purposely not implemented
00122 };
00123 
00124 } // end namespace itk
00125 
00126 #endif
00127 
00128 #ifndef ITK_MANUAL_INSTANTIATION
00129 #include "itkJointHistogramMutualInformationGetValueAndDerivativeThreader.hxx"
00130 #endif
00131