Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkSigmoidImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkSigmoidImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2003/01/24 17:07:01 $
00007   Version:   $Revision: 1.6 $
00008 
00009   Copyright (c) 2002 Insight Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkSigmoidImageFilter_h
00018 #define __itkSigmoidImageFilter_h
00019 
00020 #include "itkUnaryFunctorImageFilter.h"
00021 
00022 namespace itk
00023 {
00024   
00042 namespace Function {  
00043   template< class TInput, class TOutput>
00044   class Sigmoid
00045   {
00046   public:
00047     Sigmoid() { 
00048       m_Alpha = 1.0; 
00049       m_Beta =  0.0; 
00050       m_OutputMinimum = NumericTraits< TOutput >::min();
00051       m_OutputMaximum = NumericTraits< TOutput >::max();
00052     }
00053     ~Sigmoid() {};
00054     inline TOutput operator()( const TInput & A )
00055     {
00056       const double x = ( static_cast<double>(A) - m_Beta ) / m_Alpha;
00057       const double e = 1.0 / ( 1.0 + exp( - x ) );
00058       const double v = 
00059         (m_OutputMaximum - m_OutputMinimum ) * e + m_OutputMinimum;
00060       return static_cast<TOutput>( v );
00061     }
00062   void SetAlpha( double alpha ) {
00063     m_Alpha = alpha;
00064     }
00065   void SetBeta( double beta ) {
00066     m_Beta = beta;
00067     }
00068   double GetAlpha() const {
00069     return m_Alpha;
00070     }
00071   double GetBeta() const {
00072     return m_Beta;
00073     }
00074   void SetOutputMinimum( TOutput min ) {
00075     m_OutputMinimum = min;
00076     }
00077   void SetOutputMaximum( TOutput max ) {
00078     m_OutputMaximum = max;
00079     }
00080   TOutput GetOutputMinimum() const {
00081     return m_OutputMinimum;
00082     }
00083   TOutput GetOutputMaximum() const {
00084     return m_OutputMaximum;
00085     }
00086 
00087   private:
00088     double  m_Alpha;
00089     double  m_Beta;
00090     TOutput m_OutputMinimum;
00091     TOutput m_OutputMaximum;
00092   }; 
00093 }
00094 
00095 
00096 template <class TInputImage, class TOutputImage>
00097 class ITK_EXPORT SigmoidImageFilter :
00098     public
00099     UnaryFunctorImageFilter<TInputImage,TOutputImage, 
00100     Function::Sigmoid< 
00101               typename TInputImage::PixelType, 
00102               typename TOutputImage::PixelType>   >
00103 {
00104 public:
00106   typedef SigmoidImageFilter  Self;
00107   typedef UnaryFunctorImageFilter<TInputImage,TOutputImage, 
00108     Function::Sigmoid< typename TInputImage::PixelType, 
00109                    typename TOutputImage::PixelType> >  Superclass;
00110   typedef SmartPointer<Self>   Pointer;
00111   typedef SmartPointer<const Self>  ConstPointer;
00112 
00113   typedef typename TOutputImage::PixelType OutputPixelType;
00114 
00116   itkNewMacro(Self);
00117   
00118   void SetAlpha( double alpha )
00119     {
00120     if( alpha == this->GetFunctor().GetAlpha() ) 
00121       {
00122       return;
00123       }
00124     this->GetFunctor().SetAlpha( alpha );
00125     this->Modified();
00126     }
00127 
00128   void SetBeta( double beta )
00129     {
00130     if( beta == this->GetFunctor().GetBeta() ) 
00131       {
00132       return;
00133       }
00134     this->GetFunctor().SetBeta( beta );
00135     this->Modified();
00136     }
00137 
00138   void SetOutputMinimum( OutputPixelType min )
00139     {
00140     if( min == this->GetFunctor().GetOutputMinimum() ) 
00141       {
00142       return;
00143       }
00144     this->GetFunctor().SetOutputMinimum( min );
00145     this->Modified();
00146     }
00147 
00148   void SetOutputMaximum( OutputPixelType max )
00149     {
00150     if( max == this->GetFunctor().GetOutputMaximum() ) 
00151       {
00152       return;
00153       }
00154     this->GetFunctor().SetOutputMaximum( max );
00155     this->Modified();
00156     }
00157 
00158 protected:
00159   SigmoidImageFilter() {}
00160   virtual ~SigmoidImageFilter() {}
00161 
00162 private:
00163   SigmoidImageFilter(const Self&); //purposely not implemented
00164   void operator=(const Self&); //purposely not implemented
00165 
00166 };
00167 
00168 } // end namespace itk
00169 
00170 
00171 #endif

Generated at Fri May 21 01:15:18 2004 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000