ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.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 __itkImageToImageMetricv4GetValueAndDerivativeThreaderBase_h
00019 #define __itkImageToImageMetricv4GetValueAndDerivativeThreaderBase_h
00020 
00021 #include "itkDomainThreader.h"
00022 
00023 namespace itk
00024 {
00025 
00042 template < class TDomainPartitioner, class TImageToImageMetricv4 >
00043 class ImageToImageMetricv4GetValueAndDerivativeThreaderBase
00044   : public DomainThreader< TDomainPartitioner, TImageToImageMetricv4 >
00045 {
00046 public:
00048   typedef ImageToImageMetricv4GetValueAndDerivativeThreaderBase       Self;
00049   typedef DomainThreader< TDomainPartitioner, TImageToImageMetricv4 > Superclass;
00050   typedef SmartPointer< Self >                                        Pointer;
00051   typedef SmartPointer< const Self >                                  ConstPointer;
00052 
00053   itkTypeMacro( ImageToImageMetricv4GetValueAndDerivativeThreaderBase, DomainThreader );
00054 
00056   typedef typename Superclass::DomainType    DomainType;
00057   typedef typename Superclass::AssociateType AssociateType;
00058 
00060   typedef TImageToImageMetricv4                                      ImageToImageMetricv4Type;
00061   typedef typename ImageToImageMetricv4Type::VirtualImageType        VirtualImageType;
00062   typedef typename ImageToImageMetricv4Type::VirtualIndexType        VirtualIndexType;
00063   typedef typename ImageToImageMetricv4Type::VirtualPointType        VirtualPointType;
00064   typedef typename ImageToImageMetricv4Type::FixedImagePointType     FixedImagePointType;
00065   typedef typename ImageToImageMetricv4Type::FixedImagePixelType     FixedImagePixelType;
00066   typedef typename ImageToImageMetricv4Type::FixedImageIndexType     FixedImageIndexType;
00067   typedef typename ImageToImageMetricv4Type::FixedImageGradientType  FixedImageGradientType;
00068   typedef typename ImageToImageMetricv4Type::MovingImagePointType    MovingImagePointType;
00069   typedef typename ImageToImageMetricv4Type::MovingImagePixelType    MovingImagePixelType;
00070   typedef typename ImageToImageMetricv4Type::MovingImageGradientType MovingImageGradientType;
00071 
00072   typedef typename ImageToImageMetricv4Type::FixedTransformType      FixedTransformType;
00073   typedef typename FixedTransformType::OutputPointType                   FixedOutputPointType;
00074   typedef typename ImageToImageMetricv4Type::MovingTransformType     MovingTransformType;
00075   typedef typename MovingTransformType::OutputPointType                  MovingOutputPointType;
00076 
00077   typedef typename ImageToImageMetricv4Type::MeasureType             MeasureType;
00078   typedef typename ImageToImageMetricv4Type::DerivativeType          DerivativeType;
00079   typedef typename ImageToImageMetricv4Type::DerivativeValueType     DerivativeValueType;
00080   typedef typename ImageToImageMetricv4Type::JacobianType            JacobianType;
00081 
00082   typedef typename ImageToImageMetricv4Type::InternalComputationValueType InternalComputationValueType;
00083   typedef typename ImageToImageMetricv4Type::NumberOfParametersType       NumberOfParametersType;
00084 
00085 protected:
00087   ImageToImageMetricv4GetValueAndDerivativeThreaderBase();
00088 
00090   virtual void BeforeThreadedExecution();
00091 
00098   virtual void AfterThreadedExecution();
00099 
00105   virtual bool ProcessVirtualPoint( const VirtualIndexType & virtualIndex,
00106                                     const VirtualPointType & virtualPoint,
00107                                     const ThreadIdType threadId );
00108 
00137   virtual bool ProcessPoint(
00138         const VirtualIndexType &          virtualIndex,
00139         const VirtualPointType &          virtualPoint,
00140         const FixedImagePointType &       mappedFixedPoint,
00141         const FixedImagePixelType &       mappedFixedPixelValue,
00142         const FixedImageGradientType &    mappedFixedImageGradient,
00143         const MovingImagePointType &      mappedMovingPoint,
00144         const MovingImagePixelType &      mappedMovingPixelValue,
00145         const MovingImageGradientType &   mappedMovingImageGradient,
00146         MeasureType &                     metricValueReturn,
00147         DerivativeType &                  localDerivativeReturn,
00148         const ThreadIdType                threadID ) const = 0;
00149 
00150 
00154   virtual void StorePointDerivativeResult( const VirtualIndexType & virtualIndex,
00155                                            const ThreadIdType threadID );
00156 
00158   mutable std::vector< InternalComputationValueType > m_MeasurePerThread;
00159   mutable std::vector< DerivativeType >               m_DerivativesPerThread;
00160   mutable std::vector< DerivativeType >               m_LocalDerivativesPerThread;
00161   mutable std::vector< SizeValueType >                m_NumberOfValidPointsPerThread;
00162 
00165   mutable std::vector< JacobianType >                 m_MovingTransformJacobianPerThread;
00166 
00167 private:
00168   ImageToImageMetricv4GetValueAndDerivativeThreaderBase( const Self & ); // purposely not implemented
00169   void operator=( const Self & ); // purposely not implemented
00170 };
00171 
00172 } // end namespace itk
00173 
00174 #ifndef ITK_MANUAL_INSTANTIATION
00175 #include "itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.hxx"
00176 #endif
00177 
00178 #endif
00179