1 /*=========================================================================
3 Program: Insight Segmentation & Registration Toolkit
6 Copyright (c) Insight Software Consortium. All rights reserved.
7 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
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.
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
16 #ifndef __itkRayCastInterpolateImageFunctionWithOrigin_h
17 #define __itkRayCastInterpolateImageFunctionWithOrigin_h
19 #include "itkInterpolateImageFunction.h"
20 #include "itkTransform.h"
21 #include "itkVector.h"
26 /** \class RayCastInterpolateImageFunctionWithOrigin
27 * \brief Projective interpolation of an image at specified positions.
29 * RayCastInterpolateImageFunctionWithOrigin casts rays through a 3-dimensional
30 * image and uses bilinear interpolation to integrate each plane of
33 * \warning This interpolator works for 3-dimensional images only.
35 * \ingroup ImageFunctions
37 template <class TInputImage, class TCoordRep = float>
38 class ITK_EXPORT RayCastInterpolateImageFunctionWithOrigin :
39 public InterpolateImageFunction<TInputImage,TCoordRep>
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;
48 /** Constants for the image dimensions */
49 itkStaticConstMacro(InputImageDimension, unsigned int,
50 TInputImage::ImageDimension);
53 * Type of the Transform Base class
54 * The fixed image should be a 3D image
56 typedef Transform<TCoordRep,3,3> TransformType;
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;
64 typedef typename Superclass::InputPixelType PixelType;
66 typedef typename TInputImage::SizeType SizeType;
68 typedef Vector<TCoordRep, 3> DirectionType;
70 /** Type of the Interpolator Base class */
71 typedef InterpolateImageFunction<TInputImage,TCoordRep> InterpolatorType;
73 typedef typename InterpolatorType::Pointer InterpolatorPointer;
76 /** Run-time type information (and related methods). */
77 itkTypeMacro(RayCastInterpolateImageFunctionWithOrigin, InterpolateImageFunction);
79 /** Method for creation through the object factory. */
82 /** OutputType typedef support. */
83 typedef typename Superclass::OutputType OutputType;
85 /** InputImageType typedef support. */
86 typedef typename Superclass::InputImageType InputImageType;
88 /** RealType typedef support. */
89 typedef typename Superclass::RealType RealType;
91 /** Dimension underlying input image. */
92 itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
94 /** Point typedef support. */
95 typedef typename Superclass::PointType PointType;
97 /** Index typedef support. */
98 typedef typename Superclass::IndexType IndexType;
100 /** ContinuousIndex typedef support. */
101 typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
104 * Interpolate the image at a point position.
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.
110 * ImageFunction::IsInsideBuffer() can be used to check bounds before
111 * calling the method.
113 virtual OutputType Evaluate( const PointType& point ) const;
115 /** Interpolate the image at a continuous index position
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.
121 * Subclasses must override this method.
123 * ImageFunction::IsInsideBuffer() can be used to check bounds before
124 * calling the method.
126 virtual OutputType EvaluateAtContinuousIndex(
127 const ContinuousIndexType &index ) const;
130 /** Connect the Transform. */
131 itkSetObjectMacro( Transform, TransformType );
132 /** Get a pointer to the Transform. */
133 itkGetObjectMacro( Transform, TransformType );
135 /** Connect the Interpolator. */
136 itkSetObjectMacro( Interpolator, InterpolatorType );
137 /** Get a pointer to the Interpolator. */
138 itkGetObjectMacro( Interpolator, InterpolatorType );
140 /** Connect the Interpolator. */
141 itkSetMacro( FocalPoint, InputPointType );
142 /** Get a pointer to the Interpolator. */
143 itkGetMacro( FocalPoint, InputPointType );
145 /** Connect the Transform. */
146 itkSetMacro( Threshold, double );
147 /** Get a pointer to the Transform. */
148 itkGetMacro( Threshold, double );
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
157 bool IsInsideBuffer( const ContinuousIndexType & ) const
161 bool IsInsideBuffer( const IndexType & ) const
169 RayCastInterpolateImageFunctionWithOrigin();
172 ~RayCastInterpolateImageFunctionWithOrigin(){};
175 void PrintSelf(std::ostream& os, Indent indent) const;
177 /// Transformation used to calculate the new focal point position
178 TransformPointer m_Transform;
180 /// The focal point or position of the ray source
181 InputPointType m_FocalPoint;
183 /// The threshold above which voxels along the ray path are integrated.
186 /// Pointer to the interpolator
187 InterpolatorPointer m_Interpolator;
191 RayCastInterpolateImageFunctionWithOrigin( const Self& ); //purposely not implemented
192 void operator=( const Self& ); //purposely not implemented
199 #ifndef ITK_MANUAL_INSTANTIATION
200 #include "itkRayCastInterpolateImageFunctionWithOrigin.txx"