ITK  5.2.0
Insight Toolkit
itkObjectToObjectOptimizerBase.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  * 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 itkObjectToObjectOptimizerBase_h
19 #define itkObjectToObjectOptimizerBase_h
20 
21 #include "ITKOptimizersv4Export.h"
22 
23 #include "itkOptimizerParameters.h"
26 #include "itkIntTypes.h"
27 
28 namespace itk
29 {
35 {
36 public:
43  {
51  };
52 };
53 // Define how to print enumeration
56 extern ITKOptimizersv4_EXPORT std::ostream &
57  operator<<(std::ostream & out,
59 
112 template <typename TInternalComputationValueType = double>
113 class ITK_TEMPLATE_EXPORT ObjectToObjectOptimizerBaseTemplate : public Object
114 {
115 public:
116  ITK_DISALLOW_COPY_AND_MOVE(ObjectToObjectOptimizerBaseTemplate);
117 
123 
126 
130 
133 
137 
140 
143 
145  using MeasureType = typename MetricType::MeasureType;
146 
148  using StopConditionReturnStringType = std::string;
149 
151  using StopConditionDescriptionType = std::ostringstream;
152 
154  itkSetObjectMacro(Metric, MetricType);
155  itkGetModifiableObjectMacro(Metric, MetricType);
157 
161  itkGetConstReferenceMacro(CurrentMetricValue, MeasureType);
162 
168  virtual const MeasureType &
169  GetValue() const;
170 
172  // itkSetMacro( Scales, ScalesType );
173  virtual void
174  SetScales(const ScalesType & scales)
175  {
176  this->m_Scales = scales;
177  }
179 
181  itkGetConstReferenceMacro(Scales, ScalesType);
182 
184  itkGetConstReferenceMacro(ScalesAreIdentity, bool);
185 
187  itkSetMacro(Weights, ScalesType);
188 
191  itkGetConstReferenceMacro(Weights, ScalesType);
192 
194  itkGetConstReferenceMacro(WeightsAreIdentity, bool);
195 
198  bool
199  GetScalesInitialized() const;
200 
210  itkSetObjectMacro(ScalesEstimator, ScalesEstimatorType);
211 
217  itkSetMacro(DoEstimateScales, bool);
218  itkGetConstReferenceMacro(DoEstimateScales, bool);
219  itkBooleanMacro(DoEstimateScales);
221 
225  virtual void
226  SetNumberOfWorkUnits(ThreadIdType number);
227 
228 #if !defined(ITK_LEGACY_REMOVE)
229 
232  itkLegacyMacro(virtual void SetNumberOfThreads(ThreadIdType number)) { return this->SetNumberOfWorkUnits(number); }
233  itkLegacyMacro(virtual const ThreadIdType & GetNumberOfThreads() const) { return this->m_NumberOfWorkUnits; }
234 #endif // !ITK_LEGACY_REMOVE
235 
236 
238  itkGetConstReferenceMacro(NumberOfWorkUnits, ThreadIdType);
239 
241  itkGetConstMacro(CurrentIteration, SizeValueType);
242 
244  itkSetMacro(NumberOfIterations, SizeValueType);
245 
247  itkGetConstMacro(NumberOfIterations, SizeValueType);
248 
252  virtual const ParametersType &
253  GetCurrentPosition() const;
254 
262  virtual void
263  StartOptimization(bool doOnlyInitialization = false);
264 
266  virtual const StopConditionReturnStringType
267  GetStopConditionDescription() const = 0;
268 
269 protected:
271  ObjectToObjectOptimizerBaseTemplate();
272  ~ObjectToObjectOptimizerBaseTemplate() override;
274 
279 
282 
286 
292 
295 
298 
301 
306 
307  void
308  PrintSelf(std::ostream & os, Indent indent) const override;
309 };
310 
313 
314 } // end namespace itk
315 
316 #endif
317 
319 #ifndef ITK_TEMPLATE_EXPLICIT_ObjectToObjectOptimizerBaseTemplate
320 // Explicit instantiation is required to ensure correct dynamic_cast
321 // behavior across shared libraries.
322 //
323 // IMPORTANT: Since within the same compilation unit,
324 // ITK_TEMPLATE_EXPLICIT_<classname> defined and undefined states
325 // need to be considered. This code *MUST* be *OUTSIDE* the header
326 // guards.
327 //
328 #if defined(ITKOptimizersv4_EXPORTS)
329 // We are building this library
330 # define ITKOptimizersv4_EXPORT_EXPLICIT ITK_FORWARD_EXPORT
331 #else
332 // We are using this library
333 # define ITKOptimizersv4_EXPORT_EXPLICIT ITKOptimizersv4_EXPORT
334 #endif
335 namespace itk
336 {
337 
338 ITK_GCC_PRAGMA_DIAG_PUSH()
339 ITK_GCC_PRAGMA_DIAG(ignored "-Wattributes")
340 
341 #if defined(_MSC_VER)
342 # pragma warning(disable : 4661) // no suitable definition provided for explicit template instantiation request
343 #endif
346 
347 ITK_GCC_PRAGMA_DIAG_POP()
348 
349 } // end namespace itk
350 #undef ITKOptimizersv4_EXPORT_EXPLICIT
351 #endif
itk::ObjectToObjectOptimizerBaseTemplateEnums
This class contains all the enum classes used by ObjectToObjectOptimizerBaseTemplate class.
Definition: itkObjectToObjectOptimizerBase.h:34
itk::OptimizerParameterScalesEstimatorTemplate
OptimizerParameterScalesEstimatorTemplate is the base class offering a empty method of estimating the...
Definition: itkOptimizerParameterScalesEstimator.h:39
itk::uint8_t
::uint8_t uint8_t
Definition: itkIntTypes.h:29
itk::ObjectToObjectOptimizerBaseTemplateEnums::StopConditionObjectToObjectOptimizer::MAXIMUM_NUMBER_OF_ITERATIONS
itk::OptimizerParameters< double >
itk::ObjectToObjectOptimizerBaseTemplate< float >
template class ITKOptimizersv4_EXPORT_EXPLICIT ObjectToObjectOptimizerBaseTemplate< float >
itk::ObjectToObjectOptimizerBaseTemplate::m_ScalesEstimator
ScalesEstimatorType::Pointer m_ScalesEstimator
Definition: itkObjectToObjectOptimizerBase.h:297
itk::operator<<
std::ostream & operator<<(std::ostream &os, const Array< TValue > &arr)
Definition: itkArray.h:218
itk::ObjectToObjectMetricBaseTemplate::NumberOfParametersType
unsigned int NumberOfParametersType
Definition: itkObjectToObjectMetricBase.h:176
itk::ObjectToObjectOptimizerBaseTemplate::SetScales
virtual void SetScales(const ScalesType &scales)
Definition: itkObjectToObjectOptimizerBase.h:174
itk::ObjectToObjectOptimizerBaseTemplate< double >::NumberOfParametersType
typename MetricType::NumberOfParametersType NumberOfParametersType
Definition: itkObjectToObjectOptimizerBase.h:142
itk::ObjectToObjectOptimizerBaseTemplate< double >
template class ITKOptimizersv4_EXPORT_EXPLICIT ObjectToObjectOptimizerBaseTemplate< double >
itk::ObjectToObjectOptimizerBaseTemplateEnums::StopConditionObjectToObjectOptimizer::CONVERGENCE_CHECKER_PASSED
itk::ObjectToObjectOptimizerBaseTemplate< double >::StopConditionReturnStringType
std::string StopConditionReturnStringType
Definition: itkObjectToObjectOptimizerBase.h:148
itk::ObjectToObjectOptimizerBaseTemplateEnums::StopConditionObjectToObjectOptimizer::GRADIENT_MAGNITUDE_TOLEARANCE
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ObjectToObjectOptimizerBaseTemplate::m_DoEstimateScales
bool m_DoEstimateScales
Definition: itkObjectToObjectOptimizerBase.h:305
itk::ObjectToObjectOptimizerBaseTemplate::m_NumberOfIterations
SizeValueType m_NumberOfIterations
Definition: itkObjectToObjectOptimizerBase.h:278
itk::ObjectToObjectOptimizerBaseTemplate::m_WeightsAreIdentity
bool m_WeightsAreIdentity
Definition: itkObjectToObjectOptimizerBase.h:300
StopConditionObjectToObjectOptimizer
itk::ObjectToObjectOptimizerBaseTemplateEnums::StopConditionObjectToObjectOptimizer::COSTFUNCTION_ERROR
itk::ObjectToObjectOptimizerBaseTemplate::m_Weights
ScalesType m_Weights
Definition: itkObjectToObjectOptimizerBase.h:291
itk::ThreadIdType
unsigned int ThreadIdType
Definition: itkIntTypes.h:99
itkOptimizerParameterScalesEstimator.h
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itkOptimizerParameters.h
itk::ObjectToObjectOptimizerBaseTemplate::m_Scales
ScalesType m_Scales
Definition: itkObjectToObjectOptimizerBase.h:285
itk::ObjectToObjectOptimizerBaseTemplateEnums::StopConditionObjectToObjectOptimizer
StopConditionObjectToObjectOptimizer
Definition: itkObjectToObjectOptimizerBase.h:42
itk::ObjectToObjectMetricBaseTemplate
Base class for all object-to-object similarity metrics added in ITKv4.
Definition: itkObjectToObjectMetricBase.h:90
itkIntTypes.h
ITKOptimizersv4_EXPORT_EXPLICIT
#define ITKOptimizersv4_EXPORT_EXPLICIT
Definition: itkObjectToObjectOptimizerBase.h:333
itk::ObjectToObjectOptimizerBaseTemplate< double >::DerivativeType
typename MetricType::DerivativeType DerivativeType
Definition: itkObjectToObjectOptimizerBase.h:139
itkObjectToObjectMetricBase.h
itk::ObjectToObjectOptimizerBaseTemplate< double >::MetricTypePointer
typename MetricType::Pointer MetricTypePointer
Definition: itkObjectToObjectOptimizerBase.h:136
itk::ObjectToObjectOptimizerBaseTemplateEnums::StopConditionObjectToObjectOptimizer::UPDATE_PARAMETERS_ERROR
itk::ObjectToObjectOptimizerBaseTemplate::m_ScalesAreIdentity
bool m_ScalesAreIdentity
Definition: itkObjectToObjectOptimizerBase.h:294
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ObjectToObjectOptimizerBaseTemplateEnums::StopConditionObjectToObjectOptimizer::OTHER_ERROR
itk::ObjectToObjectOptimizerBaseTemplate
Abstract base for object-to-object optimizers.
Definition: itkObjectToObjectOptimizerBase.h:113
itk::ObjectToObjectOptimizerBaseTemplate::m_NumberOfWorkUnits
ThreadIdType m_NumberOfWorkUnits
Definition: itkObjectToObjectOptimizerBase.h:276
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:62
itk::ObjectToObjectOptimizerBaseTemplate::m_CurrentIteration
SizeValueType m_CurrentIteration
Definition: itkObjectToObjectOptimizerBase.h:277
itk::ObjectToObjectOptimizerBaseTemplate< double >::StopConditionDescriptionType
std::ostringstream StopConditionDescriptionType
Definition: itkObjectToObjectOptimizerBase.h:151
itk::ObjectToObjectMetricBaseTemplate::DerivativeType
typename Superclass::DerivativeType DerivativeType
Definition: itkObjectToObjectMetricBase.h:112
itk::ObjectToObjectOptimizerBaseTemplate< double >::MeasureType
typename MetricType::MeasureType MeasureType
Definition: itkObjectToObjectOptimizerBase.h:145
itk::ObjectToObjectOptimizerBaseTemplateEnums::StopConditionObjectToObjectOptimizer::STEP_TOO_SMALL
itk::ObjectToObjectOptimizerBaseTemplate::m_Metric
MetricTypePointer m_Metric
Definition: itkObjectToObjectOptimizerBase.h:275
itk::StopConditionObjectToObjectOptimizerEnum
ObjectToObjectOptimizerBaseTemplateEnums::StopConditionObjectToObjectOptimizer StopConditionObjectToObjectOptimizerEnum
Definition: itkObjectToObjectOptimizerBase.h:55
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::ObjectToObjectOptimizerBaseTemplate::m_CurrentMetricValue
MeasureType m_CurrentMetricValue
Definition: itkObjectToObjectOptimizerBase.h:281