00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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
00044 bool operator!=( const ExpNegative & other ) const
00045 {
00046 if( m_Factor != other.m_Factor )
00047 {
00048 return true;
00049 }
00050 return false;
00051 }
00052 bool operator==( const ExpNegative & other ) const
00053 {
00054 return !(*this != other);
00055 }
00056
00057 inline TOutput operator()( const TInput & A )
00058 {
00059 return static_cast<TOutput>( vcl_exp(- m_Factor * static_cast<double>(A) ) );
00060 }
00061
00062 void SetFactor( double factor ) {
00063 m_Factor = factor;
00064 }
00065 double GetFactor() const {
00066 return m_Factor;
00067 }
00068 private:
00069 double m_Factor;
00070 };
00071 }
00072 template <class TInputImage, class TOutputImage>
00073 class ITK_EXPORT ExpNegativeImageFilter :
00074 public
00075 UnaryFunctorImageFilter<TInputImage,TOutputImage,
00076 Function::ExpNegative<
00077 typename TInputImage::PixelType,
00078 typename TOutputImage::PixelType> >
00079 {
00080 public:
00082 typedef ExpNegativeImageFilter Self;
00083 typedef UnaryFunctorImageFilter<TInputImage,TOutputImage,
00084 Function::ExpNegative< typename TInputImage::PixelType,
00085 typename TOutputImage::PixelType> > Superclass;
00086 typedef SmartPointer<Self> Pointer;
00087 typedef SmartPointer<const Self> ConstPointer;
00088
00090 itkNewMacro(Self);
00091
00093 itkTypeMacro(ExpNegativeImageFilter,
00094 UnaryFunctorImageFilter);
00095
00096 void SetFactor( double factor )
00097 {
00098 if( factor == this->GetFunctor().GetFactor() )
00099 {
00100 return;
00101 }
00102 this->GetFunctor().SetFactor( factor );
00103 this->Modified();
00104 }
00105
00106 #ifdef ITK_USE_CONCEPT_CHECKING
00107
00108 itkConceptMacro(InputConvertibleToDoubleCheck,
00109 (Concept::Convertible<typename TInputImage::PixelType, double>));
00110 itkConceptMacro(DoubleConvertibleToOutputCheck,
00111 (Concept::Convertible<double, typename TOutputImage::PixelType>));
00112
00114 #endif
00115
00116 protected:
00117 ExpNegativeImageFilter() {}
00118 virtual ~ExpNegativeImageFilter() {}
00119
00120 private:
00121 ExpNegativeImageFilter(const Self&);
00122 void operator=(const Self&);
00123
00124 };
00125
00126 }
00127
00128
00129 #endif
00130