ITK  5.2.0
Insight Toolkit
itkMutualInformationImageToImageMetric.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 itkMutualInformationImageToImageMetric_h
19 #define itkMutualInformationImageToImageMetric_h
20 
21 #include "itkImageToImageMetric.h"
22 #include "itkPoint.h"
23 
24 #include "itkIndex.h"
25 #include "itkKernelFunctionBase.h"
26 
27 namespace itk
28 {
93 template <typename TFixedImage, typename TMovingImage>
94 class ITK_TEMPLATE_EXPORT MutualInformationImageToImageMetric : public ImageToImageMetric<TFixedImage, TMovingImage>
95 {
96 public:
97  ITK_DISALLOW_COPY_AND_ASSIGN(MutualInformationImageToImageMetric);
98 
104 
106  itkNewMacro(Self);
107 
110 
112  using TransformType = typename Superclass::TransformType;
113  using TransformPointer = typename Superclass::TransformPointer;
114  using TransformJacobianType = typename Superclass::TransformJacobianType;
115  using InterpolatorType = typename Superclass::InterpolatorType;
116  using MeasureType = typename Superclass::MeasureType;
117  using DerivativeType = typename Superclass::DerivativeType;
118  using ParametersType = typename Superclass::ParametersType;
119  using FixedImageType = typename Superclass::FixedImageType;
120  using MovingImageType = typename Superclass::MovingImageType;
121  using FixedImageConstPointer = typename Superclass::FixedImageConstPointer;
122  using MovingImageCosntPointer = typename Superclass::MovingImageConstPointer;
123 
130 
132 
134  static constexpr unsigned int MovingImageDimension = MovingImageType::ImageDimension;
135 
137  void
138  GetDerivative(const ParametersType & parameters, DerivativeType & Derivative) const override;
139 
142  GetValue(const ParametersType & parameters) const override;
143 
145  void
146  GetValueAndDerivative(const ParametersType & parameters,
147  MeasureType & Value,
148  DerivativeType & Derivative) const override;
149 
154  void
155  SetNumberOfSpatialSamples(unsigned int num);
156 
158  itkGetConstReferenceMacro(NumberOfSpatialSamples, unsigned int);
159 
165  itkSetClampMacro(MovingImageStandardDeviation,
166  double,
169  itkGetConstReferenceMacro(MovingImageStandardDeviation, double);
171 
177  itkSetClampMacro(FixedImageStandardDeviation,
178  double,
181  itkGetConstMacro(FixedImageStandardDeviation, double);
183 
186  itkSetObjectMacro(KernelFunction, KernelFunctionType);
187  itkGetModifiableObjectMacro(KernelFunction, KernelFunctionType);
189 
190 
191 protected:
193  ~MutualInformationImageToImageMetric() override = default;
194  void
195  PrintSelf(std::ostream & os, Indent indent) const override;
196 
197 private:
204  {
205  public:
206  SpatialSample() { FixedImagePointValue.Fill(0.0); }
207  ~SpatialSample() = default;
208 
210  double FixedImageValue{ 0.0 };
211  double MovingImageValue{ 0.0 };
212  };
213 
215  using SpatialSampleContainer = std::vector<SpatialSample>;
216 
220 
224 
229 
231 
237  virtual void
238  SampleFixedImageDomain(SpatialSampleContainer & samples) const;
239 
243  void
244  CalculateDerivatives(const FixedImagePointType &, DerivativeType &, TransformJacobianType &) const;
245 
246  using CoordinateRepresentationType = typename Superclass::CoordinateRepresentationType;
248 
250 };
251 } // end namespace itk
252 
253 #ifndef ITK_MANUAL_INSTANTIATION
254 # include "itkMutualInformationImageToImageMetric.hxx"
255 #endif
256 
257 #endif
itk::ImageToImageMetric::FixedImageConstPointer
typename FixedImageType::ConstPointer FixedImageConstPointer
Definition: itkImageToImageMetric.h:77
itk::ImageToImageMetric
Computes similarity between regions of two images.
Definition: itkImageToImageMetric.h:52
itk::SingleValuedCostFunction::MeasureType
double MeasureType
Definition: itkSingleValuedCostFunction.h:50
itk::OptimizerParameters< TInternalComputationValueType >
itk::ImageToImageMetric::MovingImageIndexType
typename MovingImageType::IndexType MovingImageIndexType
Definition: itkImageToImageMetric.h:96
itk::ImageToImageMetric::FixedImagePointType
typename TransformType::InputPointType FixedImagePointType
Definition: itkImageToImageMetric.h:97
itk::ImageToImageMetric::FixedImageIndexValueType
typename FixedImageIndexType::IndexValueType FixedImageIndexValueType
Definition: itkImageToImageMetric.h:95
itkPoint.h
itk::ImageToImageMetric::TransformJacobianType
typename TransformType::JacobianType TransformJacobianType
Definition: itkImageToImageMetric.h:91
itk::CentralDifferenceImageFunction
Calculate the derivative by central differencing.
Definition: itkCentralDifferenceImageFunction.h:76
itk::KernelFunctionBase< double >
itk::ImageToImageMetric::MovingImagePointType
typename TransformType::OutputPointType MovingImagePointType
Definition: itkImageToImageMetric.h:98
itk::MutualInformationImageToImageMetric::SpatialSample::SpatialSample
SpatialSample()
Definition: itkMutualInformationImageToImageMetric.h:206
itkKernelFunctionBase.h
itk::ImageToImageMetric::FixedImageType
TFixedImage FixedImageType
Definition: itkImageToImageMetric.h:75
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::MutualInformationImageToImageMetric::SpatialSample::FixedImagePointValue
FixedImagePointType FixedImagePointValue
Definition: itkMutualInformationImageToImageMetric.h:209
itk::MutualInformationImageToImageMetric
Computes the mutual information between two images to be registered.
Definition: itkMutualInformationImageToImageMetric.h:94
itk::MutualInformationImageToImageMetric::m_SampleA
SpatialSampleContainer m_SampleA
Definition: itkMutualInformationImageToImageMetric.h:219
itk::MutualInformationImageToImageMetric::m_DerivativeCalculator
DerivativeFunctionType::Pointer m_DerivativeCalculator
Definition: itkMutualInformationImageToImageMetric.h:249
itk::MutualInformationImageToImageMetric::SpatialSample
Definition: itkMutualInformationImageToImageMetric.h:203
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itkImageToImageMetric.h
itk::MutualInformationImageToImageMetric::m_FixedImageStandardDeviation
double m_FixedImageStandardDeviation
Definition: itkMutualInformationImageToImageMetric.h:227
itk::MutualInformationImageToImageMetric::m_SampleB
SpatialSampleContainer m_SampleB
Definition: itkMutualInformationImageToImageMetric.h:223
itk::MutualInformationImageToImageMetric::m_NumberOfSpatialSamples
unsigned int m_NumberOfSpatialSamples
Definition: itkMutualInformationImageToImageMetric.h:225
itk::MutualInformationImageToImageMetric::m_MinProbability
double m_MinProbability
Definition: itkMutualInformationImageToImageMetric.h:228
itkIndex.h
itk::MutualInformationImageToImageMetric::m_KernelFunction
KernelFunctionType::Pointer m_KernelFunction
Definition: itkMutualInformationImageToImageMetric.h:230
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:58
itk::ImageToImageMetric::TransformPointer
typename TransformType::Pointer TransformPointer
Definition: itkImageToImageMetric.h:87
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::MutualInformationImageToImageMetric::m_MovingImageStandardDeviation
double m_MovingImageStandardDeviation
Definition: itkMutualInformationImageToImageMetric.h:226
itk::ImageToImageMetric::MovingImageType
TMovingImage MovingImageType
Definition: itkImageToImageMetric.h:70
itk::IndexValueType
signed long IndexValueType
Definition: itkIntTypes.h:90
itk::Array
Array class with size defined at construction time.
Definition: itkArray.h:47
itk::Point
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:53
itk::Transform
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:82
itk::ImageToImageMetric::FixedImageIndexType
typename FixedImageType::IndexType FixedImageIndexType
Definition: itkImageToImageMetric.h:94
itk::MutualInformationImageToImageMetric::MovingImageCosntPointer
typename Superclass::MovingImageConstPointer MovingImageCosntPointer
Definition: itkMutualInformationImageToImageMetric.h:122
itk::ImageToImageMetric::CoordinateRepresentationType
typename Superclass::ParametersValueType CoordinateRepresentationType
Definition: itkImageToImageMetric.h:64
itk::InterpolateImageFunction
Base class for all image interpolators.
Definition: itkInterpolateImageFunction.h:45
itk::MutualInformationImageToImageMetric::SpatialSampleContainer
std::vector< SpatialSample > SpatialSampleContainer
Definition: itkMutualInformationImageToImageMetric.h:215