ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkGaussianDerivativeOperator.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 __itkGaussianDerivativeOperator_h
00019 #define __itkGaussianDerivativeOperator_h
00020 
00021 #include "itkGaussianOperator.h"
00022 #include "itkDerivativeOperator.h"
00023 
00024 namespace itk
00025 {
00075 template< class TPixel, unsigned int VDimension = 2,
00076           class TAllocator = NeighborhoodAllocator< TPixel > >
00077 class ITK_EXPORT GaussianDerivativeOperator :
00078   public NeighborhoodOperator< TPixel, VDimension, TAllocator >
00079 {
00080 public:
00081 
00083   typedef GaussianDerivativeOperator                             Self;
00084   typedef NeighborhoodOperator< TPixel, VDimension, TAllocator > Superclass;
00085 
00087   typedef GaussianOperator< TPixel, VDimension, TAllocator >   GaussianOperatorType;
00088   typedef DerivativeOperator< TPixel, VDimension, TAllocator > DerivativeOperatorType;
00089 
00091   GaussianDerivativeOperator();
00092 
00094   GaussianDerivativeOperator(const Self & other);
00095 
00097   Self & operator=(const Self & other);
00098 
00099 
00108   void SetNormalizeAcrossScale(bool flag) { m_NormalizeAcrossScale = flag; }
00109   bool GetNormalizeAcrossScale() const { return m_NormalizeAcrossScale; }
00110   itkBooleanMacro(NormalizeAcrossScale);
00112 
00116   void SetVariance(const double variance) { m_Variance = variance; }
00117   double GetVariance() const { return m_Variance; }
00119 
00121   void SetSpacing(const double spacing) { m_Spacing = spacing; }
00122   double GetSpacing() const { return m_Spacing; }
00124 
00129   void SetMaximumError(const double maxerror)
00130   {
00131     const double Min = 0.00001;
00132     const double Max = 1.0 - Min;
00133 
00134     m_MaximumError = std::max( Min, std::min( Max, maxerror ) );
00135   }
00136   double GetMaximumError() { return m_MaximumError; }
00137 
00142   void SetMaximumKernelWidth(unsigned int n)
00143   {
00144     m_MaximumKernelWidth = n;
00145   }
00146 
00148   void SetOrder(const unsigned int order) { m_Order = order;}
00149   unsigned int GetOrder() const { return m_Order; }
00151 
00153   virtual void PrintSelf(std::ostream & os, Indent i) const;
00154 
00155 protected:
00156 
00157   typedef typename Superclass::CoefficientVector CoefficientVector;
00158 
00161   static double ModifiedBesselI0(double);
00162 
00165   static double ModifiedBesselI1(double);
00166 
00169   static double ModifiedBesselI(int, double);
00170 
00172   CoefficientVector GenerateCoefficients();
00173 
00175   void Fill(const CoefficientVector & coeff)
00176   { this->FillCenteredDirectional(coeff); }
00177 private:
00178 
00179   /* methods for generations of the coeeficients for a gaussian
00180    * operator of 0-order respecting the remaining parameters */
00181   CoefficientVector GenerateGaussianCoefficients() const;
00182 
00184   const char * GetNameOfClass() const
00185   {
00186     return "itkGaussianDerivativeOperator";
00187   }
00188 
00190   bool m_NormalizeAcrossScale;
00191 
00193   double m_Variance;
00194 
00197   double m_MaximumError;
00198 
00202   unsigned int m_MaximumKernelWidth;
00203 
00205   unsigned int m_Order;
00206 
00208   double m_Spacing;
00209 };
00210 } // namespace itk
00211 
00212 #if 0 //HACK: Not yet implemented
00213 // Define instantiation macro for this template.
00214 #define ITK_TEMPLATE_GaussianDerivativeOperator(_, EXPORT, TypeX, TypeY)     \
00215   namespace itk                                                              \
00216   {                                                                          \
00217   _( 2 ( class EXPORT GaussianDerivativeOperator< ITK_TEMPLATE_2 TypeX > ) ) \
00218   namespace Templates                                                        \
00219   {                                                                          \
00220   typedef GaussianDerivativeOperator< ITK_TEMPLATE_2 TypeX >                 \
00221   GaussianDerivativeOperator##TypeY;                                       \
00222   }                                                                          \
00223   }
00224 
00225 #if ITK_TEMPLATE_EXPLICIT
00226 #include "Templates/itkGaussianDerivativeOperator+-.h"
00227 #endif
00228 #endif
00229 
00230 #if ITK_TEMPLATE_TXX
00231 #include "itkGaussianDerivativeOperator.hxx"
00232 #endif
00233 
00234 #endif
00235