ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkGaussianDerivativeImageFunction.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 __itkGaussianDerivativeImageFunction_h
00019 #define __itkGaussianDerivativeImageFunction_h
00020 
00021 #include "itkNeighborhoodOperatorImageFunction.h"
00022 #include "itkGaussianDerivativeSpatialFunction.h"
00023 #include "itkGaussianSpatialFunction.h"
00024 
00025 namespace itk
00026 {
00037 template< class TInputImage, class TOutput = double >
00038 class ITK_EXPORT GaussianDerivativeImageFunction:
00039   public ImageFunction< TInputImage,
00040                         Vector< TOutput, ::itk::GetImageDimension< TInputImage >::ImageDimension >,
00041                         TOutput >
00042 {
00043 public:
00044 
00046   typedef GaussianDerivativeImageFunction Self;
00047 
00049   typedef ImageFunction< TInputImage,
00050                          Vector< TOutput, ::itk::GetImageDimension< TInputImage >::ImageDimension >,
00051                          TOutput > Superclass;
00052 
00054   typedef SmartPointer< Self >       Pointer;
00055   typedef SmartPointer< const Self > ConstPointer;
00056 
00058   itkNewMacro(Self);
00059 
00061   itkTypeMacro(GaussianDerivativeImageFunction, ImageFunction);
00062 
00064   typedef TInputImage                        InputImageType;
00065   typedef typename InputImageType::PixelType InputPixelType;
00066   typedef typename InputImageType::IndexType IndexType;
00067 
00069   itkStaticConstMacro(ImageDimension2, unsigned int,
00070                       InputImageType::ImageDimension);
00071 
00072   typedef ContinuousIndex< TOutput, itkGetStaticConstMacro(ImageDimension2) >
00073   ContinuousIndexType;
00074 
00075   typedef Neighborhood< InputPixelType, itkGetStaticConstMacro(ImageDimension2) > NeighborhoodType;
00076   typedef Neighborhood< TOutput, itkGetStaticConstMacro(ImageDimension2) >        OperatorNeighborhoodType;
00077 
00078   typedef Vector< TOutput, itkGetStaticConstMacro(ImageDimension2) >                         VectorType;
00079   typedef typename Superclass::OutputType                                                    OutputType;
00080   typedef FixedArray< OperatorNeighborhoodType, 2 *itkGetStaticConstMacro(ImageDimension2) > OperatorArrayType;
00081   typedef NeighborhoodOperatorImageFunction< InputImageType,
00082                                              TOutput > OperatorImageFunctionType;
00083   typedef typename OperatorImageFunctionType::Pointer OperatorImageFunctionPointer;
00084 
00085   typedef GaussianDerivativeSpatialFunction< TOutput, 1 >  GaussianDerivativeFunctionType;
00086   typedef typename GaussianDerivativeFunctionType::Pointer GaussianDerivativeFunctionPointer;
00087 
00088   typedef GaussianSpatialFunction< TOutput, 1 >  GaussianFunctionType;
00089   typedef typename GaussianFunctionType::Pointer GaussianFunctionPointer;
00090 
00092   typedef Point< TOutput, itkGetStaticConstMacro(ImageDimension2) > PointType;
00093 
00095   virtual OutputType Evaluate(const PointType & point) const;
00096 
00098   virtual OutputType EvaluateAtIndex(const IndexType & index) const;
00099 
00101   virtual OutputType EvaluateAtContinuousIndex(
00102     const ContinuousIndexType & index) const;
00103 
00110   void SetSigma(const double *sigma);
00111 
00112   void SetSigma(const double sigma);
00113 
00114   const double * GetSigma() const { return m_Sigma; }
00115 
00117   void SetExtent(const double *extent);
00118 
00119   void SetExtent(const double extent);
00120 
00121   const double * GetExtent() const { return m_Extent; }
00122 
00127   virtual void SetInputImage(const InputImageType *ptr);
00128 
00129 protected:
00130   GaussianDerivativeImageFunction();
00131   GaussianDerivativeImageFunction(const Self &);
00132 
00133   ~GaussianDerivativeImageFunction(){}
00134 
00135   void operator=(const Self &);
00136 
00137   void PrintSelf(std::ostream & os, Indent indent) const;
00138 
00139   void RecomputeGaussianKernel();
00140 
00141   void RecomputeContinuousGaussianKernel(
00142     const double *offset) const;
00143 
00144 private:
00145 
00146   double m_Sigma[ImageDimension2];
00147 
00150   mutable OperatorArrayType m_OperatorArray;
00151   mutable OperatorArrayType m_ContinuousOperatorArray;
00152 
00154   OperatorImageFunctionPointer m_OperatorImageFunction;
00155   double                       m_Extent[ImageDimension2];
00156 
00158   bool m_UseImageSpacing;
00159 
00161   GaussianDerivativeFunctionPointer m_GaussianDerivativeFunction;
00162   GaussianFunctionPointer           m_GaussianFunction;
00163 };
00164 } // namespace itk
00165 
00166 // Define instantiation macro for this template.
00167 #define ITK_TEMPLATE_GaussianDerivativeImageFunction(_, EXPORT, TypeX, TypeY)                                \
00168   namespace itk                                                                                              \
00169   {                                                                                                          \
00170   _( 2 ( class EXPORT GaussianDerivativeImageFunction< ITK_TEMPLATE_2 TypeX > ) )                            \
00171   namespace Templates                                                                                        \
00172   {                                                                                                          \
00173   typedef GaussianDerivativeImageFunction< ITK_TEMPLATE_2 TypeX >  GaussianDerivativeImageFunction##TypeY; \
00174   }                                                                                                          \
00175   }
00176 
00177 #if ITK_TEMPLATE_EXPLICIT
00178 #include "Templates/itkGaussianDerivativeImageFunction+-.h"
00179 #endif
00180 
00181 #if ITK_TEMPLATE_TXX
00182 #include "itkGaussianDerivativeImageFunction.hxx"
00183 #endif
00184 
00185 #endif
00186