1 /*=========================================================================
3 Program: Insight Segmentation & Registration Toolkit
4 Module: $RCSfile: itkRayCastInterpolateImageFunctionWithOrigin.h,v $
6 Date: $Date: 2010/01/06 13:32:01 $
7 Version: $Revision: 1.1 $
9 Copyright (c) Insight Software Consortium. All rights reserved.
10 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
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.
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
19 #ifndef __itkRayCastInterpolateImageFunctionWithOrigin_h
20 #define __itkRayCastInterpolateImageFunctionWithOrigin_h
22 #include "itkInterpolateImageFunction.h"
23 #include "itkTransform.h"
24 #include "itkVector.h"
29 /** \class RayCastInterpolateImageFunctionWithOrigin
30 * \brief Projective interpolation of an image at specified positions.
32 * RayCastInterpolateImageFunctionWithOrigin casts rays through a 3-dimensional
33 * image and uses bilinear interpolation to integrate each plane of
36 * \warning This interpolator works for 3-dimensional images only.
38 * \ingroup ImageFunctions
40 template <class TInputImage, class TCoordRep = float>
41 class ITK_EXPORT RayCastInterpolateImageFunctionWithOrigin :
42 public InterpolateImageFunction<TInputImage,TCoordRep>
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;
51 /** Constants for the image dimensions */
52 itkStaticConstMacro(InputImageDimension, unsigned int,
53 TInputImage::ImageDimension);
56 * Type of the Transform Base class
57 * The fixed image should be a 3D image
59 typedef Transform<TCoordRep,3,3> TransformType;
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;
67 typedef typename Superclass::InputPixelType PixelType;
69 typedef typename TInputImage::SizeType SizeType;
71 typedef Vector<TCoordRep, 3> DirectionType;
73 /** Type of the Interpolator Base class */
74 typedef InterpolateImageFunction<TInputImage,TCoordRep> InterpolatorType;
76 typedef typename InterpolatorType::Pointer InterpolatorPointer;
79 /** Run-time type information (and related methods). */
80 itkTypeMacro(RayCastInterpolateImageFunctionWithOrigin, InterpolateImageFunction);
82 /** Method for creation through the object factory. */
85 /** OutputType typedef support. */
86 typedef typename Superclass::OutputType OutputType;
88 /** InputImageType typedef support. */
89 typedef typename Superclass::InputImageType InputImageType;
91 /** RealType typedef support. */
92 typedef typename Superclass::RealType RealType;
94 /** Dimension underlying input image. */
95 itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
97 /** Point typedef support. */
98 typedef typename Superclass::PointType PointType;
100 /** Index typedef support. */
101 typedef typename Superclass::IndexType IndexType;
103 /** ContinuousIndex typedef support. */
104 typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
107 * Interpolate the image at a point position.
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.
113 * ImageFunction::IsInsideBuffer() can be used to check bounds before
114 * calling the method.
116 virtual OutputType Evaluate( const PointType& point ) const;
118 /** Interpolate the image at a continuous index position
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.
124 * Subclasses must override this method.
126 * ImageFunction::IsInsideBuffer() can be used to check bounds before
127 * calling the method.
129 virtual OutputType EvaluateAtContinuousIndex(
130 const ContinuousIndexType &index ) const;
133 /** Connect the Transform. */
134 itkSetObjectMacro( Transform, TransformType );
135 /** Get a pointer to the Transform. */
136 itkGetObjectMacro( Transform, TransformType );
138 /** Connect the Interpolator. */
139 itkSetObjectMacro( Interpolator, InterpolatorType );
140 /** Get a pointer to the Interpolator. */
141 itkGetObjectMacro( Interpolator, InterpolatorType );
143 /** Connect the Interpolator. */
144 itkSetMacro( FocalPoint, InputPointType );
145 /** Get a pointer to the Interpolator. */
146 itkGetMacro( FocalPoint, InputPointType );
148 /** Connect the Transform. */
149 itkSetMacro( Threshold, double );
150 /** Get a pointer to the Transform. */
151 itkGetMacro( Threshold, double );
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
160 bool IsInsideBuffer( const ContinuousIndexType & ) const
164 bool IsInsideBuffer( const IndexType & ) const
172 RayCastInterpolateImageFunctionWithOrigin();
175 ~RayCastInterpolateImageFunctionWithOrigin(){};
178 void PrintSelf(std::ostream& os, Indent indent) const;
180 /// Transformation used to calculate the new focal point position
181 TransformPointer m_Transform;
183 /// The focal point or position of the ray source
184 InputPointType m_FocalPoint;
186 /// The threshold above which voxels along the ray path are integrated.
189 /// Pointer to the interpolator
190 InterpolatorPointer m_Interpolator;
194 RayCastInterpolateImageFunctionWithOrigin( const Self& ); //purposely not implemented
195 void operator=( const Self& ); //purposely not implemented
202 #ifndef ITK_MANUAL_INSTANTIATION
203 #include "itkRayCastInterpolateImageFunctionWithOrigin.txx"