ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 #ifndef __itkVectorInterpolateImageFunction_h 00019 #define __itkVectorInterpolateImageFunction_h 00020 00021 #include "itkImageFunction.h" 00022 #include "itkFixedArray.h" 00023 00024 namespace itk 00025 { 00026 #ifndef __itkVectorCentralDifferenceImageFunction_h 00027 00033 template< typename T > 00034 struct GetDimension { 00035 itkStaticConstMacro(Dimension, int, T::Dimension); 00036 }; 00037 #endif 00038 00057 template< class TInputImage, class TCoordRep = double > 00058 class ITK_EXPORT VectorInterpolateImageFunction: 00059 public ImageFunction< 00060 TInputImage, 00061 typename NumericTraits< typename TInputImage::PixelType >::RealType, 00062 TCoordRep > 00063 { 00064 public: 00066 itkStaticConstMacro(Dimension, unsigned int, 00067 TInputImage::PixelType::Dimension); 00068 00070 itkStaticConstMacro(ImageDimension, unsigned int, 00071 TInputImage::ImageDimension); 00072 00074 typedef VectorInterpolateImageFunction Self; 00075 typedef ImageFunction< TInputImage, 00076 typename NumericTraits< typename TInputImage::PixelType >::RealType, 00077 TCoordRep > Superclass; 00078 00079 typedef SmartPointer< Self > Pointer; 00080 typedef SmartPointer< const Self > ConstPointer; 00081 00083 itkTypeMacro(VectorInterpolateImageFunction, ImageFunction); 00084 00086 typedef typename Superclass::InputImageType InputImageType; 00087 typedef typename InputImageType::PixelType PixelType; 00088 typedef typename PixelType::ValueType ValueType; 00089 typedef typename NumericTraits< ValueType >::RealType RealType; 00090 00092 typedef typename Superclass::PointType PointType; 00093 00095 typedef typename Superclass::IndexType IndexType; 00096 00098 typedef typename Superclass::ContinuousIndexType ContinuousIndexType; 00099 00101 typedef typename Superclass::OutputType OutputType; 00102 00104 typedef TCoordRep CoordRepType; 00105 00111 virtual OutputType Evaluate(const PointType & point) const 00112 { 00113 ContinuousIndexType index; 00114 00115 this->GetInputImage()->TransformPhysicalPointToContinuousIndex(point, index); 00116 return ( this->EvaluateAtContinuousIndex(index) ); 00117 } 00118 00129 virtual OutputType EvaluateAtContinuousIndex( 00130 const ContinuousIndexType & index) const = 0; 00131 00139 virtual OutputType EvaluateAtIndex(const IndexType & index) const 00140 { 00141 OutputType output; 00142 PixelType input = this->GetInputImage()->GetPixel(index); 00144 00145 for ( unsigned int k = 0; 00146 k < this->GetInputImage()->GetNumberOfComponentsPerPixel(); k++ ) 00147 { 00148 output[k] = static_cast< double >( input[k] ); 00149 } 00150 return ( output ); 00151 } 00152 00153 protected: 00154 VectorInterpolateImageFunction() {} 00155 ~VectorInterpolateImageFunction() {} 00156 void PrintSelf(std::ostream & os, Indent indent) const 00157 { Superclass::PrintSelf(os, indent); } 00158 private: 00159 VectorInterpolateImageFunction(const Self &); //purposely not implemented 00160 void operator=(const Self &); //purposely not implemented 00161 }; 00162 } // end namespace itk 00163 00164 #endif 00165