ITK  4.0.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::FixedImageGradientType  FixedImageGradientType;
00067   typedef typename ImageToImageMetricv4Type::MovingImagePointType    MovingImagePointType;
00068   typedef typename ImageToImageMetricv4Type::MovingImagePixelType    MovingImagePixelType;
00069   typedef typename ImageToImageMetricv4Type::MovingImageGradientType MovingImageGradientType;
00070 
00071   typedef typename ImageToImageMetricv4Type::FixedTransformType      FixedTransformType;
00072   typedef typename FixedTransformType::OutputPointType                   FixedOutputPointType;
00073   typedef typename ImageToImageMetricv4Type::MovingTransformType     MovingTransformType;
00074   typedef typename MovingTransformType::OutputPointType                  MovingOutputPointType;
00075 
00076   typedef typename ImageToImageMetricv4Type::MeasureType             MeasureType;
00077   typedef typename ImageToImageMetricv4Type::DerivativeType          DerivativeType;
00078   typedef typename ImageToImageMetricv4Type::DerivativeValueType     DerivativeValueType;
00079   typedef typename ImageToImageMetricv4Type::JacobianType            JacobianType;
00080 
00081   typedef typename ImageToImageMetricv4Type::InternalComputationValueType InternalComputationValueType;
00082   typedef typename ImageToImageMetricv4Type::NumberOfParametersType       NumberOfParametersType;
00083 
00084 protected:
00086   ImageToImageMetricv4GetValueAndDerivativeThreaderBase();
00087 
00089   virtual void BeforeThreadedExecution();
00090 
00097   virtual void AfterThreadedExecution();
00098 
00104   virtual bool ProcessVirtualPoint( const VirtualIndexType & virtualIndex,
00105                                     const VirtualPointType & virtualPoint,
00106                                     const ThreadIdType threadId );
00107 
00135   virtual bool ProcessPoint(
00136         const VirtualPointType &          virtualPoint,
00137         const FixedImagePointType &       mappedFixedPoint,
00138         const FixedImagePixelType &       mappedFixedPixelValue,
00139         const FixedImageGradientType &    mappedFixedImageGradient,
00140         const MovingImagePointType &      mappedMovingPoint,
00141         const MovingImagePixelType &      mappedMovingPixelValue,
00142         const MovingImageGradientType &   mappedMovingImageGradient,
00143         MeasureType &                     metricValueReturn,
00144         DerivativeType &                  localDerivativeReturn,
00145         const ThreadIdType                threadID ) const = 0;
00146 
00147 
00151   virtual void StorePointDerivativeResult( const VirtualIndexType & virtualIndex,
00152                                            const ThreadIdType threadID );
00153 
00155   mutable std::vector< InternalComputationValueType > m_MeasurePerThread;
00156   mutable std::vector< DerivativeType >               m_DerivativesPerThread;
00157   mutable std::vector< DerivativeType >               m_LocalDerivativesPerThread;
00158   mutable std::vector< SizeValueType >                m_NumberOfValidPointsPerThread;
00159 
00162   mutable std::vector< JacobianType >                 m_MovingTransformJacobianPerThread;
00163 
00164 private:
00165   ImageToImageMetricv4GetValueAndDerivativeThreaderBase( const Self & ); // purposely not implemented
00166   void operator=( const Self & ); // purposely not implemented
00167 };
00168 
00169 } // end namespace itk
00170 
00171 #ifndef ITK_MANUAL_INSTANTIATION
00172 #include "itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.hxx"
00173 #endif
00174 
00175 #endif
00176