This file is indexed.

/usr/include/InsightToolkit/Review/itkOptImageToImageMetric.h is in libinsighttoolkit3-dev 3.20.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    itkOptImageToImageMetric.h
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) Insight Software Consortium. All rights reserved.
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef __itkOptImageToImageMetric_h
#define __itkOptImageToImageMetric_h

#include "itkSingleValuedCostFunction.h"
#include "itkImageBase.h"
#include "itkTransform.h"
#include "itkInterpolateImageFunction.h"
#include "itkExceptionObject.h"
#include "itkGradientRecursiveGaussianImageFilter.h"
#include "itkSpatialObject.h"
#include "itkBSplineDeformableTransform.h"
#include "itkCentralDifferenceImageFunction.h"
#include "itkCovariantVector.h"

#include "itkMultiThreader.h"

#include "itkOptBSplineInterpolateImageFunction.h"

namespace itk
{
  
/** \class ImageToImageMetric
 * \brief Computes similarity between regions of two images.
 *
 * This Class is templated over the type of the two input images.
 * It expects a Transform and an Interpolator to be plugged in.
 * This particular class is the base class for a hierarchy of 
 * similarity metrics.
 *
 * This class computes a value that measures the similarity 
 * between the Fixed image and the transformed Moving image.
 * The Interpolator is used to compute intensity values on 
 * non-grid positions resulting from mapping points through 
 * the Transform.
 * 
 *
 * \ingroup RegistrationMetrics
 *
 */

template <class TFixedImage,  class TMovingImage> 
class ITK_EXPORT ImageToImageMetric 
: public SingleValuedCostFunction 
{
public:
  /** Standard class typedefs. */
  typedef ImageToImageMetric           Self;
  typedef SingleValuedCostFunction     Superclass;
  typedef SmartPointer<Self>           Pointer;
  typedef SmartPointer<const Self>     ConstPointer;

  /** Type used for representing point components  */
  typedef typename Superclass::ParametersValueType CoordinateRepresentationType;

  /** Run-time type information (and related methods). */
  itkTypeMacro(ImageToImageMetric, SingleValuedCostFunction);

  /**  Type of the moving Image. */
  typedef TMovingImage                               MovingImageType;
  typedef typename TMovingImage::PixelType           MovingImagePixelType;
  typedef typename MovingImageType::ConstPointer     MovingImageConstPointer;

  /**  Type of the fixed Image. */
  typedef TFixedImage                                FixedImageType;
  typedef typename TFixedImage::PixelType            FixedImagePixelType;
  typedef typename FixedImageType::ConstPointer      FixedImageConstPointer;
  typedef typename FixedImageType::RegionType        FixedImageRegionType;

  /** Constants for the image dimensions */
  itkStaticConstMacro(MovingImageDimension, 
                      unsigned int,
                      TMovingImage::ImageDimension);
  itkStaticConstMacro(FixedImageDimension, 
                      unsigned int,
                      TFixedImage::ImageDimension);
  
  /**  Type of the Transform Base class */
  typedef Transform<CoordinateRepresentationType, 
                    itkGetStaticConstMacro(MovingImageDimension),
                    itkGetStaticConstMacro(FixedImageDimension)> 
                                                     TransformType;

  typedef typename TransformType::Pointer            TransformPointer;
  typedef typename TransformType::InputPointType     InputPointType;
  typedef typename TransformType::OutputPointType    OutputPointType;
  typedef typename TransformType::ParametersType     TransformParametersType;
  typedef typename TransformType::JacobianType       TransformJacobianType;

    /** Index and Point typedef support. */
  typedef typename FixedImageType::IndexType           FixedImageIndexType;
  typedef typename FixedImageIndexType::IndexValueType FixedImageIndexValueType;
  typedef typename MovingImageType::IndexType          MovingImageIndexType;
  typedef typename TransformType::InputPointType       FixedImagePointType;
  typedef typename TransformType::OutputPointType      MovingImagePointType;

  typedef std::vector<FixedImageIndexType>             FixedImageIndexContainer;

  /**  Type of the Interpolator Base class */
  typedef InterpolateImageFunction< MovingImageType, 
                                    CoordinateRepresentationType >
                                                     InterpolatorType;

  /** Gaussian filter to compute the gradient of the Moving Image */
  typedef typename NumericTraits<MovingImagePixelType>::RealType 
                                                     RealType;
  typedef CovariantVector<RealType,
                          itkGetStaticConstMacro(MovingImageDimension)>
                                                     GradientPixelType;
  typedef Image<GradientPixelType,
                itkGetStaticConstMacro(MovingImageDimension)> 
                                                     GradientImageType;
  typedef SmartPointer<GradientImageType>            GradientImagePointer;
  typedef GradientRecursiveGaussianImageFilter< MovingImageType,
                                                GradientImageType >
                                                     GradientImageFilterType;  
  typedef typename GradientImageFilterType::Pointer  GradientImageFilterPointer;


  typedef typename InterpolatorType::Pointer         InterpolatorPointer;


  /**  Type for the mask of the fixed image. Only pixels that are "inside"
       this mask will be considered for the computation of the metric */
  typedef SpatialObject< itkGetStaticConstMacro(FixedImageDimension) >
                                                     FixedImageMaskType;
  typedef typename FixedImageMaskType::Pointer       FixedImageMaskPointer;
  typedef typename FixedImageMaskType::ConstPointer  FixedImageMaskConstPointer;

  /**  Type for the mask of the moving image. Only pixels that are "inside"
       this mask will be considered for the computation of the metric */
  typedef SpatialObject< itkGetStaticConstMacro(MovingImageDimension) >
                                                     MovingImageMaskType;
  typedef typename MovingImageMaskType::Pointer      MovingImageMaskPointer;
  typedef typename MovingImageMaskType::ConstPointer MovingImageMaskConstPointer;


  /**  Type of the measure. */
  typedef typename Superclass::MeasureType                    MeasureType;

  /**  Type of the derivative. */
  typedef typename Superclass::DerivativeType                 DerivativeType;

  /**  Type of the parameters. */
  typedef typename Superclass::ParametersType                 ParametersType;

  /** Connect the Fixed Image.  */
  itkSetConstObjectMacro( FixedImage, FixedImageType );

  /** Get the Fixed Image. */
  itkGetConstObjectMacro( FixedImage, FixedImageType );

  /** Connect the Moving Image.  */
  itkSetConstObjectMacro( MovingImage, MovingImageType );

  /** Get the Moving Image. */
  itkGetConstObjectMacro( MovingImage, MovingImageType );

  /** Connect the Transform. */
  itkSetObjectMacro( Transform, TransformType );

  /** Get a pointer to the Transform.  */
  itkGetConstObjectMacro( Transform, TransformType );
 
  /** Connect the Interpolator. */
  itkSetObjectMacro( Interpolator, InterpolatorType );

  /** Get a pointer to the Interpolator.  */
  itkGetConstObjectMacro( Interpolator, InterpolatorType );

  /** Get the number of pixels considered in the computation. */
  unsigned long GetNumberOfMovingImageSamples( void )
    {
    return this->GetNumberOfPixelsCounted();
    }
  itkGetConstReferenceMacro( NumberOfPixelsCounted, unsigned long );

  /** Set the region over which the metric will be computed */
  void SetFixedImageRegion( const FixedImageRegionType reg );

  /** Get the region over which the metric will be computed */
  itkGetConstReferenceMacro( FixedImageRegion, FixedImageRegionType );
 
  /** Set/Get the moving image mask. */
  itkSetObjectMacro( MovingImageMask, MovingImageMaskType );
  itkSetConstObjectMacro( MovingImageMask, MovingImageMaskType );
  itkGetConstObjectMacro( MovingImageMask, MovingImageMaskType );

  /** Set/Get the fixed image mask. */
  itkSetObjectMacro( FixedImageMask, FixedImageMaskType );
  itkSetConstObjectMacro( FixedImageMask, FixedImageMaskType );
  itkGetConstObjectMacro( FixedImageMask, FixedImageMaskType );

  /** Set the fixed image indexes to be used as the samples when
   *   computing the match metric */
  void SetFixedImageIndexes( const FixedImageIndexContainer & indexes );
  void SetUseFixedImageIndexes( bool useIndex );
  itkGetConstReferenceMacro( UseFixedImageIndexes, bool );

  /** Set/Get number of threads to use for computations. */
  void SetNumberOfThreads( unsigned int numberOfThreads );
  itkGetConstReferenceMacro( NumberOfThreads, unsigned int );

  /** Set/Get gradient computation. */
  itkSetMacro( ComputeGradient, bool );
  itkGetConstReferenceMacro( ComputeGradient, bool );
  itkBooleanMacro(ComputeGradient );

  /** Computes the gradient image and assigns it to m_GradientImage */
  virtual void ComputeGradient( void );

  /** Get Gradient Image. */
  itkGetConstObjectMacro( GradientImage, GradientImageType );

  /** Set the parameters defining the Transform. */
  void SetTransformParameters( const ParametersType & parameters ) const;

  /** Return the number of parameters required by the Transform */
  unsigned int GetNumberOfParameters( void ) const 
    {
    return m_Transform->GetNumberOfParameters(); 
    }

  /** Initialize the Metric by making sure that all the components
   *  are present and plugged together correctly     */
  virtual void Initialize( void ) throw ( ExceptionObject );

  /** Initialize the components related to supporting multiple threads */
  virtual void MultiThreadingInitialize( void ) throw ( ExceptionObject );

  /** Number of spatial samples to used to compute metric 
   *   This sets the number of samples.  */
  virtual void SetNumberOfFixedImageSamples( unsigned long numSamples );
  itkGetConstReferenceMacro( NumberOfFixedImageSamples, unsigned long ); 

  /** Number of spatial samples to used to compute metric 
   *   This sets the number of samples.  */
  void SetNumberOfSpatialSamples( unsigned long num )
    {
    this->SetNumberOfFixedImageSamples( num ); 
    }
  unsigned long GetNumberOfSpatialSamples( void )
    {
    return this->GetNumberOfFixedImageSamples(); 
    }

  /** Minimum fixed-image intensity needed for a sample to be used in the
   *  metric computation */
  void SetFixedImageSamplesIntensityThreshold( const FixedImagePixelType & thresh );
  itkGetConstReferenceMacro( FixedImageSamplesIntensityThreshold, FixedImagePixelType );

  void SetUseFixedImageSamplesIntensityThreshold( bool useThresh );
  itkGetConstReferenceMacro( UseFixedImageSamplesIntensityThreshold, bool );

  /** Select whether the metric will be computed using all the pixels on the
   * fixed image region, or only using a set of randomly selected pixels. 
   * This value override IntensityThreshold, Masks, and SequentialSampling. */
  void SetUseAllPixels( bool useAllPixels );
  void UseAllPixelsOn( void )
    {
    this->SetUseAllPixels( true );
    }
  void UseAllPixelsOff( void )
    {
    this->SetUseAllPixels( false );
    }
  itkGetConstReferenceMacro( UseAllPixels, bool );

  /** If set to true, then every pixel in the fixed image will be scanned to
   * determine if it should be used in registration metric computation.  A
   * pixel will be chosen if it meets any mask or threshold limits set.  If
   * set to false, then UseAllPixels will be set to false. */
  void SetUseSequentialSampling( bool sequentialSampling );
  itkGetConstReferenceMacro( UseSequentialSampling, bool );

  /** Reinitialize the seed of the random number generator that selects the
   * sample of pixels used for estimating the image histograms and the joint
   * histogram. By nature, this metric is not deterministic, since at each run
   * it may select a different set of pixels. By initializing the random number
   * generator seed to the same value you can restore determinism. On the other
   * hand, calling the method ReinitializeSeed() without arguments will use the
   * clock from your machine in order to have a very random initialization of
   * the seed. This will indeed increase the non-deterministic behavior of the
   * metric. */
  void ReinitializeSeed();
  void ReinitializeSeed( int seed );  

  /** This boolean flag is only relevant when this metric is used along
   * with a BSplineDeformableTransform. The flag enables/disables the
   * caching of values computed when a physical point is mapped through
   * the BSplineDeformableTransform. In particular it will cache the
   * values of the BSpline weights for that points, and the indexes
   * indicating what BSpline-grid nodes are relevant for that specific
   * point. This caching is made optional due to the fact that the
   * memory arrays used for the caching can reach large sizes even for
   * moderate image size problems. For example, for a 3D image of
   * 256^3, using 20% of pixels, these arrays will take about 1
   * Gigabyte of RAM for storage. The ratio of computing time between
   * using the cache or not using the cache can reach 1:5, meaning that
   * using the caching can provide a five times speed up. It is
   * therefore, interesting to enable the caching, if enough memory is
   * available for it. The caching is enabled by default, in order to
   * preserve backward compatibility with previous versions of ITK. */
  itkSetMacro(UseCachingOfBSplineWeights,bool);
  itkGetConstReferenceMacro(UseCachingOfBSplineWeights,bool);
  itkBooleanMacro(UseCachingOfBSplineWeights);
      
  typedef MultiThreader               MultiThreaderType;
  /** Get the Threader. */
  itkGetConstObjectMacro( Threader, MultiThreaderType );
  const TransformPointer* GetThreaderTransform()
    {
    return m_ThreaderTransform;
    }

protected:
  ImageToImageMetric();
  virtual ~ImageToImageMetric();

  void PrintSelf(std::ostream& os, Indent indent) const;

  /** \class FixedImageSamplePoint 
   * A fixed image spatial sample consists of the fixed domain point 
   * and the fixed image value at that point. */
  /// @cond 
  class FixedImageSamplePoint
    {
    public:
    FixedImageSamplePoint()
      { 
      point.Fill(0.0);
      value = 0;
      valueIndex = 0;
      }
    ~FixedImageSamplePoint() {};

    public:
      FixedImagePointType           point;
      double                        value;
      unsigned int                  valueIndex;
    };
  /// @endcond 
  
  bool                      m_UseFixedImageIndexes;
  FixedImageIndexContainer  m_FixedImageIndexes;

  bool                      m_UseFixedImageSamplesIntensityThreshold;
  FixedImagePixelType       m_FixedImageSamplesIntensityThreshold;

  /** FixedImageSamplePoint typedef support. */
  typedef std::vector<FixedImageSamplePoint> FixedImageSampleContainer;

  /** Uniformly select a sample set from the fixed image domain. */
  virtual void SampleFixedImageRegion( FixedImageSampleContainer & samples) const;

  virtual void SampleFixedImageIndexes( FixedImageSampleContainer & 
                                           samples) const;

  /** Gather all the pixels from the fixed image domain. */
  virtual void SampleFullFixedImageRegion( FixedImageSampleContainer & 
                                           samples) const;

  /** Container to store a set of points and fixed image values. */
  FixedImageSampleContainer   m_FixedImageSamples;

  unsigned long               m_NumberOfParameters;
  mutable ParametersType      m_Parameters;

  unsigned long               m_NumberOfFixedImageSamples;
  //m_NumberOfPixelsCounted must be mutable because the const
  //thread consolidation functions merge each threads valus
  //onto this accumulator variable.
  mutable unsigned long       m_NumberOfPixelsCounted;

  FixedImageConstPointer      m_FixedImage;
  MovingImageConstPointer     m_MovingImage;

  /** Main transform to be used in thread = 0 */
  TransformPointer            m_Transform;
  /** Copies of Transform helpers per thread (N-1 of them, since m_Transform
   * will do the work for thread=0. */
  TransformPointer          * m_ThreaderTransform; 

  InterpolatorPointer         m_Interpolator;

  bool                        m_ComputeGradient;
  GradientImagePointer        m_GradientImage;

  FixedImageMaskConstPointer  m_FixedImageMask;
  MovingImageMaskConstPointer m_MovingImageMask;

  unsigned int                m_NumberOfThreads;

  bool                        m_UseAllPixels;
  bool                        m_UseSequentialSampling;

  bool                        m_ReseedIterator;

  int                         m_RandomSeed;

 /** Types and variables related to BSpline deformable transforms.
   * If the transform is of type third order BSplineDeformableTransform,
   * then we can speed up the metric derivative calculation by
   * only inspecting the parameters within the support region
   * of a mapped point.  */

  /** Boolean to indicate if the transform is BSpline deformable. */
  bool                        m_TransformIsBSpline;

  /** The number of BSpline transform weights is the number of
    * of parameter in the support region (per dimension ). */   
  unsigned long               m_NumBSplineWeights;

  itkStaticConstMacro(DeformationSplineOrder, unsigned int, 3 );

  typedef BSplineDeformableTransform< CoordinateRepresentationType,
                      ::itk::GetImageDimension<FixedImageType>::ImageDimension,
                                      itkGetStaticConstMacro(DeformationSplineOrder) >             BSplineTransformType;

  typedef typename BSplineTransformType::WeightsType       BSplineTransformWeightsType;
  typedef typename BSplineTransformWeightsType::ValueType  WeightsValueType;
  typedef          Array2D<WeightsValueType>               BSplineTransformWeightsArrayType;

  typedef typename BSplineTransformType::ParameterIndexArrayType 
                                                              BSplineTransformIndexArrayType;
  typedef typename BSplineTransformIndexArrayType::ValueType  IndexValueType;
  typedef          Array2D<IndexValueType>                    BSplineTransformIndicesArrayType;

  typedef          std::vector<MovingImagePointType>          MovingImagePointArrayType;
  typedef          std::vector<bool>                          BooleanArrayType;
  typedef          FixedArray< unsigned long, 
                               ::itk::GetImageDimension<FixedImageType>
                                ::ImageDimension >            BSplineParametersOffsetType;
  /**
   * If a BSplineInterpolationFunction is used, this class obtain
   * image derivatives from the BSpline interpolator. Otherwise, 
   * image derivatives are computed using central differencing.
   */
  typedef BSplineInterpolateImageFunction<MovingImageType,
                                             CoordinateRepresentationType> 
                                                       BSplineInterpolatorType;
  /** Typedefs for using central difference calculator. */
  typedef CentralDifferenceImageFunction<MovingImageType,
                                         CoordinateRepresentationType> 
                                                       DerivativeFunctionType;
  typedef          CovariantVector< double,
                           itkGetStaticConstMacro(MovingImageDimension) >
                                                          ImageDerivativesType;


  typename BSplineTransformType::Pointer   m_BSplineTransform;

  BSplineTransformWeightsArrayType         m_BSplineTransformWeightsArray;
  BSplineTransformIndicesArrayType         m_BSplineTransformIndicesArray;
  MovingImagePointArrayType                m_BSplinePreTransformPointsArray;
  BooleanArrayType                         m_WithinBSplineSupportRegionArray;
  
  BSplineParametersOffsetType              m_BSplineParametersOffset;

  // Variables needed for optionally caching values when using a BSpline transform.
  bool                                    m_UseCachingOfBSplineWeights;
  mutable BSplineTransformWeightsType     m_BSplineTransformWeights;
  mutable BSplineTransformIndexArrayType  m_BSplineTransformIndices;

  mutable BSplineTransformWeightsType     * m_ThreaderBSplineTransformWeights;
  mutable BSplineTransformIndexArrayType  * m_ThreaderBSplineTransformIndices;

  virtual void PreComputeTransformValues( void );

  /** Transform a point from FixedImage domain to MovingImage domain.
   * This function also checks if mapped point is within support region. */
  virtual void TransformPoint( unsigned int sampleNumber,
                               MovingImagePointType& mappedPoint,
                               bool& sampleWithinSupportRegion,
                               double& movingImageValue,
                               unsigned int threadID ) const;

  virtual void TransformPointWithDerivatives( unsigned int sampleNumber,
                               MovingImagePointType& mappedPoint,
                               bool& sampleWithinSupportRegion,
                               double& movingImageValue,
                               ImageDerivativesType & gradient,
                               unsigned int threadID ) const;

  /** Boolean to indicate if the interpolator BSpline. */
  bool                                       m_InterpolatorIsBSpline;
  /** Pointer to BSplineInterpolator. */
  typename BSplineInterpolatorType::Pointer  m_BSplineInterpolator;

  /** Pointer to central difference calculator. */
  typename DerivativeFunctionType::Pointer   m_DerivativeCalculator;

  /** Compute image derivatives at a point. */
  virtual void ComputeImageDerivatives( const MovingImagePointType & mappedPoint,
                                        ImageDerivativesType & gradient,
                                        unsigned int threadID ) const;


  /**
   * Types and variables related to multi-threading
   */

  struct MultiThreaderParameterType
    {
    ImageToImageMetric                   * metric;
    };

  MultiThreaderType::Pointer               m_Threader;
  MultiThreaderParameterType               m_ThreaderParameter;
  mutable unsigned int                   * m_ThreaderNumberOfMovingImageSamples;
  bool                                     m_WithinThreadPreProcess;
  bool                                     m_WithinThreadPostProcess;

  void                           GetValueMultiThreadedPreProcessInitiate( void ) const;
  void                           GetValueMultiThreadedInitiate( void ) const;
  void                           GetValueMultiThreadedPostProcessInitiate( void ) const;
  static ITK_THREAD_RETURN_TYPE  GetValueMultiThreadedPreProcess( void * arg );
  static ITK_THREAD_RETURN_TYPE  GetValueMultiThreaded( void * arg );
  static ITK_THREAD_RETURN_TYPE  GetValueMultiThreadedPostProcess( void * arg );

  virtual inline void       GetValueThread( unsigned int threadID ) const;
  virtual inline void       GetValueThreadPreProcess( 
                                 unsigned int itkNotUsed(threadID),
                                 bool itkNotUsed(withinSampleThread) ) const
    { };
  virtual inline bool       GetValueThreadProcessSample( 
                                 unsigned int itkNotUsed(threadID),
                                 unsigned long itkNotUsed(fixedImageSample),
                                 const MovingImagePointType & itkNotUsed(mappedPoint),
                                 double itkNotUsed(movingImageValue)) const
    { return false; };
  virtual inline void       GetValueThreadPostProcess( 
                                 unsigned int itkNotUsed(threadID),
                                 bool itkNotUsed(withinSampleThread) ) const
    { };
      
  void                          GetValueAndDerivativeMultiThreadedPreProcessInitiate( void ) const;
  void                          GetValueAndDerivativeMultiThreadedInitiate( void ) const;
  void                          GetValueAndDerivativeMultiThreadedPostProcessInitiate( void ) const;
  static ITK_THREAD_RETURN_TYPE GetValueAndDerivativeMultiThreadedPreProcess( void * arg );
  static ITK_THREAD_RETURN_TYPE GetValueAndDerivativeMultiThreaded(void * arg);
  static ITK_THREAD_RETURN_TYPE GetValueAndDerivativeMultiThreadedPostProcess(void * arg);

  virtual inline void  GetValueAndDerivativeThread(unsigned int threadID) const;
  virtual inline void  GetValueAndDerivativeThreadPreProcess(
                                unsigned int itkNotUsed(threadID),
                                bool itkNotUsed(withinSampleThread)) const 
    { };
  virtual inline bool  GetValueAndDerivativeThreadProcessSample( 
                                unsigned int itkNotUsed(threadID),
                                unsigned long itkNotUsed(fixedImageSample),
                                const MovingImagePointType & itkNotUsed(mappedPoint),
                                double itkNotUsed(movingImageValue),
                                const ImageDerivativesType & itkNotUsed(movingImageGradientValue) ) const
    { return false; }
  virtual inline void  GetValueAndDerivativeThreadPostProcess( 
                                unsigned int itkNotUsed(threadID),
                                bool itkNotUsed(withinSampleThread) ) const 
    { };

  /** Synchronizes the threader transforms with the transform
   *   member variable.
   */
  virtual void SynchronizeTransforms() const;

private:
  ImageToImageMetric(const Self&); //purposely not implemented
  void operator=(const Self&); //purposely not implemented
  
  FixedImageRegionType        m_FixedImageRegion;  

};

} // end namespace itk

#ifndef ITK_MANUAL_INSTANTIATION
#include "itkOptImageToImageMetric.txx"
#endif

#endif