go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkAdvancedImageToImageMetric.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 __itkAdvancedImageToImageMetric_h
16 #define __itkAdvancedImageToImageMetric_h
17 
18 #include "itkImageToImageMetric.h"
19 
20 #include "itkImageSamplerBase.h"
21 #include "itkGradientImageFilter.h"
22 #include "itkBSplineInterpolateImageFunction.h"
24 #include "itkLimiterFunctionBase.h"
25 #include "itkFixedArray.h"
26 #include "itkAdvancedTransform.h"
27 #include "vnl/vnl_sparse_matrix.h"
28 
29 namespace itk
30 {
31 
68 template <class TFixedImage, class TMovingImage>
70  public ImageToImageMetric< TFixedImage, TMovingImage >
71 {
72 public:
75  typedef ImageToImageMetric<
76  TFixedImage, TMovingImage > Superclass;
77  typedef SmartPointer<Self> Pointer;
78  typedef SmartPointer<const Self> ConstPointer;
79 
81  itkTypeMacro( AdvancedImageToImageMetric, ImageToImageMetric );
82 
84  itkStaticConstMacro( MovingImageDimension, unsigned int,
85  TMovingImage::ImageDimension );
86  itkStaticConstMacro( FixedImageDimension, unsigned int,
87  TFixedImage::ImageDimension );
88 
90  typedef typename Superclass::CoordinateRepresentationType CoordinateRepresentationType;
91  typedef typename Superclass::MovingImageType MovingImageType;
92  typedef typename Superclass::MovingImagePixelType MovingImagePixelType;
93  typedef typename MovingImageType::Pointer MovingImagePointer;
94  typedef typename Superclass::MovingImageConstPointer MovingImageConstPointer;
95  typedef typename Superclass::FixedImageType FixedImageType;
96  typedef typename FixedImageType::Pointer FixedImagePointer;
97  typedef typename Superclass::FixedImageConstPointer FixedImageConstPointer;
98  typedef typename Superclass::FixedImageRegionType FixedImageRegionType;
99  typedef typename Superclass::TransformType TransformType;
100  typedef typename Superclass::TransformPointer TransformPointer;
101  typedef typename Superclass::InputPointType InputPointType;
102  typedef typename Superclass::OutputPointType OutputPointType;
103  typedef typename Superclass::TransformParametersType TransformParametersType;
104  typedef typename Superclass::TransformJacobianType TransformJacobianType;
105  typedef typename Superclass::InterpolatorType InterpolatorType;
106  typedef typename Superclass::InterpolatorPointer InterpolatorPointer;
107  typedef typename Superclass::RealType RealType;
108  typedef typename Superclass::GradientPixelType GradientPixelType;
109  typedef typename Superclass::GradientImageType GradientImageType;
110  typedef typename Superclass::GradientImagePointer GradientImagePointer;
111  typedef typename Superclass::GradientImageFilterType GradientImageFilterType;
112  typedef typename Superclass::GradientImageFilterPointer GradientImageFilterPointer;
113  typedef typename Superclass::FixedImageMaskType FixedImageMaskType;
114  typedef typename Superclass::FixedImageMaskPointer FixedImageMaskPointer;
115  typedef typename Superclass::MovingImageMaskType MovingImageMaskType;
116  typedef typename Superclass::MovingImageMaskPointer MovingImageMaskPointer;
117  typedef typename Superclass::MeasureType MeasureType;
118  typedef typename Superclass::DerivativeType DerivativeType;
119  typedef typename DerivativeType::ValueType DerivativeValueType;
120  typedef typename Superclass::ParametersType ParametersType;
121 
123  typedef typename FixedImageType::PixelType FixedImagePixelType;
124  typedef typename MovingImageType::RegionType MovingImageRegionType;
125  typedef FixedArray< double,
126  itkGetStaticConstMacro(MovingImageDimension) > MovingImageDerivativeScalesType;
127 
131  typedef typename
133  typedef typename
135 
137  typedef LimiterFunctionBase<
138  RealType, FixedImageDimension> FixedImageLimiterType;
140  typedef LimiterFunctionBase<
141  RealType, MovingImageDimension> MovingImageLimiterType;
143 
145  typedef typename TransformType::ScalarType ScalarType;
146  typedef AdvancedTransform<
147  ScalarType,
148  FixedImageDimension,
149  MovingImageDimension > AdvancedTransformType;
150 
152  typedef typename DerivativeType::ValueType HessianValueType;
153  //typedef Array2D<HessianValueType> HessianType;
154  typedef vnl_sparse_matrix<HessianValueType> HessianType;
155 
158  virtual void SetTransform( AdvancedTransformType * arg )
159  {
160  this->Superclass::SetTransform( arg );
161  if ( this->m_AdvancedTransform != arg )
162  {
163  this->m_AdvancedTransform = arg;
164  this->Modified();
165  }
166  }
167  const AdvancedTransformType * GetTransform( void ) const
168  {
169  return this->m_AdvancedTransform.GetPointer();
170  }
171 
173  itkSetObjectMacro( ImageSampler, ImageSamplerType );
174  virtual ImageSamplerType * GetImageSampler( void ) const
175  {
176  return this->m_ImageSampler.GetPointer();
177  };
178 
181  itkGetConstMacro( UseImageSampler, bool );
182 
186  itkSetMacro( RequiredRatioOfValidSamples, double );
187  itkGetConstMacro( RequiredRatioOfValidSamples, double );
188 
191  itkSetObjectMacro( MovingImageLimiter, MovingImageLimiterType );
192  itkGetConstObjectMacro( MovingImageLimiter, MovingImageLimiterType );
193  itkSetObjectMacro( FixedImageLimiter, FixedImageLimiterType );
194  itkGetConstObjectMacro( FixedImageLimiter, FixedImageLimiterType );
195 
202  itkSetMacro( MovingLimitRangeRatio, double );
203  itkGetConstMacro( MovingLimitRangeRatio, double );
204  itkSetMacro( FixedLimitRangeRatio, double );
205  itkGetConstMacro( FixedLimitRangeRatio, double );
206 
209  itkGetConstMacro( UseFixedImageLimiter, bool );
210  itkGetConstMacro( UseMovingImageLimiter, bool );
211 
218  itkSetMacro( UseMovingImageDerivativeScales, bool );
219  itkGetConstMacro( UseMovingImageDerivativeScales, bool );
220  itkSetMacro( MovingImageDerivativeScales, MovingImageDerivativeScalesType );
221  itkGetConstReferenceMacro( MovingImageDerivativeScales, MovingImageDerivativeScalesType );
222 
231  virtual void Initialize( void ) throw ( ExceptionObject );
232 
235  virtual void GetSelfHessian( const TransformParametersType & parameters, HessianType & H ) const;
236 
237 protected:
238 
241 
243  virtual ~AdvancedImageToImageMetric() {};
244 
246  void PrintSelf( std::ostream& os, Indent indent ) const;
247 
251  typedef typename FixedImageType::IndexType FixedImageIndexType;
252  typedef typename FixedImageIndexType::IndexValueType FixedImageIndexValueType;
253  typedef typename MovingImageType::IndexType MovingImageIndexType;
254  typedef typename TransformType::InputPointType FixedImagePointType;
255  typedef typename TransformType::OutputPointType MovingImagePointType;
256  typedef typename InterpolatorType::ContinuousIndexType MovingImageContinuousIndexType;
257 
265  typedef typename BSplineInterpolatorType::CovariantVectorType MovingImageDerivativeType;
266  typedef GradientImageFilter<
268 
270  typedef typename
272 
278 
283  typename BSplineInterpolatorType::Pointer m_BSplineInterpolator;
284  typename BSplineInterpolatorFloatType::Pointer m_BSplineInterpolatorFloat;
286  typename CentralDifferenceGradientFilterType::Pointer m_CentralDifferenceGradientFilter;
287 
291 
303 
309  virtual void InitializeImageSampler( void ) throw ( ExceptionObject );
310 
313  itkSetMacro( UseImageSampler, bool );
314 
317  virtual void CheckNumberOfSamples(
318  unsigned long wanted, unsigned long found ) const;
319 
324  virtual void CheckForBSplineInterpolator( void );
325 
334  const MovingImagePointType & mappedPoint,
335  RealType & movingImageValue,
336  MovingImageDerivativeType * gradient ) const;
337 
341  virtual void CheckForAdvancedTransform( void );
342 
347  virtual bool TransformPoint(
348  const FixedImagePointType & fixedImagePoint,
349  MovingImagePointType & mappedPoint ) const;
350 
357  virtual bool EvaluateTransformJacobian(
358  const FixedImagePointType & fixedImagePoint,
359  TransformJacobianType & jacobian,
360  NonZeroJacobianIndicesType & nzji ) const;
361 
363  virtual bool IsInsideMovingMask( const MovingImagePointType & point ) const;
364 
370  virtual void ComputeFixedImageExtrema(
371  const FixedImageType * image,
372  const FixedImageRegionType & region );
373 
377  virtual void ComputeMovingImageExtrema(
378  const MovingImageType * image,
379  const MovingImageRegionType & region );
380 
383  virtual void InitializeLimiters( void );
384 
387  itkSetMacro( UseFixedImageLimiter, bool );
388  itkSetMacro( UseMovingImageLimiter, bool );
389 
390 private:
391  AdvancedImageToImageMetric(const Self&); //purposely not implemented
392  void operator=(const Self&); //purposely not implemented
393 
403 
404 }; // end class AdvancedImageToImageMetric
405 
406 } // end namespace itk
407 
408 #ifndef ITK_MANUAL_INSTANTIATION
409 #include "itkAdvancedImageToImageMetric.hxx"
410 #endif
411 
412 #endif // end #ifndef __itkAdvancedImageToImageMetric_h
413 
void PrintSelf(std::ostream &os, Indent indent) const
ImageToImageMetric< TFixedImage, TMovingImage > Superclass
virtual bool TransformPoint(const FixedImagePointType &fixedImagePoint, MovingImagePointType &mappedPoint) const
ReducedDimensionBSplineInterpolateImageFunction< MovingImageType, CoordinateRepresentationType, double > ReducedBSplineInterpolatorType
const AdvancedTransformType * GetTransform(void) const
MovingImageDerivativeScalesType m_MovingImageDerivativeScales
AdvancedTransform< ScalarType, FixedImageDimension, MovingImageDimension > AdvancedTransformType
virtual void CheckForAdvancedTransform(void)
virtual bool IsInsideMovingMask(const MovingImagePointType &point) const
SmartPointer< Self > Pointer
Superclass::CoordinateRepresentationType CoordinateRepresentationType
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...
virtual void CheckForBSplineInterpolator(void)
std::vector< unsigned long > NonZeroJacobianIndicesType
virtual void ComputeFixedImageExtrema(const FixedImageType *image, const FixedImageRegionType &region)
virtual void InitializeLimiters(void)
BSplineInterpolateImageFunction< MovingImageType, CoordinateRepresentationType, double > BSplineInterpolatorType
CentralDifferenceGradientFilterType::Pointer m_CentralDifferenceGradientFilter
Superclass::GradientPixelType GradientPixelType
FixedImageLimiterType::Pointer m_FixedImageLimiter
FixedImageLimiterOutputType m_FixedImageMinLimit
FixedImageLimiterType::OutputType FixedImageLimiterOutputType
Superclass::FixedImageRegionType FixedImageRegionType
AdvancedTransformType::Pointer m_AdvancedTransform
ImageSamplerType::OutputVectorContainerType ImageSampleContainerType
MovingImageType::IndexType MovingImageIndexType
MovingImageLimiterType::Pointer m_MovingImageLimiter
InterpolatorType::ContinuousIndexType MovingImageContinuousIndexType
BSplineInterpolatorType::Pointer m_BSplineInterpolator
TransformType::InputPointType FixedImagePointType
This class is a base class for any image sampler.
ImageSamplerBase< FixedImageType > ImageSamplerType
FixedImageLimiterOutputType m_FixedImageMaxLimit
SmartPointer< Self > Pointer
AdvancedTransformType::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
Define a front-end to the STL &quot;vector&quot; container that conforms to the IndexedContainerInterface.
MovingImageLimiterOutputType m_MovingImageMaxLimit
Superclass::InterpolatorPointer InterpolatorPointer
Transform maps points, vectors and covariant vectors from an input space to an output space...
vnl_sparse_matrix< HessianValueType > HessianType
FixedArray< double, itkGetStaticConstMacro(MovingImageDimension) > MovingImageDerivativeScalesType
Superclass::OutputVectorContainerPointer OutputVectorContainerPointer
FixedImageIndexType::IndexValueType FixedImageIndexValueType
TransformType::OutputPointType MovingImagePointType
LimiterFunctionBase< RealType, FixedImageDimension > FixedImageLimiterType
Superclass::MovingImageMaskType MovingImageMaskType
Superclass::GradientImageType GradientImageType
Evaluates the B-Spline interpolation of an image. Spline order may be from 0 to 5.
Superclass::TransformPointer TransformPointer
BSplineInterpolatorFloatType::Pointer m_BSplineInterpolatorFloat
BSplineInterpolateImageFunction< MovingImageType, CoordinateRepresentationType, float > BSplineInterpolatorFloatType
Superclass::GradientImageFilterType GradientImageFilterType
MovingImageType::RegionType MovingImageRegionType
MovingImageLimiterOutputType m_MovingImageMinLimit
Superclass::InterpolatorType InterpolatorType
Base class for all ITK limiter function objects.
Superclass::TransformJacobianType TransformJacobianType
virtual void CheckNumberOfSamples(unsigned long wanted, unsigned long found) const
virtual void ComputeMovingImageExtrema(const MovingImageType *image, const MovingImageRegionType &region)
GradientImageFilter< MovingImageType, RealType, RealType > CentralDifferenceGradientFilterType
Superclass::MovingImagePixelType MovingImagePixelType
SmartPointer< Self > Pointer
virtual bool EvaluateMovingImageValueAndDerivative(const MovingImagePointType &mappedPoint, RealType &movingImageValue, MovingImageDerivativeType *gradient) const
virtual void GetSelfHessian(const TransformParametersType &parameters, HessianType &H) const
Superclass::MovingImageMaskPointer MovingImageMaskPointer
MovingImageLimiterType::OutputType MovingImageLimiterOutputType
virtual void Initialize(void)
LimiterFunctionBase< RealType, MovingImageDimension > MovingImageLimiterType
ImageSamplerType::OutputVectorContainerPointer ImageSampleContainerPointer
Superclass::FixedImageMaskType FixedImageMaskType
virtual ImageSamplerType * GetImageSampler(void) const
ReducedBSplineInterpolatorType::Pointer m_ReducedBSplineInterpolator
itkStaticConstMacro(MovingImageDimension, unsigned int, TMovingImage::ImageDimension)
BSplineInterpolatorType::CovariantVectorType MovingImageDerivativeType
Superclass::OutputType OutputType
Superclass::FixedImageConstPointer FixedImageConstPointer
Superclass::MovingImageConstPointer MovingImageConstPointer
virtual void InitializeImageSampler(void)
virtual void SetTransform(AdvancedTransformType *arg)
virtual bool EvaluateTransformJacobian(const FixedImagePointType &fixedImagePoint, TransformJacobianType &jacobian, NonZeroJacobianIndicesType &nzji) const
Superclass::GradientImageFilterPointer GradientImageFilterPointer
Superclass::GradientImagePointer GradientImagePointer


Generated on 06-12-2013 for elastix by doxygen 1.8.5 elastix logo