OTB  9.0.0
Orfeo Toolbox
otbFineRegistrationImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbFineRegistrationImageFilter_h
22 #define otbFineRegistrationImageFilter_h
23 
24 #include "itkImageToImageFilter.h"
25 #include "itkInterpolateImageFunction.h"
26 #include "itkContinuousIndex.h"
27 
28 #include "itkTranslationTransform.h"
29 #include "itkImageToImageMetric.h"
30 
31 namespace otb
32 {
33 
73 template <class TInputImage, class T0utputCorrelation, class TOutputDisplacementField>
74 class ITK_EXPORT FineRegistrationImageFilter : public itk::ImageToImageFilter<TInputImage, T0utputCorrelation>
75 {
76 public:
79  typedef itk::ImageToImageFilter<TInputImage, T0utputCorrelation> Superclass;
80  typedef itk::SmartPointer<Self> Pointer;
81  typedef itk::SmartPointer<const Self> ConstPointer;
82 
84  itkNewMacro(Self);
85 
87  itkTypeMacro(FineRegistrationImageFilter, ImageToImageFilter);
88 
90  typedef typename T0utputCorrelation::RegionType OutputImageRegionType;
91  typedef typename TOutputDisplacementField::PixelType DisplacementValueType;
92  typedef typename TInputImage::Pointer InputImagePointerType;
93  typedef typename TInputImage::RegionType InputImageRegionType;
94  typedef typename TInputImage::SizeType SizeType;
95  typedef typename TInputImage::IndexType IndexType;
96  typedef typename TInputImage::SpacingType SpacingType;
97  typedef typename TInputImage::PointType PointType;
98  typedef typename TInputImage::OffsetType OffsetType;
99  typedef itk::InterpolateImageFunction<TInputImage, double> InterpolatorType;
100  typedef typename InterpolatorType::Pointer InterpolatorPointerType;
101  typedef itk::ContinuousIndex<double, 2> ContinuousIndexType;
102  typedef itk::ImageToImageMetric<TInputImage, TInputImage> MetricType;
103  typedef typename MetricType::Pointer MetricPointerType;
104  typedef itk::TranslationTransform<double, 2> TranslationType;
105  typedef typename TranslationType::Pointer TranslationPointerType;
106  typedef typename itk::Transform<double, 2, 2> TransformType;
107  typedef typename TransformType::Pointer TransformPointerType;
108 
110  itkSetObjectMacro(Metric, MetricType);
111  itkGetObjectMacro(Metric, MetricType);
113 
115  itkSetObjectMacro(Interpolator, InterpolatorType);
116  itkGetObjectMacro(Interpolator, InterpolatorType);
118 
120  void SetFixedInput(const TInputImage* image);
121 
123  void SetMovingInput(const TInputImage* image);
124 
126  const TInputImage* GetFixedInput();
127  const TInputImage* GetMovingInput();
129 
131  TOutputDisplacementField* GetOutputDisplacementField();
132 
134  itkSetMacro(Radius, SizeType);
135  itkGetMacro(Radius, SizeType);
137 
139  itkSetMacro(SearchRadius, SizeType);
140  itkGetMacro(SearchRadius, SizeType);
142 
144  itkSetMacro(ConvergenceAccuracy, double);
145  itkGetMacro(ConvergenceAccuracy, double);
147 
149  itkSetMacro(SubPixelAccuracy, double);
150  itkGetMacro(SubPixelAccuracy, double);
152 
154  itkSetMacro(MaxIter, int);
155  itkGetMacro(MaxIter, int);
157 
159  itkSetMacro(Minimize, bool);
160  itkBooleanMacro(Minimize);
162 
164  itkSetMacro(UseSpacing, bool);
165  itkBooleanMacro(UseSpacing);
167 
169  itkSetMacro(InitialOffset, SpacingType);
170  itkGetConstReferenceMacro(InitialOffset, SpacingType);
172 
174  itkSetMacro(GridStep, OffsetType);
175  itkGetConstReferenceMacro(GridStep, OffsetType);
177 
179  void SetRadius(unsigned int radius)
180  {
181  m_Radius.Fill(radius);
182  }
183 
185  void SetSearchRadius(unsigned int radius)
186  {
187  m_SearchRadius.Fill(radius);
188  }
189 
191  void SetGridStep(unsigned int step)
192  {
193  m_GridStep.Fill(step);
194  }
195 
197  itkSetObjectMacro(Transform, TransformType);
198  itkGetConstObjectMacro(Transform, TransformType);
200 
201 protected:
204 
207 
209  void GenerateData() override;
210 
212  void GenerateInputRequestedRegion(void) override;
213 
215  void GenerateOutputInformation(void) override;
216 
217 private:
218  FineRegistrationImageFilter(const Self&) = delete;
219  void operator=(const Self&) = delete;
220 
221  inline double callMetric(double val1, double val2, double& oldRes, bool& flag);
222  inline void updateOptParams(double potBestVal, double parx, double pary, // inputs
223  double& bestVal, typename TranslationType::ParametersType& optParams); // outputs
224  inline void updatePoints(double& gn, double& in1, double& in2, double& in3, // inputs
225  double& out1, double& out2, double& out3, double& out4); // outputs
226  inline void updateMinimize(double& a, double& b);
227 
230 
233 
236 
239 
243 
246 
249 
252 
255 
258 
261 
264 };
265 
266 } // end namespace otb
267 
268 #ifndef OTB_MANUAL_INSTANTIATION
270 #endif
271 
272 #endif
otb::FineRegistrationImageFilter::Self
FineRegistrationImageFilter Self
Definition: otbFineRegistrationImageFilter.h:78
otb::FineRegistrationImageFilter::SizeType
TInputImage::SizeType SizeType
Definition: otbFineRegistrationImageFilter.h:94
otb::FineRegistrationImageFilter::m_InitialOffset
SpacingType m_InitialOffset
Definition: otbFineRegistrationImageFilter.h:257
otb::FineRegistrationImageFilter::m_MaxIter
int m_MaxIter
Definition: otbFineRegistrationImageFilter.h:245
otb::FineRegistrationImageFilter::ContinuousIndexType
itk::ContinuousIndex< double, 2 > ContinuousIndexType
Definition: otbFineRegistrationImageFilter.h:101
otb::FineRegistrationImageFilter::MetricType
itk::ImageToImageMetric< TInputImage, TInputImage > MetricType
Definition: otbFineRegistrationImageFilter.h:102
otb::FineRegistrationImageFilter::TransformType
itk::Transform< double, 2, 2 > TransformType
Definition: otbFineRegistrationImageFilter.h:106
otb::FineRegistrationImageFilter::m_Interpolator
InterpolatorPointerType m_Interpolator
Definition: otbFineRegistrationImageFilter.h:248
otb::FineRegistrationImageFilter::PointType
TInputImage::PointType PointType
Definition: otbFineRegistrationImageFilter.h:97
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::FineRegistrationImageFilter::m_SubPixelAccuracy
double m_SubPixelAccuracy
Definition: otbFineRegistrationImageFilter.h:242
otb::FineRegistrationImageFilter::DisplacementValueType
TOutputDisplacementField::PixelType DisplacementValueType
Definition: otbFineRegistrationImageFilter.h:91
otb::FineRegistrationImageFilter::OffsetType
TInputImage::OffsetType OffsetType
Definition: otbFineRegistrationImageFilter.h:98
otb::FineRegistrationImageFilter::m_GridStep
OffsetType m_GridStep
Definition: otbFineRegistrationImageFilter.h:260
otb::FineRegistrationImageFilter::~FineRegistrationImageFilter
~FineRegistrationImageFilter() override
Definition: otbFineRegistrationImageFilter.h:206
otb::FineRegistrationImageFilter::TransformPointerType
TransformType::Pointer TransformPointerType
Definition: otbFineRegistrationImageFilter.h:107
otb::FineRegistrationImageFilter::m_Translation
TranslationPointerType m_Translation
Definition: otbFineRegistrationImageFilter.h:254
otb::Transform
Class to overload method passed to virtual pure in ITK V4.
Definition: otbTransform.h:39
otb::FineRegistrationImageFilter::m_ConvergenceAccuracy
double m_ConvergenceAccuracy
Definition: otbFineRegistrationImageFilter.h:241
otb::FineRegistrationImageFilter::SetSearchRadius
void SetSearchRadius(unsigned int radius)
Definition: otbFineRegistrationImageFilter.h:185
otb::FineRegistrationImageFilter::InputImageRegionType
TInputImage::RegionType InputImageRegionType
Definition: otbFineRegistrationImageFilter.h:93
otb::FineRegistrationImageFilter::m_Radius
SizeType m_Radius
Definition: otbFineRegistrationImageFilter.h:229
otb::FineRegistrationImageFilter::SetRadius
void SetRadius(unsigned int radius)
Definition: otbFineRegistrationImageFilter.h:179
otb::FineRegistrationImageFilter::InterpolatorPointerType
InterpolatorType::Pointer InterpolatorPointerType
Definition: otbFineRegistrationImageFilter.h:100
otb::FineRegistrationImageFilter::TranslationPointerType
TranslationType::Pointer TranslationPointerType
Definition: otbFineRegistrationImageFilter.h:105
otb::FineRegistrationImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbFineRegistrationImageFilter.h:80
otb::FineRegistrationImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbFineRegistrationImageFilter.h:81
otb::FineRegistrationImageFilter::Superclass
itk::ImageToImageFilter< TInputImage, T0utputCorrelation > Superclass
Definition: otbFineRegistrationImageFilter.h:79
otb::FineRegistrationImageFilter::SetGridStep
void SetGridStep(unsigned int step)
Definition: otbFineRegistrationImageFilter.h:191
otb::FineRegistrationImageFilter::OutputImageRegionType
T0utputCorrelation::RegionType OutputImageRegionType
Definition: otbFineRegistrationImageFilter.h:87
otbFineRegistrationImageFilter.hxx
otb::FineRegistrationImageFilter::m_SearchRadius
SizeType m_SearchRadius
Definition: otbFineRegistrationImageFilter.h:232
otb::FineRegistrationImageFilter::m_Minimize
bool m_Minimize
Definition: otbFineRegistrationImageFilter.h:235
otb::FineRegistrationImageFilter::InputImagePointerType
TInputImage::Pointer InputImagePointerType
Definition: otbFineRegistrationImageFilter.h:92
otb::FineRegistrationImageFilter::m_UseSpacing
bool m_UseSpacing
Definition: otbFineRegistrationImageFilter.h:238
otb::FineRegistrationImageFilter::m_Transform
TransformPointerType m_Transform
Definition: otbFineRegistrationImageFilter.h:263
otb::FineRegistrationImageFilter::m_Metric
MetricPointerType m_Metric
Definition: otbFineRegistrationImageFilter.h:251
otb::FineRegistrationImageFilter::TranslationType
itk::TranslationTransform< double, 2 > TranslationType
Definition: otbFineRegistrationImageFilter.h:104
otb::FineRegistrationImageFilter
Computes a displacement field between two images using a given metric.
Definition: otbFineRegistrationImageFilter.h:74
otb::FineRegistrationImageFilter::SpacingType
TInputImage::SpacingType SpacingType
Definition: otbFineRegistrationImageFilter.h:96
otb::FineRegistrationImageFilter::MetricPointerType
MetricType::Pointer MetricPointerType
Definition: otbFineRegistrationImageFilter.h:103
otb::FineRegistrationImageFilter::IndexType
TInputImage::IndexType IndexType
Definition: otbFineRegistrationImageFilter.h:95
otb::FineRegistrationImageFilter::InterpolatorType
itk::InterpolateImageFunction< TInputImage, double > InterpolatorType
Definition: otbFineRegistrationImageFilter.h:99