ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkGaussianBlurImageFunction.h
Go to the documentation of this file.
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 __itkGaussianBlurImageFunction_h
00019 #define __itkGaussianBlurImageFunction_h
00020 
00021 #include "itkNeighborhoodOperatorImageFunction.h"
00022 #include "itkGaussianOperator.h"
00023 #include "itkGaussianSpatialFunction.h"
00024 
00025 namespace itk
00026 {
00042 template< class TInputImage, class TOutput = double >
00043 class ITK_EXPORT GaussianBlurImageFunction:
00044   public ImageFunction< TInputImage, TOutput >
00045 {
00046 public:
00047 
00049   typedef GaussianBlurImageFunction Self;
00050 
00052   typedef ImageFunction< TInputImage, TOutput > Superclass;
00053 
00055   typedef SmartPointer< Self >       Pointer;
00056   typedef SmartPointer< const Self > ConstPointer;
00057 
00059   itkNewMacro(Self);
00060 
00062   itkTypeMacro(GaussianBlurImageFunction, ImageFunction);
00063 
00065   typedef TInputImage                              InputImageType;
00066   typedef typename InputImageType::PixelType       InputPixelType;
00067   typedef typename Superclass::IndexType           IndexType;
00068   typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
00069 
00071   itkStaticConstMacro(ImageDimension, unsigned int, InputImageType::ImageDimension);
00072 
00073   typedef GaussianOperator<
00074     TOutput, itkGetStaticConstMacro(ImageDimension) >                            GaussianOperatorType;
00075   typedef Neighborhood< TOutput, itkGetStaticConstMacro(ImageDimension) >        NeighborhoodType;
00076   typedef FixedArray< NeighborhoodType, itkGetStaticConstMacro(ImageDimension) > OperatorArrayType;
00077 
00078   typedef GaussianSpatialFunction< TOutput, 1 >                        GaussianFunctionType;
00079   typedef typename GaussianFunctionType::Pointer                       GaussianFunctionPointer;
00080   typedef typename NumericTraits< InputPixelType >::RealType           InputPixelRealType;
00081   typedef itk::Image<
00082     InputPixelRealType, itkGetStaticConstMacro(ImageDimension) >       InternalImageType;
00083   typedef typename InternalImageType::Pointer                          InternalImagePointer;
00084 
00085   typedef NeighborhoodOperatorImageFunction< InputImageType, TOutput >    OperatorImageFunctionType;
00086   typedef typename OperatorImageFunctionType::Pointer                     OperatorImageFunctionPointer;
00087 
00088   typedef NeighborhoodOperatorImageFunction< InternalImageType, TOutput > OperatorInternalImageFunctionType;
00089   typedef typename OperatorInternalImageFunctionType::Pointer             OperatorInternalImageFunctionPointer;
00090 
00091   typedef itk::FixedArray< double, itkGetStaticConstMacro(ImageDimension) > ErrorArrayType;
00092   typedef itk::FixedArray< double, itkGetStaticConstMacro(ImageDimension) > ExtentArrayType;
00093   typedef itk::FixedArray< double, itkGetStaticConstMacro(ImageDimension) > SigmaArrayType;
00094 
00096   typedef typename Superclass::PointType PointType;
00097 
00099   virtual TOutput Evaluate(const PointType & point) const;
00100 
00102   virtual TOutput EvaluateAtIndex(const IndexType & index) const;
00103 
00105   virtual TOutput EvaluateAtContinuousIndex(
00106     const ContinuousIndexType & index) const;
00107 
00114   void SetSigma(const double *sigma);
00115 
00116   void SetSigma(const float *sigma);
00117 
00118   void SetSigma(const double sigma);
00119 
00120   itkSetMacro(Sigma, SigmaArrayType);
00121   itkGetConstReferenceMacro(Sigma, SigmaArrayType);
00122 
00127   virtual void SetInputImage(const InputImageType *ptr);
00128 
00132   itkSetMacro(Extent, ExtentArrayType);
00133   itkGetConstReferenceMacro(Extent, ExtentArrayType);
00134   void SetExtent(const double *extent);
00136 
00137   void SetExtent(const double extent);
00138 
00142   itkSetMacro(MaximumError, ErrorArrayType);
00143   itkGetConstReferenceMacro(MaximumError, ErrorArrayType);
00145 
00150   itkSetMacro(MaximumKernelWidth, int);
00151   itkGetConstMacro(MaximumKernelWidth, int);
00153 
00159   itkSetMacro(UseImageSpacing, bool);
00160   itkGetConstMacro(UseImageSpacing, bool);
00161   itkBooleanMacro(UseImageSpacing);
00162 protected:
00163   GaussianBlurImageFunction();
00164   GaussianBlurImageFunction(const Self &);
00166 
00167   ~GaussianBlurImageFunction(){}
00168 
00169   void operator=(const Self &);
00170 
00171   void PrintSelf(std::ostream & os, Indent indent) const;
00172 
00173   void RecomputeGaussianKernel();
00174 
00175   void RecomputeContinuousGaussianKernel(const double *offset) const;
00176 
00177 private:
00178 
00179   virtual TOutput EvaluateAtIndex(
00180     const IndexType & index, const OperatorArrayType & operatorArray) const;
00181 
00182   SigmaArrayType                        m_Sigma;
00183   OperatorImageFunctionPointer          m_OperatorImageFunction;
00184   OperatorInternalImageFunctionPointer  m_OperatorInternalImageFunction;
00185   mutable OperatorArrayType             m_OperatorArray;
00186   mutable OperatorArrayType             m_ContinuousOperatorArray;
00187   InternalImagePointer                  m_InternalImage;
00188 
00192   ErrorArrayType  m_MaximumError;
00193   ExtentArrayType m_Extent;
00194 
00197   int m_MaximumKernelWidth;
00198 
00200   unsigned int m_FilterDimensionality;
00201 
00203   bool m_UseImageSpacing;
00204 
00206   GaussianFunctionPointer m_GaussianFunction;
00207 };
00208 } // end namespace itk
00209 
00210 // Define instantiation macro for this template.
00211 #define ITK_TEMPLATE_GaussianBlurImageFunction(_, EXPORT, TypeX, TypeY)     \
00212   namespace itk                                                             \
00213   {                                                                         \
00214   _( 2 ( class EXPORT GaussianBlurImageFunction< ITK_TEMPLATE_2 TypeX > ) ) \
00215   namespace Templates                                                       \
00216   {                                                                         \
00217   typedef GaussianBlurImageFunction< ITK_TEMPLATE_2 TypeX >                 \
00218   GaussianBlurImageFunction##TypeY;                                       \
00219   }                                                                         \
00220   }
00221 
00222 #if ITK_TEMPLATE_EXPLICIT
00223 #include "Templates/itkGaussianBlurImageFunction+-.h"
00224 #endif
00225 
00226 #if ITK_TEMPLATE_TXX
00227 #include "itkGaussianBlurImageFunction.hxx"
00228 #endif
00229 
00230 #endif
00231