ITK  4.2.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 #include "itkCompensatedSummation.h"
00023 
00024 namespace itk
00025 {
00026 
00043 template < class TDomainPartitioner, class TImageToImageMetricv4 >
00044 class ImageToImageMetricv4GetValueAndDerivativeThreaderBase
00045   : public DomainThreader< TDomainPartitioner, TImageToImageMetricv4 >
00046 {
00047 public:
00049   typedef ImageToImageMetricv4GetValueAndDerivativeThreaderBase       Self;
00050   typedef DomainThreader< TDomainPartitioner, TImageToImageMetricv4 > Superclass;
00051   typedef SmartPointer< Self >                                        Pointer;
00052   typedef SmartPointer< const Self >                                  ConstPointer;
00053 
00054   itkTypeMacro( ImageToImageMetricv4GetValueAndDerivativeThreaderBase, DomainThreader );
00055 
00057   typedef typename Superclass::DomainType    DomainType;
00058   typedef typename Superclass::AssociateType AssociateType;
00059 
00061   typedef TImageToImageMetricv4                                      ImageToImageMetricv4Type;
00062   typedef typename ImageToImageMetricv4Type::VirtualImageType        VirtualImageType;
00063   typedef typename ImageToImageMetricv4Type::VirtualIndexType        VirtualIndexType;
00064   typedef typename ImageToImageMetricv4Type::VirtualPointType        VirtualPointType;
00065   typedef typename ImageToImageMetricv4Type::FixedImagePointType     FixedImagePointType;
00066   typedef typename ImageToImageMetricv4Type::FixedImagePixelType     FixedImagePixelType;
00067   typedef typename ImageToImageMetricv4Type::FixedImageIndexType     FixedImageIndexType;
00068   typedef typename ImageToImageMetricv4Type::FixedImageGradientType  FixedImageGradientType;
00069   typedef typename ImageToImageMetricv4Type::MovingImagePointType    MovingImagePointType;
00070   typedef typename ImageToImageMetricv4Type::MovingImagePixelType    MovingImagePixelType;
00071   typedef typename ImageToImageMetricv4Type::MovingImageGradientType MovingImageGradientType;
00072 
00073   typedef typename ImageToImageMetricv4Type::FixedTransformType      FixedTransformType;
00074   typedef typename FixedTransformType::OutputPointType               FixedOutputPointType;
00075   typedef typename ImageToImageMetricv4Type::MovingTransformType     MovingTransformType;
00076   typedef typename MovingTransformType::OutputPointType              MovingOutputPointType;
00077 
00078   typedef typename ImageToImageMetricv4Type::MeasureType             MeasureType;
00079   typedef typename ImageToImageMetricv4Type::DerivativeType          DerivativeType;
00080   typedef typename ImageToImageMetricv4Type::DerivativeValueType     DerivativeValueType;
00081   typedef typename ImageToImageMetricv4Type::JacobianType            JacobianType;
00082   typedef typename ImageToImageMetricv4Type::ImageDimensionType      ImageDimensionType;
00083 
00084   typedef typename ImageToImageMetricv4Type::InternalComputationValueType InternalComputationValueType;
00085   typedef typename ImageToImageMetricv4Type::NumberOfParametersType       NumberOfParametersType;
00086 
00087   typedef CompensatedSummation<DerivativeValueType>                   CompensatedDerivativeValueType;
00088   typedef std::vector<CompensatedDerivativeValueType>                 CompensatedDerivativeType;
00089 
00090 protected:
00092   ImageToImageMetricv4GetValueAndDerivativeThreaderBase();
00093 
00095   virtual void BeforeThreadedExecution();
00096 
00103   virtual void AfterThreadedExecution();
00104 
00110   virtual bool ProcessVirtualPoint( const VirtualIndexType & virtualIndex,
00111                                     const VirtualPointType & virtualPoint,
00112                                     const ThreadIdType threadId );
00113 
00142   virtual bool ProcessPoint(
00143         const VirtualIndexType &          virtualIndex,
00144         const VirtualPointType &          virtualPoint,
00145         const FixedImagePointType &       mappedFixedPoint,
00146         const FixedImagePixelType &       mappedFixedPixelValue,
00147         const FixedImageGradientType &    mappedFixedImageGradient,
00148         const MovingImagePointType &      mappedMovingPoint,
00149         const MovingImagePixelType &      mappedMovingPixelValue,
00150         const MovingImageGradientType &   mappedMovingImageGradient,
00151         MeasureType &                     metricValueReturn,
00152         DerivativeType &                  localDerivativeReturn,
00153         const ThreadIdType                threadID ) const = 0;
00154 
00155 
00159   virtual void StorePointDerivativeResult( const VirtualIndexType & virtualIndex,
00160                                            const ThreadIdType threadID );
00161 
00163   mutable std::vector< InternalComputationValueType > m_MeasurePerThread;
00164 
00166   mutable std::vector< DerivativeType >               m_DerivativesPerThread;
00167 
00169   mutable std::vector< CompensatedDerivativeType >    m_CompensatedDerivativesPerThread;
00170 
00172   mutable std::vector< DerivativeType >               m_LocalDerivativesPerThread;
00173 
00175   mutable std::vector< SizeValueType >                m_NumberOfValidPointsPerThread;
00176 
00179   mutable std::vector< JacobianType >                 m_MovingTransformJacobianPerThread;
00180 
00181 private:
00182   ImageToImageMetricv4GetValueAndDerivativeThreaderBase( const Self & ); // purposely not implemented
00183   void operator=( const Self & ); // purposely not implemented
00184 };
00185 
00186 } // end namespace itk
00187 
00188 #ifndef ITK_MANUAL_INSTANTIATION
00189 #include "itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.hxx"
00190 #endif
00191 
00192 #endif
00193