00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkExpNegativeImageFilter.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/01/21 23:33:00 $ 00007 Version: $Revision: 1.2 $ 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 __itkExpNegativeImageFilter_h 00018 #define __itkExpNegativeImageFilter_h 00019 00020 #include "itkUnaryFunctorImageFilter.h" 00021 #include "vnl/vnl_math.h" 00022 00023 namespace itk 00024 { 00025 00036 namespace Function { 00037 template< class TInput, class TOutput> 00038 class ExpNegative 00039 { 00040 public: 00041 ExpNegative() { m_Factor = 1.0; } 00042 ~ExpNegative() {}; 00043 inline TOutput operator()( const TInput & A ) 00044 { 00045 return static_cast<TOutput>( exp( - m_Factor * static_cast<double>(A) ) ); 00046 } 00047 void SetFactor( double factor ) { 00048 m_Factor = factor; 00049 } 00050 double GetFactor() const { 00051 return m_Factor; 00052 } 00053 private: 00054 double m_Factor; 00055 }; 00056 } 00057 template <class TInputImage, class TOutputImage> 00058 class ITK_EXPORT ExpNegativeImageFilter : 00059 public 00060 UnaryFunctorImageFilter<TInputImage,TOutputImage, 00061 Function::ExpNegative< 00062 typename TInputImage::PixelType, 00063 typename TOutputImage::PixelType> > 00064 { 00065 public: 00067 typedef ExpNegativeImageFilter Self; 00068 typedef UnaryFunctorImageFilter<TInputImage,TOutputImage, 00069 Function::ExpNegative< typename TInputImage::PixelType, 00070 typename TOutputImage::PixelType> > Superclass; 00071 typedef SmartPointer<Self> Pointer; 00072 typedef SmartPointer<const Self> ConstPointer; 00073 00075 itkNewMacro(Self); 00076 00077 void SetFactor( double factor ) 00078 { 00079 if( factor == this->GetFunctor().GetFactor() ) 00080 { 00081 return; 00082 } 00083 this->GetFunctor().SetFactor( factor ); 00084 this->Modified(); 00085 } 00086 protected: 00087 ExpNegativeImageFilter() {} 00088 virtual ~ExpNegativeImageFilter() {} 00089 00090 private: 00091 ExpNegativeImageFilter(const Self&); //purposely not implemented 00092 void operator=(const Self&); //purposely not implemented 00093 00094 }; 00095 00096 } // end namespace itk 00097 00098 00099 #endif