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 __itkBSplineControlPointImageFunction_h 00019 #define __itkBSplineControlPointImageFunction_h 00020 00021 #include "itkImageFunction.h" 00022 00023 #include "itkBSplineKernelFunction.h" 00024 #include "itkCoxDeBoorBSplineKernelFunction.h" 00025 #include "itkFixedArray.h" 00026 #include "itkImage.h" 00027 #include "itkPointSet.h" 00028 #include "itkVariableSizeMatrix.h" 00029 #include "itkVector.h" 00030 #include "itkVectorContainer.h" 00031 00032 #include "vnl/vnl_matrix.h" 00033 #include "vnl/vnl_vector.h" 00034 00035 namespace itk 00036 { 00065 template <class TInputImage, class TCoordRep = double> 00066 class BSplineControlPointImageFunction 00067 : public ImageFunction<TInputImage, typename TInputImage::PixelType, TCoordRep> 00068 { 00069 public: 00070 typedef BSplineControlPointImageFunction Self; 00071 typedef ImageFunction<TInputImage, 00072 typename TInputImage::PixelType, TCoordRep> Superclass; 00073 typedef SmartPointer<Self> Pointer; 00074 typedef SmartPointer<const Self> ConstPointer; 00075 00077 itkNewMacro(Self); 00078 00080 itkStaticConstMacro( ImageDimension, unsigned int, TInputImage::ImageDimension ); 00081 00083 typedef TInputImage ControlPointLatticeType; 00084 typedef TInputImage InputImageType; 00085 typedef TCoordRep CoordRepType; 00086 typedef typename InputImageType::PixelType PixelType; 00087 typedef typename InputImageType::RegionType RegionType; 00088 typedef typename InputImageType::IndexType IndexType; 00089 typedef typename InputImageType::PointType PointType; 00090 typedef typename InputImageType::RegionType InputImageRegionType; 00091 00092 typedef typename InputImageType::SpacingType SpacingType; 00093 typedef typename InputImageType::PointType OriginType; 00094 typedef typename InputImageType::SizeType SizeType; 00095 00097 typedef PixelType OutputType; 00098 typedef VariableSizeMatrix<CoordRepType> GradientType; 00099 typedef VariableSizeMatrix<CoordRepType> HessianComponentType; 00100 00102 typedef FixedArray<unsigned, ImageDimension> ArrayType; 00103 typedef Image<CoordRepType, ImageDimension> RealImageType; 00104 typedef typename RealImageType::Pointer RealImagePointer; 00105 typedef typename Superclass::ContinuousIndexType ContinuousIndexType; 00106 00108 typedef CoxDeBoorBSplineKernelFunction<3> KernelType; 00109 typedef BSplineKernelFunction<0> KernelOrder0Type; 00110 typedef BSplineKernelFunction<1> KernelOrder1Type; 00111 typedef BSplineKernelFunction<2> KernelOrder2Type; 00112 typedef BSplineKernelFunction<3> KernelOrder3Type; 00113 00118 virtual void SetInputImage( const InputImageType * ); 00119 00124 void SetSplineOrder( const unsigned int ); 00125 00130 void SetSplineOrder( const ArrayType & ); 00131 00135 itkGetConstReferenceMacro( SplineOrder, ArrayType ); 00136 00153 itkSetMacro( CloseDimension, ArrayType ); 00154 00158 itkGetConstReferenceMacro( CloseDimension, ArrayType ); 00159 00163 itkSetMacro( Spacing, SpacingType ); 00164 00168 itkGetConstMacro( Spacing, SpacingType ); 00169 00173 itkSetMacro( Origin, OriginType ); 00174 00178 itkGetConstMacro( Origin, OriginType ); 00179 00183 itkSetMacro( Size, SizeType ); 00184 00188 itkGetConstMacro( Size, SizeType ); 00189 00194 OutputType EvaluateAtParametricPoint( const PointType & ) const; 00195 00200 virtual OutputType EvaluateAtIndex( const IndexType & ) const; 00201 00206 virtual OutputType EvaluateAtContinuousIndex( 00207 const ContinuousIndexType & ) const; 00208 00214 virtual OutputType Evaluate( const PointType & ) const; 00215 00220 GradientType EvaluateGradientAtParametricPoint( const PointType & ) const; 00221 00226 GradientType EvaluateGradientAtIndex( const IndexType & ) const; 00227 00232 GradientType EvaluateGradientAtContinuousIndex( 00233 const ContinuousIndexType & ) const; 00234 00240 GradientType EvaluateGradient( const PointType & ) const; 00241 00247 HessianComponentType EvaluateHessianAtParametricPoint( 00248 const PointType &, const unsigned int ) const; 00249 00255 HessianComponentType EvaluateHessianAtIndex( 00256 const IndexType &, const unsigned int ) const; 00257 00263 HessianComponentType EvaluateHessianAtContinuousIndex( 00264 const ContinuousIndexType &, const unsigned int ) const; 00265 00271 HessianComponentType EvaluateHessian( 00272 const PointType &, const unsigned int ) const; 00273 00274 protected: 00275 BSplineControlPointImageFunction(); 00276 virtual ~BSplineControlPointImageFunction(); 00277 void PrintSelf( std::ostream& os, Indent indent ) const; 00278 00279 private: 00280 BSplineControlPointImageFunction( const Self& ); //purposely not implemented 00281 void operator=( const Self& ); //purposely not implemented 00282 00284 SizeType m_Size; 00285 SpacingType m_Spacing; 00286 OriginType m_Origin; 00287 00288 ArrayType m_NumberOfControlPoints; 00289 ArrayType m_CloseDimension; 00290 ArrayType m_SplineOrder; 00291 00292 RealImagePointer m_NeighborhoodWeightImage; 00293 00294 typename KernelType::Pointer m_Kernel[ImageDimension]; 00295 typename KernelOrder0Type::Pointer m_KernelOrder0; 00296 typename KernelOrder1Type::Pointer m_KernelOrder1; 00297 typename KernelOrder2Type::Pointer m_KernelOrder2; 00298 typename KernelOrder3Type::Pointer m_KernelOrder3; 00299 00300 CoordRepType m_BSplineEpsilon; 00301 00302 }; 00303 00304 } // end namespace itk 00305 00306 #ifndef ITK_MANUAL_INSTANTIATION 00307 #include "itkBSplineControlPointImageFunction.hxx" 00308 #endif 00309 00310 #endif 00311