ITK  5.0.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< typename TInputImage, typename TCoordRep = double >
46 class ITK_TEMPLATE_EXPORT VectorInterpolateImageFunction:
47  public ImageFunction<
48  TInputImage,
49  typename NumericTraits< typename TInputImage::PixelType >::RealType,
50  TCoordRep >
51 {
52 public:
53  ITK_DISALLOW_COPY_AND_ASSIGN(VectorInterpolateImageFunction);
54 
56  static constexpr unsigned int Dimension = TInputImage::PixelType::Dimension;
57 
59  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
60 
63  using Superclass = ImageFunction< TInputImage,
65  TCoordRep >;
66 
69 
72 
74  using InputImageType = typename Superclass::InputImageType;
75  using PixelType = typename InputImageType::PixelType;
76  using ValueType = typename PixelType::ValueType;
78 
80  using PointType = typename Superclass::PointType;
81 
83  using IndexType = typename Superclass::IndexType;
84 
86  using ContinuousIndexType = typename Superclass::ContinuousIndexType;
87 
89  using OutputType = typename Superclass::OutputType;
90 
92  using CoordRepType = TCoordRep;
93 
99  OutputType Evaluate(const PointType & point) const override
100  {
101  ContinuousIndexType index;
102 
103  this->GetInputImage()->TransformPhysicalPointToContinuousIndex(point, index);
104  return ( this->EvaluateAtContinuousIndex(index) );
105  }
106 
117  OutputType EvaluateAtContinuousIndex(
118  const ContinuousIndexType & index) const override = 0;
119 
127  OutputType EvaluateAtIndex(const IndexType & index) const override
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:
142  VectorInterpolateImageFunction() = default;
143  ~VectorInterpolateImageFunction() override = default;
144  void PrintSelf(std::ostream & os, Indent indent) const override
145  { Superclass::PrintSelf(os, indent); }
146 };
147 } // end namespace itk
148 
149 #endif
Light weight base class for most itk classes.
Define numeric traits for std::vector.
typename NumericTraits< ValueType >::RealType RealType
OutputType EvaluateAtIndex(const IndexType &index) const override
typename InputImageType::PixelType PixelType
OutputType Evaluate(const PointType &point) const override
void PrintSelf(std::ostream &os, Indent indent) const override
typename Superclass::InputImageType InputImageType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Base class for all vector image interpolaters.
typename Superclass::ContinuousIndexType ContinuousIndexType
Evaluates a function of an image at specified position.