ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkVectorInterpolateImageFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkVectorInterpolateImageFunction_h
19 #define __itkVectorInterpolateImageFunction_h
20 
21 #include "itkImageFunction.h"
22 #include "itkFixedArray.h"
23 
24 namespace itk
25 {
26 #ifndef __itkVectorCentralDifferenceImageFunction_h
27 
33 template< typename T >
34 struct GetDimension {
35  itkStaticConstMacro(Dimension, int, T::Dimension);
36 };
37 #endif
38 
57 template< class TInputImage, class TCoordRep = double >
59  public ImageFunction<
60  TInputImage,
61  typename NumericTraits< typename TInputImage::PixelType >::RealType,
62  TCoordRep >
63 {
64 public:
66  itkStaticConstMacro(Dimension, unsigned int,
67  TInputImage::PixelType::Dimension);
68 
70  itkStaticConstMacro(ImageDimension, unsigned int,
71  TInputImage::ImageDimension);
72 
75  typedef ImageFunction< TInputImage,
77  TCoordRep > Superclass;
78 
81 
84 
86  typedef typename Superclass::InputImageType InputImageType;
87  typedef typename InputImageType::PixelType PixelType;
88  typedef typename PixelType::ValueType ValueType;
90 
92  typedef typename Superclass::PointType PointType;
93 
95  typedef typename Superclass::IndexType IndexType;
96 
98  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
99 
101  typedef typename Superclass::OutputType OutputType;
102 
104  typedef TCoordRep CoordRepType;
105 
111  virtual OutputType Evaluate(const PointType & point) const
112  {
113  ContinuousIndexType index;
114 
115  this->GetInputImage()->TransformPhysicalPointToContinuousIndex(point, index);
116  return ( this->EvaluateAtContinuousIndex(index) );
117  }
118 
129  virtual OutputType EvaluateAtContinuousIndex(
130  const ContinuousIndexType & index) const = 0;
131 
139  virtual OutputType EvaluateAtIndex(const IndexType & index) const
140  {
141  OutputType output;
142  PixelType input = this->GetInputImage()->GetPixel(index);
144 
145  for ( unsigned int k = 0;
146  k < this->GetInputImage()->GetNumberOfComponentsPerPixel(); k++ )
147  {
148  output[k] = static_cast< double >( input[k] );
149  }
150  return ( output );
151  }
152 
153 protected:
156  void PrintSelf(std::ostream & os, Indent indent) const
157  { Superclass::PrintSelf(os, indent); }
158 private:
159  VectorInterpolateImageFunction(const Self &); //purposely not implemented
160  void operator=(const Self &); //purposely not implemented
161 };
162 } // end namespace itk
163 
164 #endif
165