ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkSingleImageCostFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkSingleImageCostFunction.h,v $
5  Language: C++
6  Date: $Date$
7  Version: $Revision$
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef itkSingleImageCostFunction_h
18 #define itkSingleImageCostFunction_h
19 
20 #include "itkNumericTraits.h"
21 #include "itkExceptionObject.h"
22 #include "itkContinuousIndex.h"
28 
29 namespace itk
30 {
31 
51 template <class TImage>
52 class ITK_EXPORT SingleImageCostFunction :
54 {
55 public:
56  ITK_DISALLOW_COPY_AND_ASSIGN(SingleImageCostFunction);
57 
63 
65  itkNewMacro(Self);
66 
69 
72  using MeasureType = typename Superclass::MeasureType;
73 
76  using DerivativeType = typename Superclass::DerivativeType;
77 
80  using ParametersType = typename Superclass::ParametersType;
81 
83  using ImageType = TImage;
84  using ImagePixelType = typename TImage::PixelType;
85  using ImageConstPointer = typename ImageType::ConstPointer;
86 
88  static constexpr unsigned int ImageDimension = ImageType::ImageDimension;
89 
91  using CoordRepType = Superclass::ParametersValueType;
92 
97 
101 
104 
106  itkSetObjectMacro( Interpolator, InterpolatorType );
107  itkGetConstObjectMacro( Interpolator, InterpolatorType );
109 
111  itkSetConstObjectMacro( Image, ImageType );
112  itkGetConstObjectMacro( Image, ImageType );
114 
116  virtual void Initialize(void) throw ( ExceptionObject );
117 
119  unsigned int GetNumberOfParameters(void) const override
120  { return ImageDimension; }
121 
124  MeasureType GetValue( const ParametersType & parameters ) const override;
125 
128  void GetDerivative( const ParametersType & parameters,
129  DerivativeType & derivative ) const override;
130 
131  // Set these depending on whether you will be minimizing or maximizing.
132  // They control the value returned when the point isn't inside the buffer.
133  void SetMinimize()
134  {
135  m_OutsideValue = itk::NumericTraits< ImagePixelType >::max();
136  }
137  void SetMaximize()
138  {
139  m_OutsideValue = itk::NumericTraits< ImagePixelType >::NonpositiveMin();
140  }
141 
142 
143 protected:
146  void PrintSelf(std::ostream& os, Indent indent) const override;
147 
148 private:
155 
156 };
157 
158 } // end namespace itk
159 
160 #ifndef ITK_MANUAL_INSTANTIATION
161 #include "itkSingleImageCostFunction.hxx"
162 #endif
163 
164 #endif
Array class with size defined at construction time.
Definition: itkArray.h:46
typename TImage::PixelType ImagePixelType
This class is a cost function which queries an underlying image for the single value.
This class is a base for the CostFunctions returning a single value.
Light weight base class for most itk classes.
Represent a n-dimensional index in a n-dimensional image.
Definition: itkIndex.h:66
Calculate the derivative by central differencing in physical space.
typename ImageType::ConstPointer ImageConstPointer
Standard exception handling object.
Superclass::ParametersValueType CoordRepType
GradientImageFunctionType::Pointer m_GradientImageFunction
Linearly interpolate an image at specified positions.
Base class for all image interpolaters.
A templated class holding a point in n-Dimensional image space.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
InterpolatorType::Pointer m_Interpolator
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:52
Templated n-dimensional image class.
Definition: itkImage.h:75