KWStyle - itkVectorInterpolateImageFunction.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkVectorInterpolateImageFunction.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:49 $
7   Version:   $Revision: 1.4 $
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 DEF #ifndef _itkVectorInterpolateImageFunction_h
18 DEF #define _itkVectorInterpolateImageFunction_h
19
20 #include "itkImageFunction.h"
21 #include "itkFixedArray.h"
22
23 namespace itk
24 {
25
26 /**
27  * Due to a bug in MSVC, an enum value cannot be accessed out of a template
28  * parameter until the template class opens.  In order for templated classes
29  * to access the dimension of a template parameter in defining their
30  * own dimension, this class is needed as a work-around.
31  */
32 template <typename T>
33 struct GetDimension
34 {
35   itkStaticConstMacro(Dimension, int, T::Dimension);
36 }; 
37
38   
39 /** \class VectorInterpolateImageFunction
40  * \brief Base class for all vector image interpolaters.
41  *
42  * VectorInterpolateImageFunction is the base for all ImageFunctions that
43  * interpolates image with vector pixel types. This function outputs
44  * a return value of type Vector<double,Dimension>.
45  *
46  * This class is templated input image type and the coordinate
47  * representation type.
48  *
49  * \warning This hierarchy of functions work only for images 
50  * with Vector-based pixel types. For scalar images use 
51  * InterpolateImageFunction.
52  * 
53  * \sa InterpolateImageFunction
54  * \ingroup ImageFunctions ImageInterpolators
55  */
56 template <
57 class TInputImage,
58 class TCoordRep = float,
59 class TPixelType = ITK_TYPENAME TInputImage::PixelType
60 >
61 class ITK_EXPORT VectorInterpolateImageFunction : 
62 IND **public ImageFunction<
63     TInputImage, 
64 LEN     FixedArray< ITK_TYPENAME NumericTraits<typename TPixelType::ValueType>::RealType, 
65 IND ******::itk::GetDimension<TPixelType>::Dimension>,
66 IND ****TCoordRep > 
67 {
68 public:
69   /** Extract the vector dimension from the pixel template parameter. */
70   itkStaticConstMacro(Dimension, unsigned int,
71                       TPixelType::Dimension);
72   
73   /** Dimension underlying input image. */
74   itkStaticConstMacro(ImageDimension, unsigned int,
75                       TInputImage::ImageDimension);
76
77   /** Standard class typedefs. */
78   typedef VectorInterpolateImageFunction Self;
79   typedef ImageFunction<TInputImage,
80 LEN,TDA     FixedArray<double, itkGetStaticConstMacro(Dimension)>, TCoordRep > Superclass;
81 TDA   typedef SmartPointer<Self> Pointer;
82 TDA   typedef SmartPointer<const Self>  ConstPointer;
83   
84   /** Run-time type information (and related methods). */
85   itkTypeMacro(VectorInterpolateImageFunction, ImageFunction);
86
87   /** InputImageType typedef support. */
88   typedef typename Superclass::InputImageType InputImageType;
89   typedef typename InputImageType::PixelType  PixelType;
90   typedef typename PixelType::ValueType       ValueType;
91 TDA   typedef typename NumericTraits<ValueType>::RealType  RealType;
92     
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   /** Output type is FixedArray<RealType,Dimension>. */
104   typedef typename Superclass::OutputType OutputType;
105
106   /** CoordRep typedef support. */
107   typedef TCoordRep CoordRepType;
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    * ImageFunction::IsInsideBuffer() can be used to check bounds before
113    * calling the method. */
114   virtual OutputType Evaluate( const PointType& point ) const
115     {
116     ContinuousIndexType index;
117 LEN     this->GetInputImage()->TransformPhysicalPointToContinuousIndex( point, index );
118     return ( this->EvaluateAtContinuousIndex( index ) );
119     }
120
121   /** Interpolate the image at a continuous index position
122    *
123    * Returns the interpolated image intensity at a 
124    * specified index position. No bounds checking is done.
125    * The point is assume to lie within the image buffer.
126    *
127    * Subclasses must override this method.
128    *
129    * ImageFunction::IsInsideBuffer() can be used to check bounds before
130    * calling the method. */
131   virtual OutputType EvaluateAtContinuousIndex( 
132     const ContinuousIndexType & index ) const = 0;
133
134   /** Interpolate the image at an index position.
135    * Simply returns the image value at the
136    * specified index position. No bounds checking is done.
137    * The point is assume to lie within the image buffer.
138    *
139    * ImageFunction::IsInsideBuffer() can be used to check bounds before
140    * calling the method. */
141   virtual OutputType EvaluateAtIndex( const IndexType & index ) const
142     {
143     OutputType output;
144     PixelType input = this->GetInputImage()->GetPixel( index );
145     for( unsigned int k = 0; k < Dimension; k++ )
146       {
147       output[k] = static_cast<double>( input[k] );
148       }
149     return ( output );
150     }
151
152 protected:
153   VectorInterpolateImageFunction() {}
154   ~VectorInterpolateImageFunction() {}
155   void PrintSelf(std::ostream& os, Indent indent) const
156     { Superclass::PrintSelf( os, indent ); }
157
158 private:
159   VectorInterpolateImageFunction(const Self&); //purposely not implemented
160   void operator=(const Self&); //purposely not implemented
161
162 };
163
164 // namespace itk
165
166 #endif
167
168 EOF
169 EOF,EML

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:52PM
© Kitware Inc.