ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkPhaseCorrelationImageRegistrationMethod.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 itkPhaseCorrelationImageRegistrationMethod_h
19#define itkPhaseCorrelationImageRegistrationMethod_h
20
25#include "itkImage.h"
27#include "itkProcessObject.h"
32#include <cmath>
33#include <complex>
34
37
38namespace itk
39{
40
58
59extern Montage_EXPORT std::ostream &
61
129template <
130 typename TFixedImage,
131 typename TMovingImage,
132 typename TInternalPixelType =
133 typename std::conditional<std::is_same<typename TFixedImage::PixelType, double>::value, double, float>::type>
135{
136public:
137 ITK_DISALLOW_COPY_AND_MOVE(PhaseCorrelationImageRegistrationMethod);
138
144
146 itkNewMacro(Self);
147
149 itkOverrideGetNameOfClassMacro(PhaseCorrelationImageRegistrationMethod);
150
152 using FixedImageType = TFixedImage;
153 using FixedImagePixelType = typename FixedImageType::PixelType;
154 using FixedImageConstPointer = typename FixedImageType::ConstPointer;
155
157 using MovingImageType = TMovingImage;
158 using MovingImagePixelType = typename MovingImageType::PixelType;
159 using MovingImageConstPointer = typename MovingImageType::ConstPointer;
160
162 static constexpr unsigned int ImageDimension = FixedImageType::ImageDimension;
163
166
170 using InternalPixelType = TInternalPixelType;
171
174
177
181
185
189
192
198
201
203 void
204 SetFixedImage(const FixedImageType * fixedImage);
205 itkGetConstObjectMacro(FixedImage, FixedImageType);
206
208 void
209 SetMovingImage(const MovingImageType * movingImage);
210 itkGetConstObjectMacro(MovingImage, MovingImageType);
211
214
217
219 void
220 SetFixedImageFFT(const ComplexImageType * fixedImageFFT);
221
224 itkGetConstObjectMacro(FixedImageFFT, ComplexImageType);
225
227 void
228 SetMovingImageFFT(const ComplexImageType * movingImageFFT);
229
232 itkGetConstObjectMacro(MovingImageFFT, ComplexImageType);
233
235 void
236 SetReleaseDataFlag(bool flag) override;
237
239 void
240 SetReleaseDataBeforeUpdateFlag(const bool flag) override;
241
243 itkSetObjectMacro(Operator, OperatorType);
244 itkGetConstObjectMacro(Operator, OperatorType);
245
247 virtual void
249 itkGetConstObjectMacro(Optimizer, OptimizerType);
250
255
264 itkGetConstMacro(PadToSize, SizeType);
265
269 itkSetMacro(ObligatoryPadding, SizeType);
270 itkGetConstMacro(ObligatoryPadding, SizeType);
271
273 // itkGetConstMacro(PaddingMethod, PaddingMethodEnum);
274 void
276
282 itkSetMacro(CropToOverlap, bool);
283 itkGetConstMacro(CropToOverlap, bool);
284
287 itkSetMacro(ButterworthOrder, unsigned);
288 itkGetConstMacro(ButterworthOrder, unsigned);
289
293 virtual void
295 {
296 double f2 = f_Hz * f_Hz; // square of frequency
297 // we save per-pixel computation by recording the square
298 if (this->m_LowFrequency2 != f2)
299 {
300 this->m_LowFrequency2 = f2;
301 this->Modified();
302 }
303 }
304 virtual double
306 {
307 return std::sqrt(m_LowFrequency2);
308 }
309
313 virtual void
315 {
316 double f2 = f_Hz * f_Hz; // square of frequency
317 // we save per-pixel computation by recording the square
318 if (this->m_HighFrequency2 != f2)
319 {
320 this->m_HighFrequency2 = f2;
321 this->Modified();
322 }
323 }
324 virtual double
326 {
327 return std::sqrt(m_HighFrequency2);
328 }
329
336 virtual RealImageType *
338 {
339 itkDebugMacro("returning RealCorrelationSurface address " << this->m_IFFT->GetOutput());
340 if (m_IFFT.IsNotNull())
341 {
342 return m_IFFT->GetOutput();
343 }
344 else
345 {
346 return nullptr;
347 }
348 }
349 virtual ComplexConjugateImageType *
351 {
352 itkDebugMacro("returning ComplexCorrelationSurface address " << this->m_Operator->GetOutput());
353 if (m_Operator.IsNotNull())
354 {
355 return m_Operator->GetOutput();
356 }
357 else
358 {
359 return nullptr;
360 }
361 }
362
364 itkGetConstReferenceMacro(TransformParameters, ParametersType);
365
367 const TransformOutputType *
368 GetOutput() const;
369
371 const RealImageType *
373
376
378 virtual const OffsetVector &
380 {
381 return m_Optimizer->GetOffsets();
382 }
383
386
388 virtual const ConfidencesVector &
390 {
391 return m_Optimizer->GetConfidences();
392 }
393
394 static constexpr unsigned int MovingImageDimension = MovingImageType::ImageDimension;
395 static_assert(ImageDimension == MovingImageDimension);
396
397protected:
400 void
401 PrintSelf(std::ostream & os, Indent indent) const override;
402
404
409
411 virtual void
413
415 void
417
419 void
421
424 void
425 GenerateData() override;
426
428 void
430
432 itkSetMacro(TransformParameters, ParametersType);
433
434
448 using FrequencyFunctorType = std::function<typename BandBassFilterType::ValueFunctionType>;
449
454
455private:
458
461
462 typename ComplexImageType::Pointer m_FixedImageFFT = nullptr;
463 typename ComplexImageType::Pointer m_MovingImageFFT = nullptr;
464
468 PaddingMethodEnum m_PaddingMethod = PaddingMethodEnum::MirrorWithExponentialDecay;
469
481
482 bool m_CropToOverlap = true;
483 unsigned m_ButterworthOrder = 3;
484 double m_LowFrequency2 = 0.0004; // 0.02^2 // square of low frequency threshold
485 double m_HighFrequency2 = 0.09; // 0.3^2 // square of high frequency threshold
486
490};
491
492} // end namespace itk
493
494
495#ifndef ITK_MANUAL_INSTANTIATION
496# include "itkPhaseCorrelationImageRegistrationMethod.hxx"
497#endif
498
499#endif
Increase the image size by padding with a constant value.
Decorates any subclass of itkObject with a DataObject API.
SmartPointer< Self > Pointer
A multi-dimensional iterator templated over image type that walks pixels within a region and is speci...
Base class for specialized complex-to-real inverse Fast Fourier Transform.
Templated n-dimensional image class.
Definition itkImage.h:89
Control indentation during Print() invocation.
Definition itkIndent.h:53
static Pointer New()
Increase the image size by padding with replicants of the input image value.
virtual void Modified() const
Generic representation for an optimization method.
Increase the image size by padding. Superclass for filters that fill in extra pixels.
SizeType RoundUpToFFTSize(SizeType inSize)
void PrintSelf(std::ostream &os, Indent indent) const override
ConstantPadImageFilter< FixedImageType, RealImageType > FixedConstantPadderType
void SetMovingImageFFT(const ComplexImageType *movingImageFFT)
MirrorPadImageFilter< FixedImageType, RealImageType > FixedMirrorPadderType
ConstantPadImageFilter< MovingImageType, RealImageType > MovingConstantPadderType
Image< std::complex< InternalPixelType >, Self::ImageDimension > ComplexConjugateImageType
PhaseCorrelationOperator< InternalPixelType, ImageDimension > OperatorType
PadImageFilter< MovingImageType, RealImageType > MovingPadderImageFilter
typename TransformOutputType::ConstPointer TransformOutputConstPointer
void SetReleaseDataBeforeUpdateFlag(const bool flag) override
DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override
void SetMovingImage(const MovingImageType *movingImage)
MirrorPadImageFilter< MovingImageType, RealImageType > MovingMirrorPadderType
void SetFixedImage(const FixedImageType *fixedImage)
void SetFixedImageFFT(const ComplexImageType *fixedImageFFT)
TranslationTransform< typename MovingImageType::PointType::ValueType, ImageDimension > TransformType
~PhaseCorrelationImageRegistrationMethod() override=default
virtual void SetOptimizer(OptimizerType *)
std::function< typename BandBassFilterType::ValueFunctionType > FrequencyFunctorType
RealToHalfHermitianForwardFFTImageFilter< RealImageType > FFTFilterType
RegionOfInterestImageFilter< FixedImageType, FixedImageType > FixedRoIType
HalfHermitianToRealInverseFFTImageFilter< ComplexImageType, RealImageType > IFFTFilterType
void SetReleaseDataFlag(bool flag) override
const TransformOutputType * GetOutput() const
UnaryFrequencyDomainFilter< ComplexImageType, FrequencyHalfHermitianFFTLayoutImageRegionIteratorWithIndex< ComplexImageType > > BandBassFilterType
PhaseCorrelationImageRegistrationMethodEnums::PaddingMethod PaddingMethodEnum
PadImageFilter< FixedImageType, RealImageType > FixedPadderImageFilter
void SetPaddingMethod(const PaddingMethodEnum paddingMethod)
RegionOfInterestImageFilter< MovingImageType, MovingImageType > MovingRoIType
const RealImageType * GetPhaseCorrelationImage() const
PhaseCorrelationOptimizer< InternalPixelType, ImageDimension > OptimizerType
Computes the spectrum ratio in phase correlation method.
Defines common interface for optimizers, that estimates the shift from correlation surface.
std::vector< typename NumericTraits< typename ImageType::PixelType >::ValueType > ConfidenceVector
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx)
Make a DataObject of the correct type to used as the specified output.
Base class for specialized real-to-complex forward Fast Fourier Transform.
Image< std::complex< typename RealImageType::PixelType >, RealImageType::ImageDimension > OutputImageType
Extract a region of interest from the input image.
Implements transparent reference counting.
Translation transformation of a vector space (e.g. space coordinates)
Performs a unary operation on a frequency domain image.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, AnatomicalOrientation::CoordinateEnum value)
#define itkSetMacro(name, type)
Represent a n-dimensional size (bounds) of a n-dimensional image.
Definition itkSize.h:70