ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkGaussianOperator.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 __itkGaussianOperator_h
00019 #define __itkGaussianOperator_h
00020 
00021 #include "itkNeighborhoodOperator.h"
00022 #include <math.h>
00023 namespace itk
00024 {
00065 template< class TPixel, unsigned int VDimension = 2,
00066           class TAllocator = NeighborhoodAllocator< TPixel > >
00067 class ITK_EXPORT GaussianOperator:
00068   public NeighborhoodOperator< TPixel, VDimension, TAllocator >
00069 {
00070 public:
00071 
00073   typedef GaussianOperator                                       Self;
00074   typedef NeighborhoodOperator< TPixel, VDimension, TAllocator > Superclass;
00075 
00077   GaussianOperator():m_Variance(1), m_MaximumError(.01), m_MaximumKernelWidth(30) {}
00078 
00080   GaussianOperator(const Self & other):
00081     NeighborhoodOperator< TPixel, VDimension, TAllocator >(other)
00082   {
00083     m_Variance = other.m_Variance;
00084     m_MaximumError = other.m_MaximumError;
00085     m_MaximumKernelWidth = other.m_MaximumKernelWidth;
00086   }
00088 
00090   Self & operator=(const Self & other)
00091   {
00092     Superclass::operator=(other);
00093     m_Variance = other.m_Variance;
00094     m_MaximumError = other.m_MaximumError;
00095     m_MaximumKernelWidth = other.m_MaximumKernelWidth;
00096     return *this;
00097   }
00099 
00101   void SetVariance(const double & variance)
00102   {
00103     m_Variance = variance;
00104   }
00105 
00110   void SetMaximumError(const double & max_error)
00111   {
00112     if ( max_error >= 1 || max_error <= 0 )
00113       {
00114       itkExceptionMacro("Maximum Error Must be in the range [ 0.0 , 1.0 ]");
00115       }
00116 
00117     m_MaximumError = max_error;
00118   }
00119 
00121   double GetVariance()
00122   {  return m_Variance;  }
00123 
00128   double GetMaximumError()
00129   {    return m_MaximumError;  }
00130 
00135   void SetMaximumKernelWidth(unsigned int n)
00136   {    m_MaximumKernelWidth = n; }
00137 
00139   unsigned int GetMaximumKernelWidth() const
00140   {   return m_MaximumKernelWidth; }
00141 
00143   virtual void PrintSelf(std::ostream & os, Indent i) const
00144   {
00145     os << i << "GaussianOperator { this=" << this
00146        << ", m_Variance = " << m_Variance
00147        << ", m_MaximumError = " << m_MaximumError
00148        << "} "  << std::endl;
00149     Superclass::PrintSelf( os, i.GetNextIndent() );
00150   }
00152 
00153 protected:
00154   typedef typename Superclass::CoefficientVector CoefficientVector;
00155 
00158   double ModifiedBesselI0(double);
00159 
00162   double ModifiedBesselI1(double);
00163 
00166   double ModifiedBesselI(int, double);
00167 
00169   CoefficientVector GenerateCoefficients();
00170 
00172   void Fill(const CoefficientVector & coeff)
00173   {    this->FillCenteredDirectional(coeff);  }
00174 private:
00175 
00177   double m_Variance;
00178 
00181   double m_MaximumError;
00182 
00186   unsigned int m_MaximumKernelWidth;
00187 
00189   const char * GetNameOfClass()
00190   { return "itkGaussianOperator"; }
00191 };
00192 } // namespace itk
00193 
00194 // Define instantiation macro for this template.
00195 #define ITK_TEMPLATE_GaussianOperator(_, EXPORT, TypeX, TypeY)     \
00196   namespace itk                                                    \
00197   {                                                                \
00198   _( 2 ( class EXPORT GaussianOperator< ITK_TEMPLATE_2 TypeX > ) ) \
00199   namespace Templates                                              \
00200   {                                                                \
00201   typedef GaussianOperator< ITK_TEMPLATE_2 TypeX >                 \
00202   GaussianOperator##TypeY;                                       \
00203   }                                                                \
00204   }
00205 
00206 #if ITK_TEMPLATE_EXPLICIT
00207 #include "Templates/itkGaussianOperator+-.h"
00208 #endif
00209 
00210 #if ITK_TEMPLATE_TXX
00211 #include "itkGaussianOperator.hxx"
00212 #endif
00213 
00214 #endif
00215