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