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