]> Creatis software - clitk.git/blob - itk/itkRayCastInterpolateImageFunctionWithOrigin.h
Merge branch 'master' into GammaIndex3D
[clitk.git] / itk / itkRayCastInterpolateImageFunctionWithOrigin.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
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 copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18 #ifndef __itkRayCastInterpolateImageFunctionWithOrigin_h
19 #define __itkRayCastInterpolateImageFunctionWithOrigin_h
20 #include "itkInterpolateImageFunction.h"
21 #include "itkTransform.h"
22 #include "itkVector.h"
23
24 namespace itk
25 {
26
27 /** \class RayCastInterpolateImageFunctionWithOrigin
28  * \brief Projective interpolation of an image at specified positions.
29  *
30  * RayCastInterpolateImageFunctionWithOrigin casts rays through a 3-dimensional
31  * image and uses bilinear interpolation to integrate each plane of
32  * voxels traversed.
33  * 
34  * \warning This interpolator works for 3-dimensional images only.
35  *
36  * \ingroup ImageFunctions
37  */
38 template <class TInputImage, class TCoordRep = float>
39 class ITK_EXPORT RayCastInterpolateImageFunctionWithOrigin : 
40     public InterpolateImageFunction<TInputImage,TCoordRep> 
41 {
42 public:
43   /** Standard class typedefs. */
44   typedef RayCastInterpolateImageFunctionWithOrigin                 Self;
45   typedef InterpolateImageFunction<TInputImage,TCoordRep> Superclass;
46   typedef SmartPointer<Self>                              Pointer;
47   typedef SmartPointer<const Self>                        ConstPointer;
48
49   /** Constants for the image dimensions */
50   itkStaticConstMacro(InputImageDimension, unsigned int,
51                       TInputImage::ImageDimension);
52
53   /** 
54    * Type of the Transform Base class 
55    * The fixed image should be a 3D image
56    */
57   typedef Transform<TCoordRep,3,3> TransformType;
58
59   typedef typename TransformType::Pointer            TransformPointer;
60   typedef typename TransformType::InputPointType     InputPointType;
61   typedef typename TransformType::OutputPointType    OutputPointType;
62   typedef typename TransformType::ParametersType     TransformParametersType;
63   typedef typename TransformType::JacobianType       TransformJacobianType;
64
65   typedef typename Superclass::InputPixelType        PixelType;
66
67   typedef typename TInputImage::SizeType             SizeType;
68
69   typedef Vector<TCoordRep, 3>                       DirectionType;
70
71   /**  Type of the Interpolator Base class */
72   typedef InterpolateImageFunction<TInputImage,TCoordRep> InterpolatorType;
73
74   typedef typename InterpolatorType::Pointer         InterpolatorPointer;
75
76   
77   /** Run-time type information (and related methods). */
78   itkTypeMacro(RayCastInterpolateImageFunctionWithOrigin, InterpolateImageFunction);
79
80   /** Method for creation through the object factory. */
81   itkNewMacro(Self);  
82
83   /** OutputType typedef support. */
84   typedef typename Superclass::OutputType OutputType;
85
86   /** InputImageType typedef support. */
87   typedef typename Superclass::InputImageType InputImageType;
88
89   /** RealType typedef support. */
90   typedef typename Superclass::RealType RealType;
91
92   /** Dimension underlying input image. */
93   itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
94
95   /** Point typedef support. */
96   typedef typename Superclass::PointType PointType;
97
98   /** Index typedef support. */
99   typedef typename Superclass::IndexType IndexType;
100
101   /** ContinuousIndex typedef support. */
102   typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
103
104   /** \brief
105    * Interpolate the image at a point position.
106    *
107    * Returns the interpolated image intensity at a 
108    * specified point position. No bounds checking is done.
109    * The point is assume to lie within the image buffer.
110    *
111    * ImageFunction::IsInsideBuffer() can be used to check bounds before
112    * calling the method. 
113    */
114   virtual OutputType Evaluate( const PointType& point ) const;
115
116   /** Interpolate the image at a continuous index position
117    *
118    * Returns the interpolated image intensity at a 
119    * specified index position. No bounds checking is done.
120    * The point is assume to lie within the image buffer.
121    *
122    * Subclasses must override this method.
123    *
124    * ImageFunction::IsInsideBuffer() can be used to check bounds before
125    * calling the method. 
126    */
127   virtual OutputType EvaluateAtContinuousIndex( 
128     const ContinuousIndexType &index ) const;
129
130
131   /** Connect the Transform. */
132   itkSetObjectMacro( Transform, TransformType );
133   /** Get a pointer to the Transform.  */
134   itkGetObjectMacro( Transform, TransformType );
135  
136   /** Connect the Interpolator. */
137   itkSetObjectMacro( Interpolator, InterpolatorType );
138   /** Get a pointer to the Interpolator.  */
139   itkGetObjectMacro( Interpolator, InterpolatorType );
140
141   /** Connect the Interpolator. */
142   itkSetMacro( FocalPoint, InputPointType );
143   /** Get a pointer to the Interpolator.  */
144   itkGetMacro( FocalPoint, InputPointType );
145
146   /** Connect the Transform. */
147   itkSetMacro( Threshold, double );
148   /** Get a pointer to the Transform.  */
149   itkGetMacro( Threshold, double );
150  
151   /** Check if a point is inside the image buffer.
152    * \warning For efficiency, no validity checking of
153    * the input image pointer is done. */
154   inline bool IsInsideBuffer( const PointType & ) const
155     { 
156     return true;
157     }
158   bool IsInsideBuffer( const ContinuousIndexType &  ) const
159     {
160     return true;
161     }
162   bool IsInsideBuffer( const IndexType &  ) const
163     { 
164     return true;
165     }
166
167 protected:
168
169   /// Constructor
170   RayCastInterpolateImageFunctionWithOrigin();
171
172   /// Destructor
173   ~RayCastInterpolateImageFunctionWithOrigin(){};
174
175   /// Print the object
176   void PrintSelf(std::ostream& os, Indent indent) const;
177   
178   /// Transformation used to calculate the new focal point position
179   TransformPointer m_Transform;
180
181   /// The focal point or position of the ray source
182   InputPointType m_FocalPoint;
183
184   /// The threshold above which voxels along the ray path are integrated.
185   double m_Threshold;
186
187   /// Pointer to the interpolator
188   InterpolatorPointer m_Interpolator;
189
190
191 private:
192   RayCastInterpolateImageFunctionWithOrigin( const Self& ); //purposely not implemented
193   void operator=( const Self& ); //purposely not implemented
194
195
196 };
197
198 } // namespace itk
199
200 #ifndef ITK_MANUAL_INSTANTIATION
201 #include "itkRayCastInterpolateImageFunctionWithOrigin.txx"
202 #endif
203
204 #endif