00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _itkLevelSetCurvatureFunction_h
00018 #define _itkLevelSetCurvatureFunction_h
00019
00020 #include "itkImageFunction.h"
00021
00022 #include "vnl/vnl_vector_fixed.h"
00023 #include "vnl/vnl_matrix_fixed.h"
00024
00025 namespace itk
00026 {
00027
00044 template <class TInputImage, class TCoordRep = float >
00045 class ITK_EXPORT LevelSetCurvatureFunction :
00046 public ImageFunction<TInputImage,double,TCoordRep>
00047 {
00048 public:
00050 typedef LevelSetCurvatureFunction Self;
00051 typedef ImageFunction<TInputImage,double,TCoordRep> Superclass;
00052 typedef SmartPointer<Self> Pointer;
00053 typedef SmartPointer<const Self> ConstPointer;
00054
00056 itkTypeMacro(LevelSetCurvatureFunction, ImageFunction);
00057
00059 itkNewMacro(Self);
00060
00062 typedef TInputImage InputImageType;
00063
00065 itkStaticConstMacro(ImageDimension, unsigned int,
00066 InputImageType::ImageDimension);
00067
00069 typedef typename Superclass::IndexType IndexType;
00070
00072 typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
00073
00075 typedef typename Superclass::PointType PointType;
00076
00078 virtual void SetInputImage( const InputImageType * ptr );
00079
00084 void SetEpsilonMagnitude( double value )
00085 { m_EpsilonMagnitude = value; }
00086
00088 double GetEpsilonMagnitude() const
00089 { return m_EpsilonMagnitude; }
00090
00092 virtual double EvaluateAtIndex( const IndexType& index ) const;
00093
00095 virtual double Evaluate( const PointType& point ) const
00096 {
00097 IndexType index;
00098 this->ConvertPointToNearestIndex( point, index );
00099 return this->EvaluateAtIndex( index );
00100 }
00101
00102 virtual double EvaluateAtContinuousIndex(
00103 const ContinuousIndexType& cindex ) const
00104 {
00105 IndexType index;
00106 this->ConvertContinuousIndexToNearestIndex( cindex, index );
00107 return this->EvaluateAtIndex( index ) ;
00108 }
00109
00111 double GetCurvature() const
00112 { return m_Curvature; }
00113
00115 double GetMagnitude() const
00116 { return m_Magnitude; }
00117
00118 protected:
00119 LevelSetCurvatureFunction(){}
00120 ~LevelSetCurvatureFunction(){}
00121 void PrintSelf(std::ostream& os, Indent indent) const;
00122
00123 private:
00124 LevelSetCurvatureFunction( const Self& );
00125 void operator=( const Self& );
00126
00127 signed long m_ImageSize[ImageDimension];
00128 bool m_ImageSizeOK;
00129
00130 mutable double m_Curvature;
00131 mutable double m_Magnitude;
00132 double m_EpsilonMagnitude;
00133 mutable bool m_BorderPixel;
00134
00135 mutable vnl_vector_fixed<double,itkGetStaticConstMacro(ImageDimension)>
00136 m_FirstDerivative;
00137 mutable vnl_matrix_fixed<double,itkGetStaticConstMacro(ImageDimension),
00138 itkGetStaticConstMacro(ImageDimension)>
00139 m_SecondDerivative;
00140
00141 mutable IndexType m_NeighIndex;
00142 mutable IndexType m_RightIndex;
00143 mutable IndexType m_LeftIndex;
00144 mutable double m_CenterValue;
00145 mutable double m_DiffValue;
00146
00147 mutable vnl_matrix_fixed<unsigned int,itkGetStaticConstMacro(ImageDimension),
00148 itkGetStaticConstMacro(ImageDimension)>
00149 m_Variable;
00150
00151 void CalculateDerivatives( const IndexType& index ) const;
00152 void CalculateCurvature() const;
00153 void CalculateCurvature2D() const;
00154 void CalculateCurvature3D() const;
00155
00156 };
00157
00158 }
00159
00160 #ifndef ITK_MANUAL_INSTANTIATION
00161 #include "itkLevelSetCurvatureFunction.txx"
00162 #endif
00163
00164 #endif