itkGaussianBlurImageFunction.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkGaussianBlurImageFunction_h
00018 #define __itkGaussianBlurImageFunction_h
00019
00020 #include "itkNeighborhoodOperatorImageFunction.h"
00021 #include "itkGaussianOperator.h"
00022 #include "itkGaussianSpatialFunction.h"
00023 #include "itkImageFunction.h"
00024 #include "itkCastImageFilter.h"
00025
00026 namespace itk
00027 {
00028
00038 template <class TInputImage,class TOutput=double>
00039 class ITK_EXPORT GaussianBlurImageFunction :
00040 public ImageFunction< TInputImage, TOutput >
00041 {
00042 public:
00043
00045 typedef GaussianBlurImageFunction Self;
00046
00048 typedef ImageFunction<TInputImage, TOutput> Superclass;
00049
00051 typedef SmartPointer<Self> Pointer;
00052 typedef SmartPointer<const Self> ConstPointer;
00053
00055 itkNewMacro(Self);
00056
00058 itkTypeMacro( GaussianBlurImageFunction, ImageFunction );
00059
00061 typedef TInputImage InputImageType;
00062 typedef typename InputImageType::PixelType InputPixelType;
00063 typedef typename Superclass::IndexType IndexType;
00064 typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
00065
00066
00068 itkStaticConstMacro(ImageDimension, unsigned int, InputImageType::ImageDimension);
00069
00070 typedef GaussianOperator<
00071 TOutput, itkGetStaticConstMacro(ImageDimension)> GaussianOperatorType;
00072 typedef Neighborhood<TOutput, itkGetStaticConstMacro(ImageDimension)> NeighborhoodType;
00073 typedef FixedArray<NeighborhoodType,itkGetStaticConstMacro(ImageDimension)> OperatorArrayType;
00074
00075 typedef GaussianSpatialFunction<TOutput,1> GaussianFunctionType;
00076 typedef typename GaussianFunctionType::Pointer GaussianFunctionPointer;
00077 typedef itk::Image<double,itkGetStaticConstMacro(ImageDimension)> InternalImageType;
00078 typedef typename InternalImageType::Pointer InternalImagePointer;
00079
00080 typedef NeighborhoodOperatorImageFunction< InternalImageType, TOutput> OperatorImageFunctionType;
00081 typedef typename OperatorImageFunctionType::Pointer OperatorImageFunctionPointer;
00082
00083 typedef itk::CastImageFilter<InputImageType,InternalImageType> CastImageFilterType;
00084 typedef typename CastImageFilterType::Pointer CastImageFilterPointer;
00085
00086 typedef itk::FixedArray< double, itkGetStaticConstMacro(ImageDimension) > ErrorArrayType;
00087 typedef itk::FixedArray< double, itkGetStaticConstMacro(ImageDimension) > ExtentArrayType;
00088 typedef itk::FixedArray< double, itkGetStaticConstMacro(ImageDimension) > SigmaArrayType;
00089
00091 typedef typename Superclass::PointType PointType;
00092
00094 virtual TOutput Evaluate(const PointType& point) const;
00095
00096
00098 virtual TOutput EvaluateAtIndex( const IndexType & index ) const;
00099
00101 virtual TOutput EvaluateAtContinuousIndex(
00102 const ContinuousIndexType & index ) const;
00103
00110 void SetSigma( const double* sigma);
00111 void SetSigma( const float* sigma);
00112 void SetSigma( const double sigma);
00113 itkSetMacro( Sigma, SigmaArrayType );
00114 itkGetConstReferenceMacro( Sigma, SigmaArrayType );
00116
00121 virtual void SetInputImage( const InputImageType * ptr );
00122
00126 itkSetMacro( Extent, ExtentArrayType );
00127 itkGetConstReferenceMacro( Extent, ExtentArrayType );
00128 void SetExtent( const double* extent);
00129 void SetExtent( const double extent);
00131
00135 itkSetMacro( MaximumError, ErrorArrayType );
00136 itkGetConstReferenceMacro( MaximumError, ErrorArrayType );
00138
00143 itkSetMacro( MaximumKernelWidth, int );
00144 itkGetConstMacro( MaximumKernelWidth, int );
00146
00152 itkSetMacro( UseImageSpacing, bool );
00153 itkGetConstMacro( UseImageSpacing, bool );
00154 itkBooleanMacro( UseImageSpacing );
00156
00157
00158 protected:
00159 GaussianBlurImageFunction();
00160 GaussianBlurImageFunction( const Self& ){};
00161
00162 ~GaussianBlurImageFunction(){};
00163
00164 void operator=( const Self& ){};
00165 void PrintSelf(std::ostream& os, Indent indent) const;
00166
00167 void RecomputeGaussianKernel();
00168 void RecomputeContinuousGaussianKernel(const double* offset) const;
00169
00170 private:
00171
00172 virtual TOutput EvaluateAtIndex(
00173 const IndexType & index, const OperatorArrayType & operatorArray ) const;
00174
00175 SigmaArrayType m_Sigma;
00176 OperatorImageFunctionPointer m_OperatorImageFunction;
00177 mutable OperatorArrayType m_OperatorArray;
00178 mutable OperatorArrayType m_ContinuousOperatorArray;
00179 InternalImagePointer m_InternalImage;
00180 CastImageFilterPointer m_Caster;
00181
00185 ErrorArrayType m_MaximumError;
00186 ExtentArrayType m_Extent;
00187
00190 int m_MaximumKernelWidth;
00191
00193 unsigned int m_FilterDimensionality;
00194
00196 bool m_UseImageSpacing;
00197
00199 GaussianFunctionPointer m_GaussianFunction;
00200 };
00201
00202 }
00203
00204
00205 #define ITK_TEMPLATE_GaussianBlurImageFunction(_, EXPORT, x, y) namespace itk { \
00206 _(2(class EXPORT GaussianBlurImageFunction< ITK_TEMPLATE_2 x >)) \
00207 namespace Templates { typedef GaussianBlurImageFunction< ITK_TEMPLATE_2 x > \
00208 GaussianBlurImageFunction##y; } \
00209 }
00210
00211 #if ITK_TEMPLATE_EXPLICIT
00212 # include "Templates/itkGaussianBlurImageFunction+-.h"
00213 #endif
00214
00215 #if ITK_TEMPLATE_TXX
00216 # include "itkGaussianBlurImageFunction.txx"
00217 #endif
00218
00219 #endif
00220