ITK  4.8.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"
28 
29 namespace itk
30 {
31 
96 template <typename TFixedImage, typename TMovingImage, typename TVirtualImage = TFixedImage,
97  typename TInternalComputationValueType = double,
98  typename TMetricTraits = DefaultImageToImageMetricTraitsv4<TFixedImage,TMovingImage,TVirtualImage,TInternalComputationValueType>
99  >
101  public ImageToImageMetricv4<TFixedImage, TMovingImage, TVirtualImage, TInternalComputationValueType, TMetricTraits>
102 {
103 public:
106  typedef ImageToImageMetricv4<TFixedImage, TMovingImage, TVirtualImage,
107  TInternalComputationValueType,TMetricTraits> Superclass;
110 
112  itkNewMacro(Self);
113 
116 
118  typedef typename Superclass::MeasureType MeasureType;
120  typedef typename DerivativeType::ValueType DerivativeValueType;
121 
127 
131 
138 
141 
142  /* Image dimension accessors */
143  itkStaticConstMacro(VirtualImageDimension, ImageDimensionType, TVirtualImage::ImageDimension);
144  itkStaticConstMacro(FixedImageDimension, ImageDimensionType, TFixedImage::ImageDimension);
145  itkStaticConstMacro(MovingImageDimension, ImageDimensionType, TMovingImage::ImageDimension);
146 
152  itkSetClampMacro( NumberOfHistogramBins, SizeValueType, 5, NumericTraits<SizeValueType>::max() );
153  itkGetConstReferenceMacro(NumberOfHistogramBins, SizeValueType);
155 
156  virtual void Initialize(void) throw ( itk::ExceptionObject ) ITK_OVERRIDE;
157 
159  //NOTE: floating point precision is not as stable.
160  // Double precision proves faster and more robust in real-world testing.
161  typedef TInternalComputationValueType PDFValueType;
162 
164  typedef Image<PDFValueType, 2> JointPDFType;
166 
171  const typename JointPDFType::Pointer GetJointPDF () const
172  {
173  if( this->m_AccumulatorJointPDF.IsNull() )
174  {
175  return typename JointPDFType::Pointer(ITK_NULLPTR);
176  }
177  return this->m_AccumulatorJointPDF;
178  }
180 
188  {
190  {
191  return typename JointPDFDerivativesType::Pointer(ITK_NULLPTR);
192  }
194  }
196 
201  virtual void InitializeThread( const ThreadIdType threadId ) ITK_OVERRIDE;
202  virtual void FinalizeThread( const ThreadIdType threadId ) ITK_OVERRIDE;
204 
205 protected:
208 
210  friend class MattesMutualInformationImageToImageMetricv4GetValueAndDerivativeThreader< ThreadedIndexedContainerPartitioner, Superclass, Self >;
211  typedef MattesMutualInformationImageToImageMetricv4GetValueAndDerivativeThreader< ThreadedImageRegionPartitioner< Superclass::VirtualImageDimension >, Superclass, Self >
213  typedef MattesMutualInformationImageToImageMetricv4GetValueAndDerivativeThreader< ThreadedIndexedContainerPartitioner, Superclass, Self >
215 
216  void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE;
217 
226 
230 
234 
235  OffsetValueType ComputeSingleFixedImageParzenWindowIndex( const FixedImagePixelType & value ) const;
236 
247 
251 
254  typedef std::vector<PRatioType> PRatioArrayType;
255 
257 
260  mutable std::vector<OffsetValueType> m_JointPdfIndex1DArray;
261 
263  mutable std::vector<PDFValueType> m_MovingImageMarginalPDF;
264  mutable std::vector<std::vector<PDFValueType> > m_ThreaderFixedImageMarginalPDF;
265 
267  typename std::vector<typename JointPDFType::Pointer> m_ThreaderJointPDF;
268  typename std::vector<typename JointPDFDerivativesType::Pointer> m_ThreaderJointPDFDerivatives;
271 
273 
276  mutable std::vector<DerivativeType> m_LocalDerivativeByParzenBin;
277 
278 private:
279  MattesMutualInformationImageToImageMetricv4(const Self &); //purposely not implemented
280  void operator = (const Self &); //purposely not implemented
281 
283  virtual void ComputeResults() const;
284 
285  std::vector< MutexLock::Pointer > m_JointPDFSubsectionLocks;
286  std::vector< MutexLock::Pointer > m_JointPDFDerivativeSubsectionLocks;
287 
289 };
290 
291 } // end namespace itk
292 
293 #ifndef ITK_MANUAL_INSTANTIATION
294 #include "itkMattesMutualInformationImageToImageMetricv4.hxx"
295 #endif
296 
297 #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
virtual void InitializeThread(const ThreadIdType threadId) override
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
void PrintSelf(std::ostream &os, Indent indent) const override
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...
Superclass::DerivativeType DerivativeType
Superclass::IndexType IndexType
Definition: itkImage.h:122
Standard exception handling object.
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
MovingImageType::PixelType MovingImagePixelType
bool IsNull() const
MovingImageType::PointType MovingImagePointType
MetricTraits::MovingImageGradientType MovingImageGradientType
FixedSampledPointSetType::Pointer FixedSampledPointSetPointer
virtual void FinalizeThread(const ThreadIdType threadId) override
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