]> Creatis software - clitk.git/blob - itk/clitkRayCastInterpolateImageFunctionWithOrigin.h
separate airway tracking from extract lung
[clitk.git] / itk / clitkRayCastInterpolateImageFunctionWithOrigin.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://oncora1.lyon.fnclcc.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 __clitkRayCastInterpolateImageFunctionWithOrigin_h
19 #define __clitkRayCastInterpolateImageFunctionWithOrigin_h
20 #include "clitkBSplineDeformableTransform.h"
21
22 #include "itkInterpolateImageFunction.h"
23 #include "itkTransform.h"
24 #include "itkVector.h"
25
26 namespace clitk
27 {
28
29
30 template <class TInputImage, class TCoordRep = float>
31 class ITK_EXPORT RayCastInterpolateImageFunctionWithOrigin : 
32     public itk::InterpolateImageFunction<TInputImage,TCoordRep> 
33 {
34 public:
35   /** Standard class typedefs. */
36   typedef RayCastInterpolateImageFunctionWithOrigin                 Self;
37   typedef itk::InterpolateImageFunction<TInputImage,TCoordRep> Superclass;
38   typedef itk::SmartPointer<Self>                              Pointer;
39   typedef itk::SmartPointer<const Self>                        ConstPointer;
40
41   /** Constants for the image dimensions */
42   itkStaticConstMacro(InputImageDimension, unsigned int,
43                       TInputImage::ImageDimension);
44
45   /** 
46    * Type of the Transform Base class 
47    * The fixed image should be a 3D image
48    */
49   typedef itk::Transform<TCoordRep,3,3> TransformType;
50
51   typedef typename TransformType::Pointer            TransformPointer;
52   typedef typename TransformType::InputPointType     InputPointType;
53   typedef typename TransformType::OutputPointType    OutputPointType;
54   typedef typename TransformType::ParametersType     TransformParametersType;
55   typedef typename TransformType::JacobianType       TransformJacobianType;
56
57   typedef typename Superclass::InputPixelType        PixelType;
58
59   typedef typename TInputImage::SizeType             SizeType;
60
61   typedef itk::Vector<TCoordRep, 3>                       DirectionType;
62
63   /**  Type of the Interpolator Base class */
64   typedef itk::InterpolateImageFunction<TInputImage,TCoordRep> InterpolatorType;
65
66   typedef typename InterpolatorType::Pointer         InterpolatorPointer;
67
68   //JV Type of the Interpolator for the transform  
69   typedef itk::InterpolateImageFunction<TInputImage,TCoordRep> DeformableTransformInterpolatorType;
70   typedef typename DeformableTransformInterpolatorType::Pointer        DeformableTransformInterpolatorPointer;
71
72
73   /** Run-time type information (and related methods). */
74   itkTypeMacro(RayCastInterpolateImageFunctionWithOrigin, InterpolateImageFunction);
75
76   /** Method for creation through the object factory. */
77   itkNewMacro(Self);  
78
79   /** OutputType typedef support. */
80   typedef typename Superclass::OutputType OutputType;
81
82   /** InputImageType typedef support. */
83   typedef typename Superclass::InputImageType InputImageType;
84
85   /** RealType typedef support. */
86   typedef typename Superclass::RealType RealType;
87
88   /** Dimension underlying input image. */
89   itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
90
91   /** Point typedef support. */
92   typedef typename Superclass::PointType PointType;
93
94   /** Index typedef support. */
95   typedef typename Superclass::IndexType IndexType;
96
97   /** ContinuousIndex typedef support. */
98   typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
99
100   /** \brief
101    * Interpolate the image at a point position.
102    *
103    * Returns the interpolated image intensity at a 
104    * specified point position. No bounds checking is done.
105    * The point is assume to lie within the image buffer.
106    *
107    * ImageFunction::IsInsideBuffer() can be used to check bounds before
108    * calling the method. 
109    */
110   virtual OutputType Evaluate( const PointType& point ) const;
111
112   /** Interpolate the image at a continuous index position
113    *
114    * Returns the interpolated image intensity at a 
115    * specified index position. No bounds checking is done.
116    * The point is assume to lie within the image buffer.
117    *
118    * Subclasses must override this method.
119    *
120    * ImageFunction::IsInsideBuffer() can be used to check bounds before
121    * calling the method. 
122    */
123   virtual OutputType EvaluateAtContinuousIndex( 
124     const ContinuousIndexType &index ) const;
125
126
127   /** Connect the Transform. */
128   itkSetObjectMacro( Transform, TransformType );
129   /** Get a pointer to the Transform.  */
130   itkGetObjectMacro( Transform, TransformType );
131  
132   /** Connect the Interpolator. */
133   itkSetObjectMacro( Interpolator, InterpolatorType );
134   /** Get a pointer to the Interpolator.  */
135   itkGetObjectMacro( Interpolator, InterpolatorType );
136
137   /** Connect the focalPoint. */
138   itkSetMacro( FocalPoint, InputPointType );
139   /** Get a pointer to the focalpoint.  */
140   itkGetMacro( FocalPoint, InputPointType );
141
142   /** Connect the threshold. */
143   itkSetMacro( Threshold, double );
144   /** Get a pointer to the threshhold.  */
145   itkGetMacro( Threshold, double );
146  
147   /** Check if a point is inside the image buffer.
148    * \warning For efficiency, no validity checking of
149    * the input image pointer is done. */
150   inline bool IsInsideBuffer( const PointType & ) const
151     { 
152     return true;
153     }
154   bool IsInsideBuffer( const ContinuousIndexType &  ) const
155     {
156     return true;
157     }
158   bool IsInsideBuffer( const IndexType &  ) const
159     { 
160     return true;
161     }
162
163   //JV transform is deformable
164   itkSetMacro( TransformIsDeformable, bool );
165   itkGetMacro( TransformIsDeformable, bool );
166   
167   //JV interpolator for deformable transform
168   itkSetObjectMacro( DeformableTransformInterpolator, DeformableTransformInterpolatorType );
169   itkGetObjectMacro( DeformableTransformInterpolator, DeformableTransformInterpolatorType );
170
171 protected:
172
173   /// Constructor
174   RayCastInterpolateImageFunctionWithOrigin();
175
176   /// Destructor
177   ~RayCastInterpolateImageFunctionWithOrigin(){};
178
179   /// Print the object
180   void PrintSelf(std::ostream& os, itk::Indent indent) const;
181   
182   /// Transformation used to calculate the new focal point position
183   TransformPointer m_Transform;
184
185   /// The focal point or position of the ray source
186   InputPointType m_FocalPoint;
187
188   /// The threshold above which voxels along the ray path are integrated.
189   double m_Threshold;
190
191   /// Pointer to the interpolator
192   InterpolatorPointer m_Interpolator;
193
194   //JV Pointer to the deformable transform interpolator
195   DeformableTransformInterpolatorPointer m_DeformableTransformInterpolator;
196
197
198   //JV Transform is deformable: fetch interpolated value at transformed intersect
199   bool m_TransformIsDeformable;
200   
201
202 private:
203   RayCastInterpolateImageFunctionWithOrigin( const Self& ); //purposely not implemented
204   void operator=( const Self& ); //purposely not implemented
205
206
207 };
208
209 } // namespace clitk
210
211 #ifndef ITK_MANUAL_INSTANTIATION
212 #include "clitkRayCastInterpolateImageFunctionWithOrigin.txx"
213 #endif
214
215 #endif