ITK  5.4.0
Insight Toolkit
itkCorrelationImageToImageMetricv4HelperThreader.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 itkCorrelationImageToImageMetricv4HelperThreader_h
19 #define itkCorrelationImageToImageMetricv4HelperThreader_h
20 
22 
23 #include <memory> // For unique_ptr.
24 
25 namespace itk
26 {
27 
37 template <typename TDomainPartitioner, typename TImageToImageMetric, typename TCorrelationMetric>
39  : public ImageToImageMetricv4GetValueAndDerivativeThreader<TDomainPartitioner, TImageToImageMetric>
40 {
41 public:
42  ITK_DISALLOW_COPY_AND_MOVE(CorrelationImageToImageMetricv4HelperThreader);
43 
49 
50  itkOverrideGetNameOfClassMacro(CorrelationImageToImageMetricv4HelperThreader);
51 
52  itkNewMacro(Self);
53 
54  using typename Superclass::DomainType;
55  using typename Superclass::AssociateType;
56 
57  using ImageToImageMetricv4Type = typename Superclass::ImageToImageMetricv4Type;
58  using typename Superclass::VirtualIndexType;
59  using typename Superclass::VirtualPointType;
60  using typename Superclass::FixedImagePointType;
61  using typename Superclass::FixedImagePixelType;
62  using typename Superclass::FixedImageGradientType;
63  using typename Superclass::MovingImagePointType;
64  using typename Superclass::MovingImagePixelType;
65  using typename Superclass::MovingImageGradientType;
66  using typename Superclass::MeasureType;
67  using typename Superclass::DerivativeType;
68  using typename Superclass::DerivativeValueType;
69 
70  using typename Superclass::InternalComputationValueType;
71  using typename Superclass::NumberOfParametersType;
72 
73  using typename Superclass::FixedOutputPointType;
74  using typename Superclass::MovingOutputPointType;
75 
76 protected:
79 
81  void
82  BeforeThreadedExecution() override;
83 
91  void
92  AfterThreadedExecution() override;
93 
94 
95  /* Overload: don't need to compute the image gradients and store derivatives
96  *
97  * Method called by the threaders to process the given virtual point. This
98  * in turn calls \c TransformAndEvaluateFixedPoint, \c
99  * TransformAndEvaluateMovingPoint, and \c ProcessPoint.
100  */
101  bool
102  ProcessVirtualPoint(const VirtualIndexType & virtualIndex,
103  const VirtualPointType & virtualPoint,
104  const ThreadIdType threadId) override;
105 
106 
110  bool
111  ProcessPoint(const VirtualIndexType &,
112  const VirtualPointType &,
113  const FixedImagePointType &,
114  const FixedImagePixelType &,
115  const FixedImageGradientType &,
116  const MovingImagePointType &,
117  const MovingImagePixelType &,
118  const MovingImageGradientType &,
119  MeasureType &,
120  DerivativeType &,
121  const ThreadIdType) const override
122  {
123  return false;
124  }
125 
126 private:
128  {
129  InternalComputationValueType FixSum;
130  InternalComputationValueType MovSum;
131  };
132  itkPadStruct(ITK_CACHE_LINE_ALIGNMENT, CorrelationMetricPerThreadStruct, PaddedCorrelationMetricPerThreadStruct);
133  itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT,
134  PaddedCorrelationMetricPerThreadStruct,
135  AlignedCorrelationMetricPerThreadStruct);
136  /* per thread variables for correlation and its derivatives */
137  std::unique_ptr<AlignedCorrelationMetricPerThreadStruct[]> m_CorrelationMetricPerThreadVariables;
138 
141  TCorrelationMetric * m_CorrelationAssociate{};
142 };
143 
144 } // end namespace itk
145 
146 #ifndef ITK_MANUAL_INSTANTIATION
147 # include "itkCorrelationImageToImageMetricv4HelperThreader.hxx"
148 #endif
149 
150 #endif
itk::CorrelationImageToImageMetricv4HelperThreader::CorrelationMetricPerThreadStruct
Definition: itkCorrelationImageToImageMetricv4HelperThreader.h:127
itk::CorrelationImageToImageMetricv4HelperThreader::ImageToImageMetricv4Type
typename Superclass::ImageToImageMetricv4Type ImageToImageMetricv4Type
Definition: itkCorrelationImageToImageMetricv4HelperThreader.h:57
itk::ImageToImageMetricv4GetValueAndDerivativeThreader
Provides threading for ImageToImageMetricv4::GetValueAndDerivative.
Definition: itkImageToImageMetricv4GetValueAndDerivativeThreader.h:44
itk::CorrelationImageToImageMetricv4HelperThreader
Definition: itkCorrelationImageToImageMetricv4HelperThreader.h:38
itk::CorrelationImageToImageMetricv4HelperThreader::ProcessPoint
bool ProcessPoint(const VirtualIndexType &, const VirtualPointType &, const FixedImagePointType &, const FixedImagePixelType &, const FixedImageGradientType &, const MovingImagePointType &, const MovingImagePixelType &, const MovingImageGradientType &, MeasureType &, DerivativeType &, const ThreadIdType) const override
Definition: itkCorrelationImageToImageMetricv4HelperThreader.h:111
itkImageToImageMetricv4GetValueAndDerivativeThreader.h
itk::SmartPointer< Self >
itk::ThreadIdType
unsigned int ThreadIdType
Definition: itkIntTypes.h:99
itk::CorrelationImageToImageMetricv4HelperThreader::CorrelationMetricPerThreadStruct::MovSum
InternalComputationValueType MovSum
Definition: itkCorrelationImageToImageMetricv4HelperThreader.h:130
itk::CorrelationImageToImageMetricv4HelperThreader::m_CorrelationMetricPerThreadVariables
std::unique_ptr< AlignedCorrelationMetricPerThreadStruct[]> m_CorrelationMetricPerThreadVariables
Definition: itkCorrelationImageToImageMetricv4HelperThreader.h:137
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::CorrelationImageToImageMetricv4HelperThreader::CorrelationMetricPerThreadStruct::FixSum
InternalComputationValueType FixSum
Definition: itkCorrelationImageToImageMetricv4HelperThreader.h:129