ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkBlockMatchingOptimizingInterpolationDisplacementCalculator.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 itkBlockMatchingOptimizingInterpolationDisplacementCalculator_h
19#define itkBlockMatchingOptimizingInterpolationDisplacementCalculator_h
20
22
24
26
27namespace itk
28{
29namespace BlockMatching
30{
31
45template <typename TMetricImage, typename TDisplacementImage, typename TCoordRep = double>
47 : public MetricImageToDisplacementCalculator<TMetricImage, TDisplacementImage>
48{
49public:
50 ITK_DISALLOW_COPY_AND_MOVE(OptimizingInterpolationDisplacementCalculator);
51
57
59 static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
60
62 itkNewMacro(Self);
63
65 itkOverrideGetNameOfClassMacro(OptimizingInterpolationDisplacementCalculator);
66
69 using PixelType = typename MetricImageType::PixelType;
70 using SpacingType = typename MetricImageType::SpacingType;
73
76 using ContinuousIndexType = typename InterpolatorType::ContinuousIndexType;
77
80
81 void
82 SetMetricImagePixel(const PointType & point, const IndexType & index, MetricImageType * image) override;
83
84 void
85 Compute() override
86 {
87 // We do this here instead of SetMetricImagePixel so it only has to be done
88 // once.
89 this->m_DisplacementImage->Modified();
90 };
91
93 virtual void
95 {
96 m_CostFunction->SetInterpolator(interpolator);
97 this->Modified();
98 }
99 InterpolatorType *
101 {
102 return m_CostFunction->GetInterpolator();
103 }
104
108 virtual void
110 {
111 m_Optimizer = optimizer;
112 m_Optimizer->SetCostFunction(m_CostFunction);
113 this->Modified();
114 }
115 itkGetConstObjectMacro(Optimizer, OptimizerType);
116
118
121 {
122 public:
125
127
128 itkOverrideGetNameOfClassMacro(OptimizingInterpolationCostFunction);
129
130 itkNewMacro(Self);
131
134 using MeasureType = Superclass::MeasureType;
135
138 using ParametersType = Superclass::ParametersType;
139
142 using DerivativeType = Superclass::DerivativeType;
143
147 GetValue(const ParametersType & parameters) const override;
148
151 void
152 GetDerivative(const ParametersType & parameters, DerivativeType & derivative) const override;
153
157 unsigned int
158 GetNumberOfParameters() const override
159 {
160 return ImageDimension;
161 }
162
165 void
166 Initialize(const ParametersType & parameters)
167 {
168 m_PreviousParameters = parameters;
169 this->m_PreviousParametersPtr = this->m_PreviousParameters.data_block();
170 }
171
172 itkSetObjectMacro(Interpolator, InterpolatorType);
173 itkGetConstObjectMacro(Interpolator, InterpolatorType);
174
175 typename InterpolatorType::Pointer m_Interpolator;
176
177 protected:
179
180 private:
182 ParametersType::ValueType * m_PreviousParametersPtr;
183
185 typename ContinuousIndexType::ValueType * m_ContinuousIndexPtr;
186 };
187
188protected:
190
193
194private:
195};
196
197
198} // namespace BlockMatching
199} // namespace itk
200
201#ifndef ITK_MANUAL_INSTANTIATION
202# include "itkBlockMatchingOptimizingInterpolationDisplacementCalculator.hxx"
203#endif
204
205#endif
void GetDerivative(const ParametersType &parameters, DerivativeType &derivative) const override
void SetMetricImagePixel(const PointType &point, const IndexType &index, MetricImageType *image) override
Base class for all image interpolators.
virtual void Modified() const
Generic representation for an optimization method.
This class is a base for the Optimization methods that optimize a single valued function.
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....