ITK  6.0.0
Insight Toolkit
itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * https://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkImageToImageMetricv4GetValueAndDerivativeThreaderBase_h
19 #define itkImageToImageMetricv4GetValueAndDerivativeThreaderBase_h
20 
21 #include "itkDomainThreader.h"
23 
24 #include <memory> // For unique_ptr.
25 
26 namespace itk
27 {
28 
45 template <typename TDomainPartitioner, typename TImageToImageMetricv4>
47  : public DomainThreader<TDomainPartitioner, TImageToImageMetricv4>
48 {
49 public:
51 
57 
58  itkOverrideGetNameOfClassMacro(ImageToImageMetricv4GetValueAndDerivativeThreaderBase);
59 
61  using typename Superclass::DomainType;
62  using typename Superclass::AssociateType;
63 
65  using ImageToImageMetricv4Type = TImageToImageMetricv4;
66  using VirtualImageType = typename ImageToImageMetricv4Type::VirtualImageType;
67  using VirtualIndexType = typename ImageToImageMetricv4Type::VirtualIndexType;
68  using VirtualPointType = typename ImageToImageMetricv4Type::VirtualPointType;
69  using FixedImagePointType = typename ImageToImageMetricv4Type::FixedImagePointType;
70  using FixedImagePixelType = typename ImageToImageMetricv4Type::FixedImagePixelType;
71  using FixedImageIndexType = typename ImageToImageMetricv4Type::FixedImageIndexType;
72  using FixedImageGradientType = typename ImageToImageMetricv4Type::FixedImageGradientType;
73  using MovingImagePointType = typename ImageToImageMetricv4Type::MovingImagePointType;
74  using MovingImagePixelType = typename ImageToImageMetricv4Type::MovingImagePixelType;
75  using MovingImageGradientType = typename ImageToImageMetricv4Type::MovingImageGradientType;
76 
77  using FixedTransformType = typename ImageToImageMetricv4Type::FixedTransformType;
78  using FixedOutputPointType = typename FixedTransformType::OutputPointType;
79  using MovingTransformType = typename ImageToImageMetricv4Type::MovingTransformType;
80  using MovingOutputPointType = typename MovingTransformType::OutputPointType;
81 
82  using MeasureType = typename ImageToImageMetricv4Type::MeasureType;
83  using DerivativeType = typename ImageToImageMetricv4Type::DerivativeType;
84  using DerivativeValueType = typename ImageToImageMetricv4Type::DerivativeValueType;
85  using JacobianType = typename ImageToImageMetricv4Type::JacobianType;
86  using ImageDimensionType = typename ImageToImageMetricv4Type::ImageDimensionType;
87 
88  using InternalComputationValueType = typename ImageToImageMetricv4Type::InternalComputationValueType;
89  using NumberOfParametersType = typename ImageToImageMetricv4Type::NumberOfParametersType;
90 
92  using CompensatedDerivativeType = std::vector<CompensatedDerivativeValueType>;
93 
95  virtual bool
96  GetComputeDerivative() const;
97 
98 protected:
101 
103  void
104  BeforeThreadedExecution() override;
105 
112  void
113  AfterThreadedExecution() override;
114 
120  virtual bool
121  ProcessVirtualPoint(const VirtualIndexType & virtualIndex,
122  const VirtualPointType & virtualPoint,
123  const ThreadIdType threadId);
124 
153  virtual bool
154  ProcessPoint(const VirtualIndexType & virtualIndex,
155  const VirtualPointType & virtualPoint,
156  const FixedImagePointType & mappedFixedPoint,
157  const FixedImagePixelType & mappedFixedPixelValue,
158  const FixedImageGradientType & mappedFixedImageGradient,
159  const MovingImagePointType & mappedMovingPoint,
160  const MovingImagePixelType & mappedMovingPixelValue,
161  const MovingImageGradientType & mappedMovingImageGradient,
162  MeasureType & metricValueReturn,
163  DerivativeType & localDerivativeReturn,
164  const ThreadIdType threadId) const = 0;
165 
166 
170  virtual void
171  StorePointDerivativeResult(const VirtualIndexType & virtualIndex, const ThreadIdType threadId);
172 
174  {
177 
180 
183 
186 
189 
194  };
195  itkPadStruct(ITK_CACHE_LINE_ALIGNMENT,
197  PaddedGetValueAndDerivativePerThreadStruct);
198  itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT,
199  PaddedGetValueAndDerivativePerThreadStruct,
200  AlignedGetValueAndDerivativePerThreadStruct);
201  std::unique_ptr<AlignedGetValueAndDerivativePerThreadStruct[]> m_GetValueAndDerivativePerThreadVariables;
206  mutable NumberOfParametersType m_CachedNumberOfParameters{};
207  mutable NumberOfParametersType m_CachedNumberOfLocalParameters{};
208 };
209 
210 } // end namespace itk
211 
212 #ifndef ITK_MANUAL_INSTANTIATION
213 # include "itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.hxx"
214 #endif
215 
216 #endif
itk::CompensatedSummation
Perform more precise accumulation of floating point numbers.
Definition: itkCompensatedSummation.h:66
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase
Provides threading for ImageToImageMetricv4::GetValueAndDerivative.
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:46
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >::ImageToImageMetricv4Type
TImageToImageMetricv4 ImageToImageMetricv4Type
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:65
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase::GetValueAndDerivativePerThreadStruct::CompensatedDerivatives
CompensatedDerivativeType CompensatedDerivatives
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:182
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase::GetValueAndDerivativePerThreadStruct::NumberOfValidPoints
SizeValueType NumberOfValidPoints
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:188
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >::ImageDimensionType
typename ImageToImageMetricv4Type::ImageDimensionType ImageDimensionType
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:86
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >::VirtualImageType
typename ImageToImageMetricv4Type::VirtualImageType VirtualImageType
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:66
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >::DerivativeValueType
typename ImageToImageMetricv4Type::DerivativeValueType DerivativeValueType
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:84
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >::MovingImagePointType
typename ImageToImageMetricv4Type::MovingImagePointType MovingImagePointType
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:73
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >::MovingImageGradientType
typename ImageToImageMetricv4Type::MovingImageGradientType MovingImageGradientType
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:75
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >::FixedImagePointType
typename ImageToImageMetricv4Type::FixedImagePointType FixedImagePointType
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:69
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase::GetValueAndDerivativePerThreadStruct::Measure
InternalComputationValueType Measure
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:176
itk::SmartPointer< Self >
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase::m_GetValueAndDerivativePerThreadVariables
std::unique_ptr< AlignedGetValueAndDerivativePerThreadStruct[]> m_GetValueAndDerivativePerThreadVariables
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:201
itkCompensatedSummation.h
itk::ThreadIdType
unsigned int ThreadIdType
Definition: itkIntTypes.h:102
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >::MovingTransformType
typename ImageToImageMetricv4Type::MovingTransformType MovingTransformType
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:79
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >::NumberOfParametersType
typename ImageToImageMetricv4Type::NumberOfParametersType NumberOfParametersType
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:89
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >::VirtualPointType
typename ImageToImageMetricv4Type::VirtualPointType VirtualPointType
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:68
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >::FixedImagePixelType
typename ImageToImageMetricv4Type::FixedImagePixelType FixedImagePixelType
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:70
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase::GetValueAndDerivativePerThreadStruct::Derivatives
DerivativeType Derivatives
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:179
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase::GetValueAndDerivativePerThreadStruct::MovingTransformJacobian
JacobianType MovingTransformJacobian
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:192
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >::FixedTransformType
typename ImageToImageMetricv4Type::FixedTransformType FixedTransformType
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:77
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >::MovingImagePixelType
typename ImageToImageMetricv4Type::MovingImagePixelType MovingImagePixelType
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:74
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase::GetValueAndDerivativePerThreadStruct::MovingTransformJacobianPositional
JacobianType MovingTransformJacobianPositional
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:193
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase::GetValueAndDerivativePerThreadStruct::LocalDerivatives
DerivativeType LocalDerivatives
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:185
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >::CompensatedDerivativeType
std::vector< CompensatedDerivativeValueType > CompensatedDerivativeType
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:92
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >::MovingOutputPointType
typename MovingTransformType::OutputPointType MovingOutputPointType
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:80
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >::DerivativeType
typename ImageToImageMetricv4Type::DerivativeType DerivativeType
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:83
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >::FixedImageGradientType
typename ImageToImageMetricv4Type::FixedImageGradientType FixedImageGradientType
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:72
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >::VirtualIndexType
typename ImageToImageMetricv4Type::VirtualIndexType VirtualIndexType
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:67
itk::DomainThreader
Multi-threaded processing on a domain by processing sub-domains per thread.
Definition: itkDomainThreader.h:66
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >::FixedImageIndexType
typename ImageToImageMetricv4Type::FixedImageIndexType FixedImageIndexType
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:71
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >::JacobianType
typename ImageToImageMetricv4Type::JacobianType JacobianType
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:85
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >::FixedOutputPointType
typename FixedTransformType::OutputPointType FixedOutputPointType
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:78
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase::GetValueAndDerivativePerThreadStruct
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:173
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >::MeasureType
typename ImageToImageMetricv4Type::MeasureType MeasureType
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:82
itkDomainThreader.h
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86
itk::ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, TImageToImageMetricv4 >::InternalComputationValueType
typename ImageToImageMetricv4Type::InternalComputationValueType InternalComputationValueType
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.h:88