ITK  4.3.0
Insight Segmentation and Registration Toolkit
itkMutualInformationImageToImageMetric.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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< class TFixedImage, class TMovingImage >
95  public ImageToImageMetric< TFixedImage, TMovingImage >
96 {
97 public:
98 
104 
106  itkNewMacro(Self);
107 
110 
112  typedef typename Superclass::TransformType TransformType;
113  typedef typename Superclass::TransformPointer TransformPointer;
114  typedef typename Superclass::TransformJacobianType TransformJacobianType;
115  typedef typename Superclass::InterpolatorType InterpolatorType;
116  typedef typename Superclass::MeasureType MeasureType;
117  typedef typename Superclass::DerivativeType DerivativeType;
118  typedef typename Superclass::ParametersType ParametersType;
119  typedef typename Superclass::FixedImageType FixedImageType;
120  typedef typename Superclass::MovingImageType MovingImageType;
121  typedef typename Superclass::FixedImageConstPointer FixedImageConstPointer;
122  typedef typename Superclass::MovingImageConstPointer MovingImageCosntPointer;
123 
125  typedef typename FixedImageType::IndexType FixedImageIndexType;
127  typedef typename MovingImageType::IndexType MovingImageIndexType;
130 
132 
134  itkStaticConstMacro(MovingImageDimension, unsigned int,
135  MovingImageType::ImageDimension);
136 
138  void GetDerivative(
139  const ParametersType & parameters,
140  DerivativeType & Derivative) const;
141 
143  MeasureType GetValue(const ParametersType & parameters) const;
144 
146  void GetValueAndDerivative(const ParametersType & parameters,
147  MeasureType & Value, DerivativeType & Derivative) const;
148 
153  void SetNumberOfSpatialSamples(unsigned int num);
154 
156  itkGetConstReferenceMacro(NumberOfSpatialSamples, unsigned int);
157 
163  itkSetClampMacro( MovingImageStandardDeviation, double,
165  itkGetConstReferenceMacro(MovingImageStandardDeviation, double);
167 
173  itkSetClampMacro( FixedImageStandardDeviation, double,
175  itkGetConstMacro(FixedImageStandardDeviation, double);
177 
180  itkSetObjectMacro(KernelFunction, KernelFunctionType);
181  itkGetObjectMacro(KernelFunction, KernelFunctionType);
183 
193  void ReinitializeSeed();
194 
195  void ReinitializeSeed(int);
196 
197 protected:
200  void PrintSelf(std::ostream & os, Indent indent) const;
201 
202 private:
203  MutualInformationImageToImageMetric(const Self &); //purposely not implemented
204  void operator=(const Self &); //purposely not implemented
205 
212  {
213 public:
214  SpatialSample():FixedImageValue(0.0), MovingImageValue(0.0)
215  { FixedImagePointValue.Fill(0.0); }
217 
221  };
222 
224  typedef std::vector< SpatialSample > SpatialSampleContainer;
225 
229 
233 
238 
240 
246  virtual void SampleFixedImageDomain(SpatialSampleContainer & samples) const;
247 
251  void CalculateDerivatives(const FixedImagePointType &, DerivativeType &, TransformJacobianType &) const;
252 
253  typedef typename Superclass::CoordinateRepresentationType
257 
259 
262 };
263 } // end namespace itk
264 
265 #ifndef ITK_MANUAL_INSTANTIATION
266 #include "itkMutualInformationImageToImageMetric.hxx"
267 #endif
268 
269 #endif
270