ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkJointHistogramMutualInformationImageToImageMetricv4.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 
19 #ifndef itkJointHistogramMutualInformationImageToImageMetricv4_h
20 #define itkJointHistogramMutualInformationImageToImageMetricv4_h
21 
23 #include "itkImage.h"
25 
28 
29 namespace itk
30 {
43 template<typename TFixedImage,typename TMovingImage,typename TVirtualImage = TFixedImage,
44  typename TInternalComputationValueType = double,
45  typename TMetricTraits = DefaultImageToImageMetricTraitsv4<TFixedImage,TMovingImage,TVirtualImage,TInternalComputationValueType>
46  >
48  public ImageToImageMetricv4<TFixedImage, TMovingImage, TVirtualImage, TInternalComputationValueType, TMetricTraits>
49 {
50 public:
51 
54  typedef ImageToImageMetricv4<TFixedImage, TMovingImage, TVirtualImage,
55  TInternalComputationValueType,TMetricTraits> Superclass;
58 
60  itkNewMacro(Self);
61 
64 
66  typedef typename Superclass::CoordinateRepresentationType
68 
72  typedef TInternalComputationValueType InternalComputationValueType;
73 
75  typedef typename Superclass::ParametersType ParametersType;
76  typedef typename Superclass::ParametersValueType ParametersValueType;
77  typedef typename Superclass::NumberOfParametersType NumberOfParametersType;
78 
80  typedef typename Superclass::MeasureType MeasureType;
81  typedef typename Superclass::DerivativeType DerivativeType;
82  typedef typename Superclass::FixedImagePointType FixedImagePointType;
83  typedef typename Superclass::FixedImagePixelType FixedImagePixelType;
84  typedef typename Superclass::FixedGradientPixelType FixedImageGradientType;
85  typedef typename Superclass::MovingImagePointType MovingImagePointType;
86  typedef typename Superclass::MovingImagePixelType MovingImagePixelType;
87  typedef typename Superclass::MovingGradientPixelType MovingImageGradientType;
88 
89  typedef typename Superclass::FixedTransformType::JacobianType FixedTransformJacobianType;
90  typedef typename Superclass::MovingTransformType::JacobianType MovingTransformJacobianType;
91 
92  typedef typename Superclass::VirtualImageType VirtualImageType;
93  typedef typename Superclass::VirtualIndexType VirtualIndexType;
94  typedef typename Superclass::VirtualPointType VirtualPointType;
95  typedef typename Superclass::VirtualPointSetType VirtualPointSetType;
96 
97  /* Image dimension accessors */
98  itkStaticConstMacro(VirtualImageDimension, typename TVirtualImage::ImageDimensionType, TVirtualImage::ImageDimension);
99  itkStaticConstMacro(MovingImageDimension, typename TMovingImage::ImageDimensionType, TMovingImage::ImageDimension);
100 
102  typedef TInternalComputationValueType PDFValueType;
103 
112 
114  itkGetModifiableObjectMacro(JointPDF, JointPDFType );
115 
116  // Declare the type for the derivative calculation
119  typedef typename JPDFGradientImageType::Pointer JPDFGradientImagePointer;
120 
123  typedef typename MarginalGradientImageType::Pointer MarginalGradientImagePointer;
124 
130 
136 
137 
139  itkSetClampMacro( NumberOfHistogramBins, SizeValueType, 5, NumericTraits< SizeValueType >::max() );
140  itkGetConstReferenceMacro(NumberOfHistogramBins, SizeValueType );
142 
144  itkSetMacro(VarianceForJointPDFSmoothing, TInternalComputationValueType);
145  itkGetMacro(VarianceForJointPDFSmoothing, TInternalComputationValueType);
147 
149  virtual void Initialize() ITK_OVERRIDE;
150 
151  virtual MeasureType GetValue() const ITK_OVERRIDE;
152 
153 protected:
155  virtual ~JointHistogramMutualInformationImageToImageMetricv4() ITK_OVERRIDE;
156 
160  virtual void InitializeForIteration() const ITK_OVERRIDE;
161 
163  MeasureType ComputeValue() const;
164 
167  inline void ComputeJointPDFPoint( const FixedImagePixelType fixedImageValue, const MovingImagePixelType movingImageValue, JointPDFPointType & jointPDFpoint ) const;
168 
172  friend class JointHistogramMutualInformationComputeJointPDFThreader< ThreadedIndexedContainerPartitioner, Self >;
173 
174  typedef JointHistogramMutualInformationComputeJointPDFThreader< ThreadedImageRegionPartitioner< Self::VirtualImageDimension >, Self >
176  typedef JointHistogramMutualInformationComputeJointPDFThreader< ThreadedIndexedContainerPartitioner, Self >
178 
179  typename JointHistogramMutualInformationDenseComputeJointPDFThreaderType::Pointer m_JointHistogramMutualInformationDenseComputeJointPDFThreader;
180  typename JointHistogramMutualInformationSparseComputeJointPDFThreaderType::Pointer m_JointHistogramMutualInformationSparseComputeJointPDFThreader;
181 
183  friend class JointHistogramMutualInformationGetValueAndDerivativeThreader< ThreadedIndexedContainerPartitioner, Superclass, Self >;
184 
185  typedef JointHistogramMutualInformationGetValueAndDerivativeThreader< ThreadedImageRegionPartitioner< Superclass::VirtualImageDimension >, Superclass, Self >
187  typedef JointHistogramMutualInformationGetValueAndDerivativeThreader< ThreadedIndexedContainerPartitioner, Superclass, Self >
189 
191  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
192 
194  SizeValueType m_JointHistogramTotalCount;
195 
196 private:
197  ITK_DISALLOW_COPY_AND_ASSIGN(JointHistogramMutualInformationImageToImageMetricv4);
198 
200  typename MarginalPDFType::Pointer m_FixedImageMarginalPDF;
201 
203  typename MarginalPDFType::Pointer m_MovingImageMarginalPDF;
204 
206  mutable typename JointPDFType::Pointer m_JointPDF;
207 
209  TInternalComputationValueType m_VarianceForJointPDFSmoothing;
210 
212  SizeValueType m_NumberOfHistogramBins;
213  TInternalComputationValueType m_FixedImageTrueMin;
214  TInternalComputationValueType m_FixedImageTrueMax;
215  TInternalComputationValueType m_MovingImageTrueMin;
216  TInternalComputationValueType m_MovingImageTrueMax;
217  TInternalComputationValueType m_FixedImageBinSize;
218  TInternalComputationValueType m_MovingImageBinSize;
219 
220  TInternalComputationValueType m_JointPDFSum;
221  JointPDFSpacingType m_JointPDFSpacing;
222 
223  TInternalComputationValueType m_Log2;
225 
226 };
227 
228 } // end namespace itk
229 
230 #ifndef ITK_MANUAL_INSTANTIATION
231 #include "itkJointHistogramMutualInformationImageToImageMetricv4.hxx"
232 #endif
233 
234 #endif
Superclass::RegionType RegionType
Definition: itkImage.h:137
Light weight base class for most itk classes.
Represent the size (bounds) of a n-dimensional image.
Definition: itkSize.h:52
Class for partitioning of an ImageRegion.
Superclass::IndexValueType IndexValueType
Definition: itkImage.h:120
Computes the gradient of an image by convolution with the first derivative of a Gaussian.
unsigned long SizeValueType
Definition: itkIntTypes.h:143
Provide a threaded computation of the joint PDF for JointHistogramMutualInformationImageToImageMetric...
TPixel PixelType
Definition: itkImage.h:89
FixedImageType::PixelType FixedImagePixelType
ImageToImageMetricv4< TFixedImage, TMovingImage, TVirtualImage, TInternalComputationValueType, TMetricTraits > Superclass
Linearly interpolate an image at specified positions.
MovingImageType::PixelType MovingImagePixelType
Computes the mutual information between two images to be registered using the method referenced below...
Processes points for JointHistogramMutualInformationImageToImageMetricv4 GetValueAndDerivative().
Control indentation during Print() invocation.
Definition: itkIndent.h:49
LinearInterpolateImageFunction< MarginalPDFType, double > MarginalPDFInterpolatorType
Define additional traits for native types such as int or float.
Templated n-dimensional image class.
Definition: itkImage.h:75
itk::GradientRecursiveGaussianImageFilter< MarginalPDFType > MarginalGradientFilterType