go home Home | Main Page | Topics | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkComputeDisplacementDistribution.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright UMC Utrecht and contributors
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 itkComputeDisplacementDistribution_h
19#define itkComputeDisplacementDistribution_h
20
22
23#include "itkImageGridSampler.h"
26#include "itkImageFullSampler.h"
27#include "itkMultiThreaderBase.h"
28
29#include <vector>
30
31namespace itk
32{
46
47template <typename TFixedImage, typename TTransform>
49{
50public:
52
56 using Pointer = SmartPointer<Self>;
57 using ConstPointer = SmartPointer<const Self>;
58
60 itkNewMacro(Self);
61
64
66 using FixedImageType = TFixedImage;
67 using FixedImagePixelType = typename TFixedImage::PixelType;
68 using TransformType = TTransform;
69 using TransformPointer = typename TTransform::Pointer;
70 using FixedImageRegionType = typename TFixedImage::RegionType;
71 using Superclass::ParametersType;
72 using Superclass::DerivativeType;
74
78 itkStaticConstMacro(FixedImageDimension, unsigned int, TFixedImage::ImageDimension);
79 using FixedImageMaskType = ImageMaskSpatialObject<Self::FixedImageDimension>;
80 using FixedImageMaskPointer = typename FixedImageMaskType::Pointer;
81 using FixedImageMaskConstPointer = typename FixedImageMaskType::ConstPointer;
82 using NonZeroJacobianIndicesType = typename TTransform::NonZeroJacobianIndicesType;
83
85 itkSetConstObjectMacro(FixedImage, TFixedImage);
86
88 itkSetObjectMacro(Transform, TTransform);
89
91 itkSetObjectMacro(FixedImageMask, FixedImageMaskType);
92 itkSetConstObjectMacro(FixedImageMask, FixedImageMaskType);
93 itkGetConstObjectMacro(FixedImageMask, FixedImageMaskType);
94
96 itkSetMacro(NumberOfJacobianMeasurements, SizeValueType);
97
99 void
101 {
102 m_FixedImageRegion = region;
103 }
104
105
107 itkGetConstReferenceMacro(FixedImageRegion, FixedImageRegionType);
108
110 virtual void
111 Compute(const ParametersType & mu, double & jacg, double & maxJJ, std::string method);
112
114 virtual void
115 ComputeSingleThreaded(const ParametersType & mu, double & jacg, double & maxJJ, std::string method);
116
117 virtual void
118 ComputeUsingSearchDirection(const ParametersType & mu, double & jacg, double & maxJJ, std::string methods);
119
121 void
122 SetNumberOfWorkUnits(ThreadIdType numberOfThreads)
123 {
124 m_Threader->SetNumberOfWorkUnits(numberOfThreads);
125 }
126
127
128 virtual void
129 BeforeThreadedCompute(const ParametersType & mu);
130
131 virtual void
132 AfterThreadedCompute(double & jacg, double & maxJJ);
133
134protected:
137
139 using ThreadInfoType = MultiThreaderBase::WorkUnitInfo;
140
141 typename TFixedImage::ConstPointer m_FixedImage{ nullptr };
147 DerivativeType m_ExactGradient{};
148 SizeValueType m_NumberOfParameters{};
149 MultiThreaderBase::Pointer m_Threader{ MultiThreaderBase::New() };
150
151 using FixedImageIndexType = typename TFixedImage::IndexType;
152 using FixedImagePointType = typename TFixedImage::PointType;
153 using JacobianType = typename TTransform::JacobianType;
154 using JacobianValueType = typename JacobianType::ValueType;
155
157
160 using CoordinateRepresentationType = typename TTransform::ScalarType;
161 using NumberOfParametersType = typename TTransform::NumberOfParametersType;
162
164 // \todo: note that this is an exact copy of itk::ComputeJacobianTerms
165 // in the future it would be better to refactoring this part of the code
166 std::vector<ImageSampleType>
168
170 void
172
174 static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
176
178 virtual void
179 ThreadedCompute(ThreadIdType threadID);
180
182 virtual void
184
198 itkPadStruct(ITK_CACHE_LINE_ALIGNMENT, ComputePerThreadStruct, PaddedComputePerThreadStruct);
199 itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT, PaddedComputePerThreadStruct, AlignedComputePerThreadStruct);
200
201private:
202 mutable MultiThreaderParameterType m_ThreaderParameters{};
203
204 mutable std::vector<AlignedComputePerThreadStruct> m_ComputePerThreadVariables{};
205
206 bool m_UseMultiThread{ true };
207 std::vector<ImageSampleType> m_Samples{};
208};
209
210} // end namespace itk
211
212#ifndef ITK_MANUAL_INSTANTIATION
213# include "itkComputeDisplacementDistribution.hxx"
214#endif
215
216#endif // end #ifndef itkComputeDisplacementDistribution_h
ScaledSingleValuedNonLinearOptimizer Superclass
typename TTransform::NumberOfParametersType NumberOfParametersType
virtual void Compute(const ParametersType &mu, double &jacg, double &maxJJ, std::string method)
typename FixedImageMaskType::Pointer FixedImageMaskPointer
virtual void ComputeSingleThreaded(const ParametersType &mu, double &jacg, double &maxJJ, std::string method)
itkOverrideGetNameOfClassMacro(ComputeDisplacementDistribution)
typename TTransform::ScalarType CoordinateRepresentationType
itkPadStruct(ITK_CACHE_LINE_ALIGNMENT, ComputePerThreadStruct, PaddedComputePerThreadStruct)
virtual void ThreadedCompute(ThreadIdType threadID)
itkStaticConstMacro(FixedImageDimension, unsigned int, TFixedImage::ImageDimension)
virtual void ComputeUsingSearchDirection(const ParametersType &mu, double &jacg, double &maxJJ, std::string methods)
itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT, PaddedComputePerThreadStruct, AlignedComputePerThreadStruct)
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION ComputeThreaderCallback(void *arg)
virtual void AfterThreadedCompute(double &jacg, double &maxJJ)
void SetFixedImageRegion(const FixedImageRegionType &region)
ITK_DISALLOW_COPY_AND_MOVE(ComputeDisplacementDistribution)
ImageMaskSpatialObject< Self::FixedImageDimension > FixedImageMaskType
~ComputeDisplacementDistribution() override=default
std::vector< ImageSampleType > SampleFixedImageForJacobianTerms() const
void SetNumberOfWorkUnits(ThreadIdType numberOfThreads)
typename FixedImageMaskType::ConstPointer FixedImageMaskConstPointer
virtual void BeforeThreadedCompute(const ParametersType &mu)
typename TTransform::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
A class that defines an image sample, which is the coordinates of a point and its value.


Generated on 26-02-2026 for elastix by doxygen 1.16.1 (669aeeefca743c148e2d935b3d3c69535c7491e6) elastix logo