ITK  4.6.0
Insight Segmentation and Registration Toolkit
itkMattesMutualInformationImageToImageMetricv4.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 __itkMattesMutualInformationImageToImageMetricv4_h
19 #define __itkMattesMutualInformationImageToImageMetricv4_h
20 
23 #include "itkPoint.h"
24 #include "itkIndex.h"
26 #include "itkArray2D.h"
27 
28 namespace itk
29 {
30 
95 template <typename TFixedImage, typename TMovingImage, typename TVirtualImage = TFixedImage,
96  typename TInternalComputationValueType = double,
97  typename TMetricTraits = DefaultImageToImageMetricTraitsv4<TFixedImage,TMovingImage,TVirtualImage,TInternalComputationValueType>
98  >
100  public ImageToImageMetricv4<TFixedImage, TMovingImage, TVirtualImage, TInternalComputationValueType, TMetricTraits>
101 {
102 public:
105  typedef ImageToImageMetricv4<TFixedImage, TMovingImage, TVirtualImage,
106  TInternalComputationValueType,TMetricTraits> Superclass;
109 
111  itkNewMacro(Self);
112 
115 
117  typedef typename Superclass::MeasureType MeasureType;
119  typedef typename DerivativeType::ValueType DerivativeValueType;
120 
126 
130 
137 
140 
141  /* Image dimension accessors */
142  itkStaticConstMacro(VirtualImageDimension, ImageDimensionType, TVirtualImage::ImageDimension);
143  itkStaticConstMacro(FixedImageDimension, ImageDimensionType, TFixedImage::ImageDimension);
144  itkStaticConstMacro(MovingImageDimension, ImageDimensionType, TMovingImage::ImageDimension);
145 
151  itkSetClampMacro( NumberOfHistogramBins, SizeValueType, 5, NumericTraits<SizeValueType>::max() );
152  itkGetConstReferenceMacro(NumberOfHistogramBins, SizeValueType);
154 
155  virtual void Initialize(void) throw ( itk::ExceptionObject );
156 
158  //NOTE: floating point precision is not as stable.
159  // Double precision proves faster and more robust in real-world testing.
160  typedef TInternalComputationValueType PDFValueType;
161 
163  typedef Image<PDFValueType, 2> JointPDFType;
165 
170  const typename JointPDFType::Pointer GetJointPDF () const
171  {
172  if( this->m_ThreaderJointPDF.size() == 0 )
173  {
174  return typename JointPDFType::Pointer(ITK_NULLPTR);
175  }
176  return this->m_ThreaderJointPDF[0];
177  }
179 
187  {
188  if( this->m_ThreaderJointPDFDerivatives.size() == 0 )
189  {
190  return typename JointPDFDerivativesType::Pointer(ITK_NULLPTR);
191  }
192  return this->m_ThreaderJointPDFDerivatives[0];
193  }
195 
196 protected:
199 
201  friend class MattesMutualInformationImageToImageMetricv4GetValueAndDerivativeThreader< ThreadedIndexedContainerPartitioner, Superclass, Self >;
202  typedef MattesMutualInformationImageToImageMetricv4GetValueAndDerivativeThreader< ThreadedImageRegionPartitioner< Superclass::VirtualImageDimension >, Superclass, Self >
204  typedef MattesMutualInformationImageToImageMetricv4GetValueAndDerivativeThreader< ThreadedIndexedContainerPartitioner, Superclass, Self >
206 
207  void PrintSelf(std::ostream& os, Indent indent) const;
208 
217 
221 
225 
226  OffsetValueType ComputeSingleFixedImageParzenWindowIndex( const FixedImagePixelType & value ) const;
227 
238 
242 
245  typedef std::vector<PRatioType> PRatioArrayType;
246 
248 
251  mutable std::vector<OffsetValueType> m_JointPdfIndex1DArray;
252 
254  mutable std::vector<PDFValueType> m_MovingImageMarginalPDF;
255  mutable std::vector<std::vector<PDFValueType> > m_ThreaderFixedImageMarginalPDF;
256 
258  typename std::vector<typename JointPDFType::Pointer> m_ThreaderJointPDF;
259  typename std::vector<typename JointPDFDerivativesType::Pointer> m_ThreaderJointPDFDerivatives;
260 
261  std::vector<int> m_ThreaderJointPDFStartBin;
262  std::vector<int> m_ThreaderJointPDFEndBin;
263 
264  mutable std::vector<PDFValueType> m_ThreaderJointPDFSum;
265 
268  mutable std::vector<DerivativeType> m_LocalDerivativeByParzenBin;
269 
270 private:
271  MattesMutualInformationImageToImageMetricv4(const Self &); //purposely not implemented
272  void operator = (const Self &); //purposely not implemented
273 
275  virtual void ComputeResults( void ) const;
276 
277 };
278 
279 } // end namespace itk
280 
281 #ifndef ITK_MANUAL_INSTANTIATION
282 #include "itkMattesMutualInformationImageToImageMetricv4.hxx"
283 #endif
284 
285 #endif
Superclass::RegionType RegionType
Definition: itkImage.h:140
Superclass::VirtualPointSetType VirtualPointSetType
Light weight base class for most itk classes.
Superclass::JacobianType JacobianType
Superclass::MeasureType MeasureType
Superclass::VirtualIndexType VirtualIndexType
SmartPointer< Self > Pointer
Definition: itkImage.h:81
Represent the size (bounds) of a n-dimensional image.
Definition: itkSize.h:52
signed long OffsetValueType
Definition: itkIntTypes.h:154
Superclass::MovingTransformType MovingTransformType
ImageToImageMetricv4< TFixedImage, TMovingImage, TVirtualImage, TInternalComputationValueType, TMetricTraits > Superclass
Class for partitioning of an ImageRegion.
typedef(itk::Concept::IsFloatingPoint< FixedImagePixelValueType >) OnlyDefinedForFloatingPointTypes0
Superclass::DimensionType ImageDimensionType
MetricTraits::FixedImageGradientType FixedImageGradientType
unsigned long SizeValueType
Definition: itkIntTypes.h:143
TPixel PixelType
Definition: itkImage.h:89
Derivative of a BSpline kernel used for density estimation and nonparameteric regression.
BSpline kernel used for density estimation and nonparameteric regression.
OffsetValueType ComputeSingleFixedImageParzenWindowIndex(const FixedImagePixelType &value) const
FixedImageType::PixelType FixedImagePixelType
FixedImageType::IndexType FixedImageIndexType
Superclass::VirtualPointType VirtualPointType
Computes the mutual information between two images to be registered using the method of Mattes et al...
void PrintSelf(std::ostream &os, Indent indent) const
Superclass::DerivativeType DerivativeType
Superclass::IndexType IndexType
Definition: itkImage.h:122
Standard exception handling object.
MovingImageType::PixelType MovingImagePixelType
MovingImageType::PointType MovingImagePointType
MetricTraits::MovingImageGradientType MovingImageGradientType
FixedSampledPointSetType::Pointer FixedSampledPointSetPointer
Define additional traits for native types such as int or float.
FixedImageType::PointType FixedImagePointType
Templated n-dimensional image class.
Definition: itkImage.h:75
Superclass::VirtualImageType VirtualImageType
std::vector< typename JointPDFDerivativesType::Pointer > m_ThreaderJointPDFDerivatives