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  * Copyright UMC Utrecht and contributors
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 __itkParzenWindowHistogramImageToImageMetric_H__
19 #define __itkParzenWindowHistogramImageToImageMetric_H__
20 
22 #include "itkKernelFunctionBase2.h"
23 
24 
25 namespace itk
26 {
73 template< class TFixedImage, class TMovingImage >
75  public AdvancedImageToImageMetric< TFixedImage, TMovingImage >
76 {
77 public:
78 
82  typedef SmartPointer< Self > Pointer;
83  typedef SmartPointer< const Self > ConstPointer;
84 
87 
104  typedef typename Superclass::RealType RealType;
131 
133  itkStaticConstMacro( FixedImageDimension, unsigned int,
134  FixedImageType::ImageDimension );
135 
137  itkStaticConstMacro( MovingImageDimension, unsigned int,
138  MovingImageType::ImageDimension );
139 
146  void Initialize( void ) override;
147 
153  const ParametersType & parameters,
154  DerivativeType & Derivative ) const override;
155 
161  void GetValueAndDerivative( const ParametersType & parameters,
162  MeasureType & value, DerivativeType & derivative ) const override;
163 
170  itkSetClampMacro( NumberOfFixedHistogramBins, unsigned long,
171  4, NumericTraits< unsigned long >::max() );
172  itkGetMacro( NumberOfFixedHistogramBins, unsigned long );
173 
180  itkSetClampMacro( NumberOfMovingHistogramBins, unsigned long,
181  4, NumericTraits< unsigned long >::max() );
182  itkGetMacro( NumberOfMovingHistogramBins, unsigned long );
183 
185  itkSetClampMacro( FixedKernelBSplineOrder, unsigned int, 0, 3 );
186  itkGetConstMacro( FixedKernelBSplineOrder, unsigned int );
187 
189  itkSetClampMacro( MovingKernelBSplineOrder, unsigned int, 0, 3 );
190  itkGetConstMacro( MovingKernelBSplineOrder, unsigned int );
191 
195  itkSetMacro( UseExplicitPDFDerivatives, bool );
196  itkGetConstReferenceMacro( UseExplicitPDFDerivatives, bool );
197  itkBooleanMacro( UseExplicitPDFDerivatives );
198 
202  itkSetMacro( UseDerivative, bool );
203  itkGetConstMacro( UseDerivative, bool );
204 
208  itkSetMacro( UseFiniteDifferenceDerivative, bool );
209  itkGetConstMacro( UseFiniteDifferenceDerivative, bool );
210 
215  itkSetMacro( FiniteDifferencePerturbation, double );
216  itkGetConstMacro( FiniteDifferencePerturbation, double );
217 
218 protected:
219 
222 
225 
227  void PrintSelf( std::ostream & os, Indent indent ) const override;
228 
234  typedef typename FixedImageType::OffsetValueType OffsetValueType;
243 
245  typedef double PDFValueType;
246  typedef float PDFDerivativeValueType;
249  typedef typename JointPDFType::Pointer JointPDFPointer;
251  typedef typename JointPDFDerivativesType::Pointer JointPDFDerivativesPointer;
253  typedef typename IncrementalMarginalPDFType::Pointer IncrementalMarginalPDFPointer;
254  typedef JointPDFType::IndexType JointPDFIndexType;
255  typedef JointPDFType::RegionType JointPDFRegionType;
256  typedef JointPDFType::SizeType JointPDFSizeType;
257  typedef JointPDFDerivativesType::IndexType JointPDFDerivativesIndexType;
258  typedef JointPDFDerivativesType::RegionType JointPDFDerivativesRegionType;
259  typedef JointPDFDerivativesType::SizeType JointPDFDerivativesSizeType;
260  typedef IncrementalMarginalPDFType::IndexType IncrementalMarginalPDFIndexType;
261  typedef IncrementalMarginalPDFType::RegionType IncrementalMarginalPDFRegionType;
262  typedef IncrementalMarginalPDFType::SizeType IncrementalMarginalPDFSizeType;
264 
268 
272  mutable double m_Alpha;
275 
287  mutable JointPDFRegionType m_JointPDFWindow; // no need for mutable anymore?
294 
299 
301  mutable std::vector< JointPDFPointer > m_ThreaderJointPDFs;
302 
306  struct ParzenWindowHistogramMultiThreaderParameterType // can't we use the one from AdvancedImageToImageMetric ?
307  {
309  };
311 
313  {
316  };
318  PaddedParzenWindowHistogramGetValueAndDerivativePerThreadStruct );
319  itkAlignedTypedef( ITK_CACHE_LINE_ALIGNMENT, PaddedParzenWindowHistogramGetValueAndDerivativePerThreadStruct,
320  AlignedParzenWindowHistogramGetValueAndDerivativePerThreadStruct );
321  mutable AlignedParzenWindowHistogramGetValueAndDerivativePerThreadStruct * m_ParzenWindowHistogramGetValueAndDerivativePerThreadVariables;
323 
325  void InitializeThreadingParameters( void ) const override;
326 
328  inline void ThreadedComputePDFs( ThreadIdType threadId );
329 
331  inline void AfterThreadedComputePDFs( void ) const;
332 
334  static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION ComputePDFsThreaderCallback( void * arg );
335 
338 
346  double parzenWindowTerm, OffsetValueType parzenWindowIndex,
347  const KernelFunctionType * kernel,
348  ParzenValueContainerType & parzenValues ) const;
349 
354  const RealType & fixedImageValue,
355  const RealType & movingImageValue,
356  const DerivativeType * imageJacobian,
357  const NonZeroJacobianIndicesType * nzji,
358  JointPDFType * jointPDF ) const;
359 
371  RealType fixedImageValue, RealType movingImageValue, RealType movingMaskValue,
372  const DerivativeType & movingImageValuesRight,
373  const DerivativeType & movingImageValuesLeft,
374  const DerivativeType & movingMaskValuesRight,
375  const DerivativeType & movingMaskValuesLeft,
376  const NonZeroJacobianIndicesType & nzji ) const;
377 
384  const JointPDFIndexType & pdfIndex, double factor,
385  const DerivativeType & imageJacobian,
386  const NonZeroJacobianIndicesType & nzji ) const;
387 
389  virtual void NormalizeJointPDF(
390  JointPDFType * pdf, const double & factor ) const;
391 
394  JointPDFDerivativesType * pdf, const double & factor ) const;
395 
400  virtual void ComputeMarginalPDF(
401  const JointPDFType * jointPDF,
402  MarginalPDFType & marginalPDF,
403  const unsigned int & direction ) const;
404 
409  const JointPDFDerivativesType * incrementalPDF,
410  IncrementalMarginalPDFType * fixedIncrementalMarginalPDF,
411  IncrementalMarginalPDFType * movingIncrementalMarginalPDF ) const;
412 
422  virtual void ComputePDFsAndPDFDerivatives( const ParametersType & parameters ) const;
423 
447  virtual void ComputePDFsAndIncrementalPDFs( const ParametersType & parameters ) const;
448 
457  virtual void ComputePDFsSingleThreaded( const ParametersType & parameters ) const;
458 
459  virtual void ComputePDFs( const ParametersType & parameters ) const;
460 
462  virtual void InitializeHistograms( void );
463 
464  virtual void InitializeKernels( void );
465 
471  const ParametersType & itkNotUsed( parameters ),
472  MeasureType & itkNotUsed( value ),
473  DerivativeType & itkNotUsed( derivative ) ) const {}
474 
480  const ParametersType & itkNotUsed( parameters ),
481  MeasureType & itkNotUsed( value ),
482  DerivativeType & itkNotUsed( derivative ) ) const {}
483 
484 private:
485 
487  ParzenWindowHistogramImageToImageMetric( const Self & ); // purposely not implemented
489  void operator=( const Self & ); // purposely not implemented
490 
500 
501 };
502 
503 } // end namespace itk
504 
505 #ifndef ITK_MANUAL_INSTANTIATION
506 #include "itkParzenWindowHistogramImageToImageMetric.hxx"
507 #endif
508 
509 #endif // end #ifndef __itkParzenWindowHistogramImageToImageMetric_H__
An extension of the ITK ImageToImageMetric. It is the intended base class for all elastix metrics.
BSplineInterpolateImageFunction< MovingImageType, CoordinateRepresentationType, double > BSplineInterpolatorType
Superclass::FixedImageConstPointer FixedImageConstPointer
Superclass::TransformParametersType TransformParametersType
Superclass::MovingImageConstPointer MovingImageConstPointer
Superclass::FixedImageMaskPointer FixedImageMaskPointer
InterpolatorType::ContinuousIndexType MovingImageContinuousIndexType
Superclass::GradientImageFilterPointer GradientImageFilterPointer
Superclass::GradientImageFilterType GradientImageFilterType
Superclass::TransformJacobianType TransformJacobianType
FixedArray< double, Self::MovingImageDimension > MovingImageDerivativeScalesType
Superclass::GradientImagePointer GradientImagePointer
Superclass::TransformPointer TransformPointer
ImageSamplerType::OutputVectorContainerPointer ImageSampleContainerPointer
AdvancedTransformType::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
ImageSamplerBase< FixedImageType > ImageSamplerType
Superclass::CoordinateRepresentationType CoordinateRepresentationType
ImageSamplerType::OutputVectorContainerType ImageSampleContainerType
Superclass::InterpolatorPointer InterpolatorPointer
Superclass::MovingImageMaskPointer MovingImageMaskPointer
TransformType::InputPointType FixedImagePointType
Superclass::MovingImageMaskType MovingImageMaskType
Superclass::GradientPixelType GradientPixelType
MovingImageType::IndexType MovingImageIndexType
MovingImageType::RegionType MovingImageRegionType
FixedImageLimiterType::OutputType FixedImageLimiterOutputType
FixedImageIndexType::IndexValueType FixedImageIndexValueType
Superclass::MovingImagePixelType MovingImagePixelType
MovingImageLimiterType::OutputType MovingImageLimiterOutputType
GradientImageFilter< MovingImageType, RealType, RealType > CentralDifferenceGradientFilterType
LimiterFunctionBase< RealType, MovingImageDimension > MovingImageLimiterType
BSplineInterpolatorType::CovariantVectorType MovingImageDerivativeType
Superclass::FixedImageMaskType FixedImageMaskType
Superclass::GradientImageType GradientImageType
Superclass::InterpolatorType InterpolatorType
TransformType::OutputPointType MovingImagePointType
LimiterFunctionBase< RealType, FixedImageDimension > FixedImageLimiterType
Superclass::FixedImageRegionType FixedImageRegionType
Kernel used for density estimation and nonparameteric regression.
SmartPointer< Self > Pointer
A base class for image metrics based on a joint histogram computed using Parzen Windowing.
Superclass::MovingImageDerivativeScalesType MovingImageDerivativeScalesType
Superclass::CentralDifferenceGradientFilterType CentralDifferenceGradientFilterType
void InitializeThreadingParameters(void) const override
virtual void NormalizeJointPDF(JointPDFType *pdf, const double &factor) const
virtual void ComputePDFsAndIncrementalPDFs(const ParametersType &parameters) const
Superclass::MovingImageContinuousIndexType MovingImageContinuousIndexType
void ThreadedComputePDFs(ThreadIdType threadId)
virtual void ComputePDFsSingleThreaded(const ParametersType &parameters) const
itkPadStruct(ITK_CACHE_LINE_ALIGNMENT, ParzenWindowHistogramGetValueAndDerivativePerThreadStruct, PaddedParzenWindowHistogramGetValueAndDerivativePerThreadStruct)
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION ComputePDFsThreaderCallback(void *arg)
virtual void ComputePDFsAndPDFDerivatives(const ParametersType &parameters) const
void GetDerivative(const ParametersType &parameters, DerivativeType &Derivative) const override
itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT, PaddedParzenWindowHistogramGetValueAndDerivativePerThreadStruct, AlignedParzenWindowHistogramGetValueAndDerivativePerThreadStruct)
void UpdateJointPDFDerivatives(const JointPDFIndexType &pdfIndex, double factor, const DerivativeType &imageJacobian, const NonZeroJacobianIndicesType &nzji) const
virtual void ComputeMarginalPDF(const JointPDFType *jointPDF, MarginalPDFType &marginalPDF, const unsigned int &direction) const
virtual void GetValueAndAnalyticDerivative(const ParametersType &, MeasureType &, DerivativeType &) const
virtual void ComputePDFs(const ParametersType &parameters) const
AdvancedImageToImageMetric< TFixedImage, TMovingImage > Superclass
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::CoordinateRepresentationType CoordinateRepresentationType
itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension)
void GetValueAndDerivative(const ParametersType &parameters, MeasureType &value, DerivativeType &derivative) const override
void PrintSelf(std::ostream &os, Indent indent) const override
virtual void NormalizeJointPDFDerivatives(JointPDFDerivativesType *pdf, const double &factor) const
virtual void UpdateJointPDFAndDerivatives(const RealType &fixedImageValue, const RealType &movingImageValue, const DerivativeType *imageJacobian, const NonZeroJacobianIndicesType *nzji, JointPDFType *jointPDF) const
ParzenWindowHistogramMultiThreaderParameterType m_ParzenWindowHistogramThreaderParameters
virtual void ComputeIncrementalMarginalPDFs(const JointPDFDerivativesType *incrementalPDF, IncrementalMarginalPDFType *fixedIncrementalMarginalPDF, IncrementalMarginalPDFType *movingIncrementalMarginalPDF) const
void EvaluateParzenValues(double parzenWindowTerm, OffsetValueType parzenWindowIndex, const KernelFunctionType *kernel, ParzenValueContainerType &parzenValues) const
AlignedParzenWindowHistogramGetValueAndDerivativePerThreadStruct * m_ParzenWindowHistogramGetValueAndDerivativePerThreadVariables
virtual void GetValueAndFiniteDifferenceDerivative(const ParametersType &, MeasureType &, DerivativeType &) const
itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension)


Generated on OURCE_DATE_EPOCH for elastix by doxygen 1.9.1 elastix logo