KWStyle - itkGaussianBlurImageFunction.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkGaussianBlurImageFunction.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:36 $
7   Version:   $Revision: 1.4 $
8
9   Copyright (c) Insight Software Consortium. All rights reserved.
10   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11
12      This software is distributed WITHOUT ANY WARRANTY; without even 
13      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14      PURPOSE.  See the above copyright notices for more information.
15
16 =========================================================================*/
17 DEF #ifndef _itkGaussianBlurImageFunction_h
18 DEF #define _itkGaussianBlurImageFunction_h
19
20 #include "itkNeighborhoodOperatorImageFunction.h"
21 #include "itkGaussianOperator.h"
22 #include "itkGaussianSpatialFunction.h"
23 #include "itkImageFunction.h"
24 #include "itkCastImageFilter.h"
25
26 namespace itk
27 {
28
29 /**
30  * \class GaussianBlurImageFunction
31  * \brief Compute the convolution of a neighborhood operator with the image
32  *        at a specific location in space, i.e. point, index or continuous
33  *        index.
34  * This class is templated over the input image type.
35  * \sa NeighborhoodOperator
36  * \sa ImageFunction
37  */
38 template <class TInputImage,class TOutput=double>
39 class ITK_EXPORT GaussianBlurImageFunction :
40 IND **public ImageFunction< TInputImage, TOutput >
41 {
42 public:
43
44   /**Standard "Self" typedef */
45   typedef GaussianBlurImageFunction Self;
46
47   /** Standard "Superclass" typedef*/
48   typedef ImageFunction<TInputImage, TOutput> Superclass;
49
50   /** Smart pointer typedef support. */
51   typedef SmartPointer<Self> Pointer;
52 TDA   typedef SmartPointer<const Self>  ConstPointer;
53
54   /** Method for creation through the object factory.*/
55   itkNewMacro(Self);
56
57   /** Run-time type information (and related methods). */
58   itkTypeMacro( GaussianBlurImageFunction, ImageFunction );
59
60   /** InputImageType typedef support.*/
61   typedef TInputImage                                 InputImageType;
62   typedef typename InputImageType::PixelType          InputPixelType;
63   typedef typename Superclass::IndexType              IndexType;
64   typedef typename Superclass::ContinuousIndexType    ContinuousIndexType;
65
66
67   /** Dimension of the underlying image. */
68   itkStaticConstMacro(ImageDimension, unsigned int,
69                       InputImageType::ImageDimension);
70   
71   typedef GaussianOperator<TOutput,
72                            itkGetStaticConstMacro(ImageDimension)> 
73 IND ******************************************************GaussianOperatorType;
74 LEN,TDA   typedef Neighborhood<TOutput, itkGetStaticConstMacro(ImageDimension)> NeighborhoodType;
75 LEN,TDA   typedef FixedArray<NeighborhoodType,itkGetStaticConstMacro(ImageDimension)> OperatorArrayType;
76   
77   typedef GaussianSpatialFunction<TOutput,1>  GaussianFunctionType;
78 TDA   typedef typename GaussianFunctionType::Pointer GaussianFunctionPointer;
79 LEN,TDA   typedef itk::Image<double,itkGetStaticConstMacro(ImageDimension)> InternalImageType;
80   typedef typename InternalImageType::Pointer InternalImagePointer;
81
82   typedef NeighborhoodOperatorImageFunction<InternalImageType,
83                                              TOutput> OperatorImageFunctionType;
84 LEN   typedef typename OperatorImageFunctionType::Pointer OperatorImageFunctionPointer;
85
86 LEN   typedef itk::CastImageFilter<InputImageType,InternalImageType> CastImageFilterType;
87 TDA   typedef typename CastImageFilterType::Pointer CastImageFilterPointer;
88
89   typedef itk::FixedArray< double, 
90                   itkGetStaticConstMacro(ImageDimension) >   ErrorArrayType;
91
92   typedef itk::FixedArray< double, 
93                   itkGetStaticConstMacro(ImageDimension) >   ExtentArrayType;
94
95   typedef itk::FixedArray< double, 
96                   itkGetStaticConstMacro(ImageDimension) >   SigmaArrayType;
97
98   /** Point typedef support. */
99   typedef typename Superclass::PointType PointType;
100   
101   /** Evalutate the  in the given dimension at specified point */
102 IND ***virtual TOutput Evaluate(const PointType& point) const;
103
104
105   /** Evaluate the function at specified Index position*/
106   virtual TOutput EvaluateAtIndex( const IndexType & index ) const;
107
108   /** Evaluate the function at specified ContinousIndex position.*/
109   virtual TOutput EvaluateAtContinuousIndex( 
110     const ContinuousIndexType & index ) const;
111
112   /** The standard deviation for the discrete Gaussian kernel.  Sets the
113    * standard deviation independently for each dimension.
114    * The default is 1.0 in each dimension. 
115    * If UseImageSpacing is true (default), the units are the physical units
116    * of your image.  If UseImageSpacing is false then the units are pixels.
117    */
118   void SetSigma( const double* sigma);
119   void SetSigma( const float* sigma);
120   void SetSigma( const double sigma);
121   itkSetMacro( Sigma, SigmaArrayType );
122   itkGetConstReferenceMacro( Sigma, SigmaArrayType );
123   
124   /** Set the input image.
125    * \warning this method caches BufferedRegion information.
126    * If the BufferedRegion has changed, user must call
127    * SetInputImage again to update cached values. */
128   virtual void SetInputImage( const InputImageType * ptr );
129
130   /** Set/Get the Extent of the array holding the coefficients
131    *  of the Gaussian kernel computed by the GaussianOperator.
132    */
133   itkSetMacro( Extent, ExtentArrayType );
134   itkGetConstReferenceMacro( Extent, ExtentArrayType );
135   void SetExtent( const double* extent);
136   void SetExtent( const double extent);
137
138   /** Set/Get the maximum error acceptable for the approximation
139    *  of the Gaussian kernel with the GaussianOperator.
140    */
141   itkSetMacro( MaximumError, ErrorArrayType );
142   itkGetConstReferenceMacro( MaximumError, ErrorArrayType );
143
144   /** Set/GetMaximumKernelWidth() This value is used by the underling 
145    *  GaussianOperator for computing the number of coefficients to be 
146    *  used in the Gaussian kernel  
147    */
148   itkSetMacro( MaximumKernelWidth, int );
149   itkGetMacro( MaximumKernelWidth, int );
150
151   /** Set/GetUseImageSpacing() This flag is used by the underling 
152    *  GaussianOperator to decide if the image spacing should be used
153    *  to scale the value of sigma or not. The methods UseImageSpacingOn() 
154    *  and UseImageSpacingOff() provide a similar functionality.
155    */
156   itkSetMacro( UseImageSpacing, bool );
157   itkGetMacro( UseImageSpacing, bool );
158   itkBooleanMacro( UseImageSpacing );
159
160
161 protected:
162   GaussianBlurImageFunction();
163   GaussianBlurImageFunction( const Self& ){};
164
165   ~GaussianBlurImageFunction(){};
166
167   void operator=( const Self& ){};
168   void PrintSelf(std::ostream& os, Indent indent) const;
169
170   void RecomputeGaussianKernel();
171   void RecomputeContinuousGaussianKernel(const double* offset) const;
172
173 private:
174   
175   SigmaArrayType                m_Sigma;
176   OperatorImageFunctionPointer  m_OperatorImageFunction;
177   mutable OperatorArrayType     m_OperatorArray;
178   mutable OperatorArrayType     m_ContinuousOperatorArray;
179   InternalImagePointer          m_InternalImage;
180   CastImageFilterPointer        m_Caster;
181
182   /** The maximum error of the gaussian blurring kernel in each dimensional
183    * direction. For definition of maximum error, see GaussianOperator.
184    * \sa GaussianOperator */
185   ErrorArrayType                m_MaximumError;
186   ExtentArrayType               m_Extent;
187
188   /** Maximum allowed kernel width for any dimension of the discrete Gaussian
189 IND ******approximation */
190   int m_MaximumKernelWidth;
191
192   /** Number of dimensions to process. Default is all dimensions */
193   unsigned int m_FilterDimensionality;
194
195   /** Flag to indicate whether to use image spacing */
196   bool m_UseImageSpacing;
197
198   /** Neighborhood Image Function */
199   GaussianFunctionPointer m_GaussianFunction;
200 };
201
202 // namespace itk
203
204 #ifndef ITK_MANUAL_INSTANTIATION
205 #include "itkGaussianBlurImageFunction.txx"
206 #endif
207
208 #endif
209
210 EOF

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:09PM
© Kitware Inc.