ITK  4.4.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 
45 template< class TInputImage, class TCoordRep = double >
47  public ImageFunction<
48  TInputImage,
49  typename NumericTraits< typename TInputImage::PixelType >::RealType,
50  TCoordRep >
51 {
52 public:
54  itkStaticConstMacro(Dimension, unsigned int,
55  TInputImage::PixelType::Dimension);
56 
58  itkStaticConstMacro(ImageDimension, unsigned int,
59  TInputImage::ImageDimension);
60 
63  typedef ImageFunction< TInputImage,
65  TCoordRep > Superclass;
66 
69 
72 
74  typedef typename Superclass::InputImageType InputImageType;
75  typedef typename InputImageType::PixelType PixelType;
76  typedef typename PixelType::ValueType ValueType;
78 
80  typedef typename Superclass::PointType PointType;
81 
83  typedef typename Superclass::IndexType IndexType;
84 
86  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
87 
89  typedef typename Superclass::OutputType OutputType;
90 
92  typedef TCoordRep CoordRepType;
93 
99  virtual OutputType Evaluate(const PointType & point) const
100  {
101  ContinuousIndexType index;
102 
103  this->GetInputImage()->TransformPhysicalPointToContinuousIndex(point, index);
104  return ( this->EvaluateAtContinuousIndex(index) );
105  }
106 
117  virtual OutputType EvaluateAtContinuousIndex(
118  const ContinuousIndexType & index) const = 0;
119 
127  virtual OutputType EvaluateAtIndex(const IndexType & index) const
128  {
129  OutputType output;
130  PixelType input = this->GetInputImage()->GetPixel(index);
132 
133  for ( unsigned int k = 0;
134  k < this->GetInputImage()->GetNumberOfComponentsPerPixel(); k++ )
135  {
136  output[k] = static_cast< double >( input[k] );
137  }
138  return ( output );
139  }
140 
141 protected:
144  void PrintSelf(std::ostream & os, Indent indent) const
145  { Superclass::PrintSelf(os, indent); }
146 
147 private:
148  VectorInterpolateImageFunction(const Self &); //purposely not implemented
149  void operator=(const Self &); //purposely not implemented
150 };
151 } // end namespace itk
152 
153 #endif
154