File: itkExponentialDeformationFieldImageFilter.h

package info (click to toggle)
insighttoolkit 3.20.1%2Bgit20120521-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 80,652 kB
  • sloc: cpp: 458,133; ansic: 196,223; fortran: 28,000; python: 3,839; tcl: 1,811; sh: 1,184; java: 583; makefile: 430; csh: 220; perl: 193; xml: 20
file content (197 lines) | stat: -rw-r--r-- 7,650 bytes parent folder | download | duplicates (2)
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
/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    itkExponentialDeformationFieldImageFilter.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 __itkExponentialDeformationFieldImageFilter_h
#define __itkExponentialDeformationFieldImageFilter_h

#include "itkImageToImageFilter.h"
#include "itkDivideByConstantImageFilter.h"
#include "itkCastImageFilter.h"
#include "itkWarpVectorImageFilter.h"
#include "itkVectorLinearInterpolateNearestNeighborExtrapolateImageFunction.h"
#include "itkAddImageFilter.h"


namespace itk
{

/** \class ExponentialDeformationFieldImageFilter
 * \brief Computes a diffeomorphic deformation field as the Lie group
 * exponential of a vector field.
 *
 * ExponentialDeformationFieldImageFilter takes a 'smooth' vector field
 * as input and computes the deformation field that is its exponential.
 *
 * Given that both the input and output deformation field are represented as
 * discrete images with pixel type vector, the exponential will be only an
 * estimation and will probably not correspond to a perfect exponential.  The
 * precision of the exponential can be improved at the price of increasing the
 * computation time (number of iterations).
 *
 * The method used for computing the exponential deformation field is
 * an iterative scaling and squaring (cf Arsigny et al., "A
 * Log-Euclidean Framework for Statistics on Diffeomorphisms", MICCAI'06).
 *
 *    \f[
 *      exp(\Phi) = exp( \frac{\Phi}{2^N} )^{2^N}
 *    \f]
 *
 *
 * This filter expects both the input and output images to be of pixel type
 * Vector.
 *
 * \author Tom Vercauteren, INRIA & Mauna Kea Technologies
 *
 * This implementation was taken from the Insight Journal paper:
 * http://hdl.handle.net/1926/510
 *
 * \ingroup ImageToImageFilter
 */
template <class TInputImage, class TOutputImage>
class ITK_EXPORT ExponentialDeformationFieldImageFilter:
      public ImageToImageFilter<TInputImage, TOutputImage>
{
public:
  /** Standard class typedefs. */
  typedef ExponentialDeformationFieldImageFilter         Self;
  typedef ImageToImageFilter<TInputImage,TOutputImage>   Superclass;
  typedef SmartPointer<Self>                             Pointer;
  typedef SmartPointer<const Self>                       ConstPointer;

  /** Method for creation through the object factory. */
  itkNewMacro(Self);

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

  /** Some convenient typedefs. */
  typedef TInputImage                                  InputImageType;
  typedef typename InputImageType::Pointer             InputImagePointer;
  typedef typename InputImageType::ConstPointer        InputImageConstPointer;
  typedef typename InputImageType::PixelType           InputPixelType;
  typedef typename InputPixelType::RealValueType       InputPixelRealValueType;

  typedef TOutputImage                                 OutputImageType;
  typedef typename OutputImageType::Pointer            OutputImagePointer;
  typedef typename OutputImageType::PixelType          OutputPixelType;

  /** Specify the maximum number of iteration. */
  itkSetMacro(MaximumNumberOfIterations, unsigned int);
  itkGetConstMacro(MaximumNumberOfIterations, unsigned int);

  /** If AutomaticNumberOfIterations is off, the number of iterations is
   * given by MaximumNumberOfIterations. If it is on, we try to get
   * the lowest good number (which may not be larger than
   * MaximumNumberOfIterations ) */
  itkSetMacro( AutomaticNumberOfIterations, bool );
  itkGetConstMacro( AutomaticNumberOfIterations, bool );
  itkBooleanMacro(AutomaticNumberOfIterations);

  /** If ComputeInverse is on, the filter will compute the exponential
   * of the opposite (minus) of the input vector field. The output deformation
   * fields computed with ComputeInverse set to on and off respectively
   * therefore represent spatial transformations that are inverses of
   * each other. */
  itkSetMacro( ComputeInverse, bool );
  itkGetConstMacro( ComputeInverse, bool );
  itkBooleanMacro(ComputeInverse);

  /** Image dimension. */
  itkStaticConstMacro(ImageDimension, unsigned int,
                      TInputImage::ImageDimension);
  itkStaticConstMacro(OutputImageDimension, unsigned int,
                      TInputImage::ImageDimension );
  itkStaticConstMacro(PixelDimension, unsigned int,
                      InputPixelType::Dimension );
  itkStaticConstMacro(OutputPixelDimension, unsigned int,
                      OutputPixelType::Dimension );


#ifdef ITK_USE_CONCEPT_CHECKING
   /** Begin concept checking */
   itkConceptMacro(OutputHasNumericTraitsCheck,
                   (Concept::HasNumericTraits<typename OutputPixelType::ValueType>));
   itkConceptMacro(SameDimensionCheck1,
                   (Concept::SameDimension<ImageDimension,OutputImageDimension>));
   itkConceptMacro(SameDimensionCheck2,
                   (Concept::SameDimension<ImageDimension,PixelDimension>));
   itkConceptMacro(SameDimensionCheck3,
                   (Concept::SameDimension<ImageDimension,OutputPixelDimension>));
   /** End concept checking */
#endif

protected:
  ExponentialDeformationFieldImageFilter();
  virtual ~ExponentialDeformationFieldImageFilter() {};

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

  /**
   * GenerateData()
   */
  void GenerateData();

  typedef typename InputImageType::RegionType          RegionType;

  typedef DivideByConstantImageFilter<
    InputImageType,
    InputPixelRealValueType, OutputImageType >         DivideByConstantType;

  typedef CastImageFilter<
    InputImageType, OutputImageType>                   CasterType;

  typedef WarpVectorImageFilter<
    OutputImageType,
    OutputImageType, OutputImageType>                  VectorWarperType;

  typedef VectorLinearInterpolateNearestNeighborExtrapolateImageFunction<
    OutputImageType,double>                            FieldInterpolatorType;

  typedef AddImageFilter<
    OutputImageType, OutputImageType, OutputImageType> AdderType;

  typedef typename DivideByConstantType::Pointer       DivideByConstantPointer;
  typedef typename CasterType::Pointer                 CasterPointer;
  typedef typename VectorWarperType::Pointer           VectorWarperPointer;
  typedef typename FieldInterpolatorType::Pointer      FieldInterpolatorPointer;
  typedef typename FieldInterpolatorType::OutputType   FieldInterpolatorOutputType;
  typedef typename AdderType::Pointer                  AdderPointer;


private:
  ExponentialDeformationFieldImageFilter(const Self&); //purposely not implemented
  void operator=(const Self&); //purposely not implemented

  bool                       m_AutomaticNumberOfIterations;
  unsigned int               m_MaximumNumberOfIterations;

  bool                       m_ComputeInverse;

  DivideByConstantPointer    m_Divider;
  CasterPointer              m_Caster;
  VectorWarperPointer        m_Warper;
  AdderPointer               m_Adder;
};


} // end namespace itk

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

#endif