ITK  5.2.0
Insight Toolkit
itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.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  * http://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 itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader_h
19 #define itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader_h
20 
22 
23 namespace itk
24 {
25 
32 template <typename TDomainPartitioner, typename TImageToImageMetric, typename TCorrelationMetric>
34  : public ImageToImageMetricv4GetValueAndDerivativeThreader<TDomainPartitioner, TImageToImageMetric>
35 {
36 public:
38 
44 
47 
48  itkNewMacro(Self);
49 
50  using DomainType = typename Superclass::DomainType;
51  using AssociateType = typename Superclass::AssociateType;
52 
53  using ImageToImageMetricv4Type = typename Superclass::ImageToImageMetricv4Type;
54  using VirtualIndexType = typename Superclass::VirtualIndexType;
55  using VirtualPointType = typename Superclass::VirtualPointType;
56  using FixedImagePointType = typename Superclass::FixedImagePointType;
57  using FixedImagePixelType = typename Superclass::FixedImagePixelType;
58  using FixedImageGradientType = typename Superclass::FixedImageGradientType;
59  using MovingImagePointType = typename Superclass::MovingImagePointType;
60  using MovingImagePixelType = typename Superclass::MovingImagePixelType;
61  using MovingImageGradientType = typename Superclass::MovingImageGradientType;
62  using MeasureType = typename Superclass::MeasureType;
63  using DerivativeType = typename Superclass::DerivativeType;
64  using DerivativeValueType = typename Superclass::DerivativeValueType;
65 
66  using FixedTransformType = typename ImageToImageMetricv4Type::FixedTransformType;
67  using FixedOutputPointType = typename FixedTransformType::OutputPointType;
68  using MovingTransformType = typename ImageToImageMetricv4Type::MovingTransformType;
69  using MovingOutputPointType = typename MovingTransformType::OutputPointType;
70 
71  using InternalComputationValueType = typename Superclass::InternalComputationValueType;
72  using NumberOfParametersType = typename Superclass::NumberOfParametersType;
73 
74 protected:
77 
83  void
84  BeforeThreadedExecution() override;
85 
93  void
94  AfterThreadedExecution() override;
95 
101  bool
102  ProcessVirtualPoint(const VirtualIndexType & virtualIndex,
103  const VirtualPointType & virtualPoint,
104  const ThreadIdType threadId) override;
105 
109  bool
110  ProcessPoint(const VirtualIndexType & virtualIndex,
111  const VirtualPointType & virtualPoint,
112  const FixedImagePointType & mappedFixedPoint,
113  const FixedImagePixelType & fixedImageValue,
114  const FixedImageGradientType & mappedFixedImageGradient,
115  const MovingImagePointType & mappedMovingPoint,
116  const MovingImagePixelType & movingImageValue,
117  const MovingImageGradientType & movingImageGradient,
118  MeasureType & metricValueReturn,
119  DerivativeType & localDerivativeReturn,
120  const ThreadIdType threadId) const override;
121 
122 private:
123  /*
124  * the per-thread memory for computing the correlation and its derivatives
125  * \bar f (CorrelationImageToImageMetricv4::m_AverageFix ) and
126  * \bar m (CorrelationImageToImageMetricv4::m_AverageMov ), the average pixel
127  * intensity, computed using the helper
128  * class CorrelationHelperImageToImageMetricv4GetValueAndDerivativeThreader.
129  * say f_i is the i-th pixel of fixed image, m_i is the i-th pixel of moving
130  * image: see the comments below
131  */
133  { // keep cumulative summation over points for:
134  InternalComputationValueType fm; // (f_i - \bar f) * (m_i - \bar m)
135  InternalComputationValueType m2; // (m_i - \bar m)^2
136  InternalComputationValueType f2; // (f_i - \bar m)^2
139  DerivativeType fdm; // (f_i - \bar f) * dm_i/dp
140  DerivativeType mdm; // (m_i - \bar m) * dm_i/dp
141  };
142 
143  itkPadStruct(ITK_CACHE_LINE_ALIGNMENT,
145  PaddedCorrelationMetricValueDerivativePerThreadStruct);
146  itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT,
147  PaddedCorrelationMetricValueDerivativePerThreadStruct,
148  AlignedCorrelationMetricValueDerivativePerThreadStruct);
149  /* per thread variables for correlation and its derivatives */
150  mutable AlignedCorrelationMetricValueDerivativePerThreadStruct * m_CorrelationMetricValueDerivativePerThreadVariables;
151 
154  TCorrelationMetric * m_CorrelationAssociate;
155 };
156 
157 } // end namespace itk
158 
159 #ifndef ITK_MANUAL_INSTANTIATION
160 # include "itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx"
161 #endif
162 
163 #endif
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::MovingOutputPointType
typename MovingTransformType::OutputPointType MovingOutputPointType
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:69
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::DerivativeType
typename Superclass::DerivativeType DerivativeType
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:63
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::CorrelationMetricValueDerivativePerThreadStruct::fm
InternalComputationValueType fm
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:134
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::MeasureType
typename Superclass::MeasureType MeasureType
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:62
itk::ImageToImageMetricv4GetValueAndDerivativeThreader
Provides threading for ImageToImageMetricv4::GetValueAndDerivative.
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreader.h:44
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::CorrelationMetricValueDerivativePerThreadStruct::f2
InternalComputationValueType f2
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:136
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::MovingImageGradientType
typename Superclass::MovingImageGradientType MovingImageGradientType
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:61
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader
Processes points for CorrelationImageToImageMetricv4 GetValueAndDerivative.
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:33
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::CorrelationMetricValueDerivativePerThreadStruct::f
InternalComputationValueType f
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:138
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::DomainType
typename Superclass::DomainType DomainType
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:50
itkImageToImageMetricv4GetValueAndDerivativeThreader.h
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::ImageToImageMetricv4Type
typename Superclass::ImageToImageMetricv4Type ImageToImageMetricv4Type
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:53
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::MovingTransformType
typename ImageToImageMetricv4Type::MovingTransformType MovingTransformType
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:68
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::NumberOfParametersType
typename Superclass::NumberOfParametersType NumberOfParametersType
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:72
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::FixedImagePointType
typename Superclass::FixedImagePointType FixedImagePointType
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:56
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::InternalComputationValueType
typename Superclass::InternalComputationValueType InternalComputationValueType
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:71
itk::SmartPointer< Self >
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::CorrelationMetricValueDerivativePerThreadStruct::m
InternalComputationValueType m
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:137
itk::ThreadIdType
unsigned int ThreadIdType
Definition: itkIntTypes.h:99
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::DerivativeValueType
typename Superclass::DerivativeValueType DerivativeValueType
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:64
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::VirtualPointType
typename Superclass::VirtualPointType VirtualPointType
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:55
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::CorrelationMetricValueDerivativePerThreadStruct
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:132
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::m_CorrelationAssociate
TCorrelationMetric * m_CorrelationAssociate
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:154
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::m_CorrelationMetricValueDerivativePerThreadVariables
AlignedCorrelationMetricValueDerivativePerThreadStruct * m_CorrelationMetricValueDerivativePerThreadVariables
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:150
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::CorrelationMetricValueDerivativePerThreadStruct::mdm
DerivativeType mdm
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:140
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::FixedImagePixelType
typename Superclass::FixedImagePixelType FixedImagePixelType
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:57
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::CorrelationMetricValueDerivativePerThreadStruct::fdm
DerivativeType fdm
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:139
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::FixedTransformType
typename ImageToImageMetricv4Type::FixedTransformType FixedTransformType
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:66
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::FixedImageGradientType
typename Superclass::FixedImageGradientType FixedImageGradientType
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:58
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::AssociateType
typename Superclass::AssociateType AssociateType
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:51
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::MovingImagePixelType
typename Superclass::MovingImagePixelType MovingImagePixelType
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:60
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::MovingImagePointType
typename Superclass::MovingImagePointType MovingImagePointType
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:59
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::CorrelationMetricValueDerivativePerThreadStruct::m2
InternalComputationValueType m2
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:135
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::VirtualIndexType
typename Superclass::VirtualIndexType VirtualIndexType
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:54
itk::CorrelationImageToImageMetricv4GetValueAndDerivativeThreader::FixedOutputPointType
typename FixedTransformType::OutputPointType FixedOutputPointType
Definition: itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:67