Orfeo Toolbox  4.0
itkImageToImageMetric.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 #ifndef __itkImageToImageMetric_h
19 #define __itkImageToImageMetric_h
20 
25 #include "itkSpatialObject.h"
27 
28 namespace itk
29 {
50 template< typename TFixedImage, typename TMovingImage >
53 {
54 public:
60 
63 
66 
68  typedef TMovingImage MovingImageType;
69  typedef typename TMovingImage::PixelType MovingImagePixelType;
70  typedef typename MovingImageType::ConstPointer MovingImageConstPointer;
71 
73  typedef TFixedImage FixedImageType;
74  typedef typename TFixedImage::PixelType FixedImagePixelType;
75  typedef typename FixedImageType::ConstPointer FixedImageConstPointer;
76  typedef typename FixedImageType::RegionType FixedImageRegionType;
77 
79  itkStaticConstMacro(MovingImageDimension,
80  unsigned int,
81  TMovingImage::ImageDimension);
82  itkStaticConstMacro(FixedImageDimension,
83  unsigned int,
84  TFixedImage::ImageDimension);
85 
88  itkGetStaticConstMacro(MovingImageDimension),
89  itkGetStaticConstMacro(FixedImageDimension) >
91 
97 
99  typedef typename FixedImageType::IndexType FixedImageIndexType;
101  typedef typename MovingImageType::IndexType MovingImageIndexType;
104 
105  typedef std::vector< FixedImageIndexType > FixedImageIndexContainer;
106 
109 
117 
119 
125 
131 
134 
137 
140 
142  itkSetConstObjectMacro( FixedImage, FixedImageType );
143  itkGetConstObjectMacro(FixedImage, FixedImageType );
144 
146  itkSetConstObjectMacro( MovingImage, MovingImageType );
147  itkGetConstObjectMacro(MovingImage, MovingImageType );
148 
150  itkSetObjectMacro( Transform, TransformType );
151 
154 
156  itkSetObjectMacro(Interpolator, InterpolatorType);
157 
160 
163  {
164  return this->GetNumberOfPixelsCounted();
165  }
166 
167  itkGetConstReferenceMacro(NumberOfPixelsCounted, SizeValueType);
168 
170  virtual void SetFixedImageRegion(const FixedImageRegionType reg);
171 
173  itkGetConstReferenceMacro(FixedImageRegion, FixedImageRegionType);
174 
176  itkSetObjectMacro(MovingImageMask, MovingImageMaskType);
177  itkSetConstObjectMacro(MovingImageMask, MovingImageMaskType);
178  itkGetConstObjectMacro(MovingImageMask, MovingImageMaskType);
179 
181  itkSetObjectMacro(FixedImageMask, FixedImageMaskType);
182  itkSetConstObjectMacro(FixedImageMask, FixedImageMaskType);
183  itkGetConstObjectMacro(FixedImageMask, FixedImageMaskType);
184 
187  void SetFixedImageIndexes(const FixedImageIndexContainer & indexes);
188 
189  void SetUseFixedImageIndexes(bool useIndex);
190 
191  itkGetConstReferenceMacro(UseFixedImageIndexes, bool);
192 
194  void SetNumberOfThreads(ThreadIdType numberOfThreads);
195  itkGetConstReferenceMacro(NumberOfThreads, ThreadIdType);
196 
198  itkSetMacro(ComputeGradient, bool);
199  itkGetConstReferenceMacro(ComputeGradient, bool);
200  itkBooleanMacro(ComputeGradient);
201 
203  virtual void ComputeGradient(void);
204 
207 
209  void SetTransformParameters(const ParametersType & parameters) const;
210 
212  unsigned int GetNumberOfParameters(void) const
213  {
214  return m_Transform->GetNumberOfParameters();
215  }
216 
219  virtual void Initialize(void)
220  throw ( ExceptionObject );
221 
223  virtual void MultiThreadingInitialize(void) throw ( ExceptionObject );
224 
227  virtual void SetNumberOfFixedImageSamples(SizeValueType numSamples);
228  itkGetConstReferenceMacro(NumberOfFixedImageSamples, SizeValueType);
229 
232  void SetNumberOfSpatialSamples(SizeValueType num)
233  {
234  this->SetNumberOfFixedImageSamples(num);
235  }
236 
238  {
239  return this->GetNumberOfFixedImageSamples();
240  }
241 
245 
246  itkGetConstReferenceMacro(FixedImageSamplesIntensityThreshold, FixedImagePixelType);
247 
248  void SetUseFixedImageSamplesIntensityThreshold(bool useThresh);
249 
250  itkGetConstReferenceMacro(UseFixedImageSamplesIntensityThreshold, bool);
251 
255  void SetUseAllPixels(bool useAllPixels);
256 
257  void UseAllPixelsOn(void)
258  {
259  this->SetUseAllPixels(true);
260  }
261 
262  void UseAllPixelsOff(void)
263  {
264  this->SetUseAllPixels(false);
265  }
266 
267  itkGetConstReferenceMacro(UseAllPixels, bool);
268 
273  void SetUseSequentialSampling(bool sequentialSampling);
274 
275  itkGetConstReferenceMacro(UseSequentialSampling, bool);
276 
286  void ReinitializeSeed();
287  void ReinitializeSeed(int seed);
288 
305  itkSetMacro(UseCachingOfBSplineWeights, bool);
306  itkGetConstReferenceMacro(UseCachingOfBSplineWeights, bool);
307  itkBooleanMacro(UseCachingOfBSplineWeights);
308 
313  {
314  return m_ThreaderTransform;
315  }
316 
317 protected:
319  virtual ~ImageToImageMetric();
320 
321  void PrintSelf(std::ostream & os, Indent indent) const;
322 
329  {
330 public:
332  {
333  point.Fill(0.0);
334  value = 0;
335  valueIndex = 0;
336  }
337 
339 
340 public:
342  double value;
343  unsigned int valueIndex;
344  };
345 
348 
351 
353  typedef std::vector< FixedImageSamplePoint > FixedImageSampleContainer;
354 
356  virtual void SampleFixedImageRegion(FixedImageSampleContainer & samples) const;
357 
358  virtual void SampleFixedImageIndexes(FixedImageSampleContainer & samples) const;
359 
362  samples) const;
363 
366 
368 
370  //m_NumberOfPixelsCounted must be mutable because the const
371  //thread consolidation functions merge each threads valus
372  //onto this accumulator variable.
374 
377 
383 
385 
388 
391 
393 
396 
398 
400 
409 
413 
414  itkStaticConstMacro(DeformationSplineOrder, unsigned int, 3);
415 
417  FixedImageType ::ImageDimension,
418  itkGetStaticConstMacro(DeformationSplineOrder) > BSplineTransformType;
419 
423 
427 
428  typedef std::vector< MovingImagePointType > MovingImagePointArrayType;
429  typedef std::vector< bool > BooleanArrayType;
445 
447 
452 
454 
455  // Variables needed for optionally caching values when using a BSpline
456  // transform.
460 
463 
464  virtual void PreComputeTransformValues(void);
465 
468  virtual void TransformPoint(unsigned int sampleNumber,
469  MovingImagePointType & mappedPoint,
470  bool & sampleWithinSupportRegion,
471  double & movingImageValue,
472  ThreadIdType threadID) const;
473 
474  virtual void TransformPointWithDerivatives(unsigned int sampleNumber,
475  MovingImagePointType & mappedPoint,
476  bool & sampleWithinSupportRegion,
477  double & movingImageValue,
478  ImageDerivativesType & gradient,
479  ThreadIdType threadID) const;
480 
485 
488 
490  virtual void ComputeImageDerivatives(const MovingImagePointType & mappedPoint,
491  ImageDerivativesType & gradient,
492  ThreadIdType threadID) const;
493 
500  };
501 
504  mutable unsigned int * m_ThreaderNumberOfMovingImageSamples;
507 
509 
510  void GetValueMultiThreadedInitiate(void) const;
511 
513 
515 
517 
519 
520  virtual inline void GetValueThread(ThreadIdType threadID) const;
521 
522  virtual inline void GetValueThreadPreProcess(
523  ThreadIdType itkNotUsed(threadID),
524  bool itkNotUsed(withinSampleThread) ) const
525  {}
526  virtual inline bool GetValueThreadProcessSample(
527  ThreadIdType itkNotUsed(threadID),
528  SizeValueType itkNotUsed(fixedImageSample),
529  const MovingImagePointType & itkNotUsed(mappedPoint),
530  double itkNotUsed(movingImageValue) ) const
531  { return false; }
532  virtual inline void GetValueThreadPostProcess(
533  ThreadIdType itkNotUsed(threadID),
534  bool itkNotUsed(withinSampleThread) ) const
535  {}
536 
538 
540 
542 
544 
546 
548 
549  virtual inline void GetValueAndDerivativeThread(ThreadIdType threadID) const;
550 
552  ThreadIdType itkNotUsed(threadID),
553  bool itkNotUsed(withinSampleThread) ) const
554  {}
556  ThreadIdType itkNotUsed(threadID),
557  SizeValueType itkNotUsed(fixedImageSample),
558  const MovingImagePointType & itkNotUsed(mappedPoint),
559  double itkNotUsed(movingImageValue),
560  const ImageDerivativesType & itkNotUsed(movingImageGradientValue) ) const
561  { return false; }
563  ThreadIdType itkNotUsed(threadID),
564  bool itkNotUsed(withinSampleThread) ) const
565  {}
566 
570  virtual void SynchronizeTransforms() const;
571 
572 private:
573  ImageToImageMetric(const Self &); //purposely not implemented
574  void operator=(const Self &); //purposely not implemented
575 
577 };
578 } // end namespace itk
579 
580 #ifndef ITK_MANUAL_INSTANTIATION
581 #include "itkImageToImageMetric.hxx"
582 #endif
583 
584 #endif

Generated at Sat Mar 8 2014 14:54:46 for Orfeo Toolbox with doxygen 1.8.3.1