go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkParzenWindowHistogramImageToImageMetric.h
Go to the documentation of this file.
1 /*======================================================================
2 
3  This file is part of the elastix software.
4 
5  Copyright (c) University Medical Center Utrecht. All rights reserved.
6  See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
7  details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notices for more information.
12 
13 ======================================================================*/
14 
15 #ifndef __itkParzenWindowHistogramImageToImageMetric_H__
16 #define __itkParzenWindowHistogramImageToImageMetric_H__
17 
19 #include "itkBSplineKernelFunction.h"
20 
21 namespace itk
22 {
69 template< class TFixedImage, class TMovingImage >
71  public AdvancedImageToImageMetric< TFixedImage, TMovingImage >
72 {
73 public:
74 
78  typedef SmartPointer< Self > Pointer;
79  typedef SmartPointer< const Self > ConstPointer;
80 
83 
100  typedef typename Superclass::RealType RealType;
127 
129  itkStaticConstMacro( FixedImageDimension, unsigned int,
130  FixedImageType::ImageDimension );
131 
133  itkStaticConstMacro( MovingImageDimension, unsigned int,
134  MovingImageType::ImageDimension );
135 
142  void Initialize( void ) throw ( ExceptionObject );
143 
148  void GetDerivative(
149  const ParametersType & parameters,
150  DerivativeType & Derivative ) const;
151 
157  void GetValueAndDerivative( const ParametersType & parameters,
158  MeasureType & value, DerivativeType & derivative ) const;
159 
166  itkSetClampMacro( NumberOfFixedHistogramBins, unsigned long,
167  4, NumericTraits< unsigned long >::max() );
168  itkGetMacro( NumberOfFixedHistogramBins, unsigned long );
169 
176  itkSetClampMacro( NumberOfMovingHistogramBins, unsigned long,
177  4, NumericTraits< unsigned long >::max() );
178  itkGetMacro( NumberOfMovingHistogramBins, unsigned long );
179 
181  itkSetClampMacro( FixedKernelBSplineOrder, unsigned int, 0, 3 );
182  itkGetConstMacro( FixedKernelBSplineOrder, unsigned int );
183 
185  itkSetClampMacro( MovingKernelBSplineOrder, unsigned int, 0, 3 );
186  itkGetConstMacro( MovingKernelBSplineOrder, unsigned int );
187 
191  itkSetMacro( UseExplicitPDFDerivatives, bool );
192  itkGetConstReferenceMacro( UseExplicitPDFDerivatives, bool );
193  itkBooleanMacro( UseExplicitPDFDerivatives );
194 
198  itkSetMacro( UseDerivative, bool );
199  itkGetConstMacro( UseDerivative, bool );
200 
204  itkSetMacro( UseFiniteDifferenceDerivative, bool );
205  itkGetConstMacro( UseFiniteDifferenceDerivative, bool );
206 
211  itkSetMacro( FiniteDifferencePerturbation, double );
212  itkGetConstMacro( FiniteDifferencePerturbation, double );
213 
214  //mutable std::vector<float> m_TemporaryNormalizedSumJointPDF;
215 
216 protected:
217 
220 
222  virtual ~ParzenWindowHistogramImageToImageMetric();
223 
225  void PrintSelf( std::ostream & os, Indent indent ) const;
226 
241 
243  typedef double PDFValueType;
244  typedef float PDFDerivativeValueType;
245  typedef Array< PDFValueType > MarginalPDFType;
246  typedef Image< PDFValueType, 2 > JointPDFType;
247  typedef typename JointPDFType::Pointer JointPDFPointer;
248  typedef Image< PDFDerivativeValueType, 3 > JointPDFDerivativesType;
249  typedef typename JointPDFDerivativesType::Pointer JointPDFDerivativesPointer;
250  typedef Image< PDFValueType, 2 > IncrementalMarginalPDFType;
251  typedef typename IncrementalMarginalPDFType::Pointer IncrementalMarginalPDFPointer;
252  typedef JointPDFType::IndexType JointPDFIndexType;
253  typedef JointPDFType::RegionType JointPDFRegionType;
254  typedef JointPDFType::SizeType JointPDFSizeType;
255  typedef JointPDFDerivativesType::IndexType JointPDFDerivativesIndexType;
256  typedef JointPDFDerivativesType::RegionType JointPDFDerivativesRegionType;
257  typedef JointPDFDerivativesType::SizeType JointPDFDerivativesSizeType;
258  typedef IncrementalMarginalPDFType::IndexType IncrementalMarginalPDFIndexType;
259  typedef IncrementalMarginalPDFType::RegionType IncrementalMarginalPDFRegionType;
260  typedef IncrementalMarginalPDFType::SizeType IncrementalMarginalPDFSizeType;
261  typedef Array< PDFValueType > ParzenValueContainerType;
262 
264  typedef KernelFunctionBase< PDFValueType > KernelFunctionType;
265  typedef typename KernelFunctionType::Pointer KernelFunctionPointer;
266 
270  mutable double m_Alpha;
273 
275  mutable MarginalPDFType m_FixedImageMarginalPDF;
276  mutable MarginalPDFType m_MovingImageMarginalPDF;
277  JointPDFPointer m_JointPDF;
278  JointPDFDerivativesPointer m_JointPDFDerivatives;
279  JointPDFDerivativesPointer m_IncrementalJointPDFRight;
280  JointPDFDerivativesPointer m_IncrementalJointPDFLeft;
281  IncrementalMarginalPDFPointer m_FixedIncrementalMarginalPDFRight;
282  IncrementalMarginalPDFPointer m_MovingIncrementalMarginalPDFRight;
283  IncrementalMarginalPDFPointer m_FixedIncrementalMarginalPDFLeft;
284  IncrementalMarginalPDFPointer m_MovingIncrementalMarginalPDFLeft;
285  mutable JointPDFRegionType m_JointPDFWindow; // no need for mutable anymore?
292 
294  KernelFunctionPointer m_FixedKernel;
295  KernelFunctionPointer m_MovingKernel;
296  KernelFunctionPointer m_DerivativeMovingKernel;
297 
299  mutable std::vector< JointPDFPointer > m_ThreaderJointPDFs;
300 
304  struct ParzenWindowHistogramMultiThreaderParameterType // can't we use the one from AdvancedImageToImageMetric ?
305  {
307  };
308  ParzenWindowHistogramMultiThreaderParameterType m_ParzenWindowHistogramThreaderParameters;
309 
311  {
314  };
316  PaddedParzenWindowHistogramGetValueAndDerivativePerThreadStruct );
317  itkAlignedTypedef( ITK_CACHE_LINE_ALIGNMENT, PaddedParzenWindowHistogramGetValueAndDerivativePerThreadStruct,
318  AlignedParzenWindowHistogramGetValueAndDerivativePerThreadStruct );
319  mutable AlignedParzenWindowHistogramGetValueAndDerivativePerThreadStruct * m_ParzenWindowHistogramGetValueAndDerivativePerThreadVariables;
321 
323  virtual void InitializeThreadingParameters( void ) const;
324 
326  inline void ThreadedComputePDFs( ThreadIdType threadId );
327 
329  inline void AfterThreadedComputePDFs( void ) const;
330 
332  static ITK_THREAD_RETURN_TYPE ComputePDFsThreaderCallback( void * arg );
333 
335  void LaunchComputePDFsThreaderCallback( void ) const;
336 
344  double parzenWindowTerm, OffsetValueType parzenWindowIndex,
345  const KernelFunctionType * kernel,
346  ParzenValueContainerType & parzenValues ) const;
347 
351  virtual void UpdateJointPDFAndDerivatives(
352  const RealType & fixedImageValue,
353  const RealType & movingImageValue,
354  const DerivativeType * imageJacobian,
355  const NonZeroJacobianIndicesType * nzji,
356  JointPDFType * jointPDF ) const;
357 
369  RealType fixedImageValue, RealType movingImageValue, RealType movingMaskValue,
370  const DerivativeType & movingImageValuesRight,
371  const DerivativeType & movingImageValuesLeft,
372  const DerivativeType & movingMaskValuesRight,
373  const DerivativeType & movingMaskValuesLeft,
374  const NonZeroJacobianIndicesType & nzji ) const;
375 
382  const JointPDFIndexType & pdfIndex, double factor,
383  const DerivativeType & imageJacobian,
384  const NonZeroJacobianIndicesType & nzji ) const;
385 
387  virtual void NormalizeJointPDF(
388  JointPDFType * pdf, const double & factor ) const;
389 
391  virtual void NormalizeJointPDFDerivatives(
392  JointPDFDerivativesType * pdf, const double & factor ) const;
393 
398  virtual void ComputeMarginalPDF(
399  const JointPDFType * jointPDF,
400  MarginalPDFType & marginalPDF,
401  const unsigned int & direction ) const;
402 
406  virtual void ComputeIncrementalMarginalPDFs(
407  const JointPDFDerivativesType * incrementalPDF,
408  IncrementalMarginalPDFType * fixedIncrementalMarginalPDF,
409  IncrementalMarginalPDFType * movingIncrementalMarginalPDF ) const;
410 
420  virtual void ComputePDFsAndPDFDerivatives( const ParametersType & parameters ) const;
421 
445  virtual void ComputePDFsAndIncrementalPDFs( const ParametersType & parameters ) const;
446 
455  virtual void ComputePDFsSingleThreaded( const ParametersType & parameters ) const;
456 
457  virtual void ComputePDFs( const ParametersType & parameters ) const;
458 
460  virtual void InitializeHistograms( void );
461 
462  virtual void InitializeKernels( void );
463 
469  const ParametersType & itkNotUsed( parameters ),
470  MeasureType & itkNotUsed( value ),
471  DerivativeType & itkNotUsed( derivative ) ) const {}
472 
478  const ParametersType & itkNotUsed( parameters ),
479  MeasureType & itkNotUsed( value ),
480  DerivativeType & itkNotUsed( derivative ) ) const {}
481 
482 private:
483 
485  ParzenWindowHistogramImageToImageMetric( const Self & ); // purposely not implemented
487  void operator=( const Self & ); // purposely not implemented
488 
498 
499 };
500 
501 } // end namespace itk
502 
503 #ifndef ITK_MANUAL_INSTANTIATION
504 #include "itkParzenWindowHistogramImageToImageMetric.hxx"
505 #endif
506 
507 #endif // end #ifndef __itkParzenWindowHistogramImageToImageMetric_H__
ImageToImageMetric< MetricBase< TElastix >::FixedImageType, MetricBase< TElastix >::MovingImageType > Superclass
virtual void GetValueAndFiniteDifferenceDerivative(const ParametersType &, MeasureType &, DerivativeType &) const
Superclass::MovingImageDerivativeScalesType MovingImageDerivativeScalesType
virtual void ComputeIncrementalMarginalPDFs(const JointPDFDerivativesType *incrementalPDF, IncrementalMarginalPDFType *fixedIncrementalMarginalPDF, IncrementalMarginalPDFType *movingIncrementalMarginalPDF) const
virtual void NormalizeJointPDFDerivatives(JointPDFDerivativesType *pdf, const double &factor) const
LimiterFunctionBase< RealType, FixedImageDimension > FixedImageLimiterType
Superclass::CoordinateRepresentationType CoordinateRepresentationType
void EvaluateParzenValues(double parzenWindowTerm, OffsetValueType parzenWindowIndex, const KernelFunctionType *kernel, ParzenValueContainerType &parzenValues) const
Superclass::TransformParametersType TransformParametersType
Superclass::MovingImageType MovingImageType
Superclass::FixedImageMaskPointer FixedImageMaskPointer
An extension of the ITK ImageToImageMetric. It is the intended base class for all elastix metrics...
Superclass::GradientPixelType GradientPixelType
FixedImageLimiterType::OutputType FixedImageLimiterOutputType
Superclass::FixedImageRegionType FixedImageRegionType
itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT, PaddedParzenWindowHistogramGetValueAndDerivativePerThreadStruct, AlignedParzenWindowHistogramGetValueAndDerivativePerThreadStruct)
void ThreadedComputePDFs(ThreadIdType threadId)
ImageSamplerType::OutputVectorContainerType ImageSampleContainerType
virtual void NormalizeJointPDF(JointPDFType *pdf, const double &factor) const
FixedArray< double, Self::MovingImageDimension > MovingImageDerivativeScalesType
BSplineInterpolateImageFunction< MovingImageType, CoordinateRepresentationType, double > BSplineInterpolatorType
ImageSamplerBase< FixedImageType > ImageSamplerType
virtual void ComputePDFsSingleThreaded(const ParametersType &parameters) const
virtual void ComputePDFsAndIncrementalPDFs(const ParametersType &parameters) const
virtual void UpdateJointPDFAndIncrementalPDFs(RealType fixedImageValue, RealType movingImageValue, RealType movingMaskValue, const DerivativeType &movingImageValuesRight, const DerivativeType &movingImageValuesLeft, const DerivativeType &movingMaskValuesRight, const DerivativeType &movingMaskValuesLeft, const NonZeroJacobianIndicesType &nzji) const
Superclass::InterpolatorPointer InterpolatorPointer
Superclass::CoordinateRepresentationType CoordinateRepresentationType
virtual void GetValueAndAnalyticDerivative(const ParametersType &, MeasureType &, DerivativeType &) const
virtual void InitializeThreadingParameters(void) const
int max(int a, int b)
Superclass::MovingImageMaskType MovingImageMaskType
LimiterFunctionBase< RealType, MovingImageDimension > MovingImageLimiterType
Superclass::GradientImageType GradientImageType
virtual void ComputePDFs(const ParametersType &parameters) const
Superclass::TransformPointer TransformPointer
ParzenWindowHistogramMultiThreaderParameterType m_ParzenWindowHistogramThreaderParameters
A base class for image metrics based on a joint histogram computed using Parzen Windowing.
void PrintSelf(std::ostream &os, Indent indent) const
void UpdateJointPDFDerivatives(const JointPDFIndexType &pdfIndex, double factor, const DerivativeType &imageJacobian, const NonZeroJacobianIndicesType &nzji) const
itkPadStruct(ITK_CACHE_LINE_ALIGNMENT, ParzenWindowHistogramGetValueAndDerivativePerThreadStruct, PaddedParzenWindowHistogramGetValueAndDerivativePerThreadStruct)
void GetValueAndDerivative(const ParametersType &parameters, MeasureType &value, DerivativeType &derivative) const
void GetDerivative(const ParametersType &parameters, DerivativeType &Derivative) const
Superclass::GradientImageFilterType GradientImageFilterType
MovingImageType::RegionType MovingImageRegionType
Superclass::InterpolatorType InterpolatorType
Superclass::TransformJacobianType TransformJacobianType
static ITK_THREAD_RETURN_TYPE ComputePDFsThreaderCallback(void *arg)
virtual void UpdateJointPDFAndDerivatives(const RealType &fixedImageValue, const RealType &movingImageValue, const DerivativeType *imageJacobian, const NonZeroJacobianIndicesType *nzji, JointPDFType *jointPDF) const
virtual void ComputeMarginalPDF(const JointPDFType *jointPDF, MarginalPDFType &marginalPDF, const unsigned int &direction) const
Superclass::MovingImagePixelType MovingImagePixelType
Superclass::MovingImageMaskPointer MovingImageMaskPointer
MovingImageLimiterType::OutputType MovingImageLimiterOutputType
ThreaderType::ThreadInfoStruct ThreadInfoType
virtual void ComputePDFsAndPDFDerivatives(const ParametersType &parameters) const
ImageSamplerType::OutputVectorContainerPointer ImageSampleContainerPointer
Superclass::FixedImageMaskType FixedImageMaskType
itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension)
Superclass::FixedImageConstPointer FixedImageConstPointer
AlignedParzenWindowHistogramGetValueAndDerivativePerThreadStruct * m_ParzenWindowHistogramGetValueAndDerivativePerThreadVariables
Superclass::MovingImageConstPointer MovingImageConstPointer
AdvancedImageToImageMetric< TFixedImage, TMovingImage > Superclass
Superclass::GradientImageFilterPointer GradientImageFilterPointer
Superclass::GradientImagePointer GradientImagePointer


Generated on 27-04-2014 for elastix by doxygen 1.8.6 elastix logo