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