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 {
00064 m_Factor = factor;
00065 }
00066 double GetFactor() const
00067 {
00068 return m_Factor;
00069 }
00070 private:
00071 double m_Factor;
00072 };
00073 }
00074 template <class TInputImage, class TOutputImage>
00075 class ITK_EXPORT ExpNegativeImageFilter :
00076 public
00077 UnaryFunctorImageFilter<TInputImage,TOutputImage,
00078 Function::ExpNegative<
00079 typename TInputImage::PixelType,
00080 typename TOutputImage::PixelType> >
00081 {
00082 public:
00084 typedef ExpNegativeImageFilter Self;
00085 typedef UnaryFunctorImageFilter<
00086 TInputImage,TOutputImage,
00087 Function::ExpNegative< typename TInputImage::PixelType,
00088 typename TOutputImage::PixelType> > Superclass;
00089 typedef SmartPointer<Self> Pointer;
00090 typedef SmartPointer<const Self> ConstPointer;
00091
00093 itkNewMacro(Self);
00094
00096 itkTypeMacro(ExpNegativeImageFilter,
00097 UnaryFunctorImageFilter);
00098
00099 void SetFactor( double factor )
00100 {
00101 if( factor == this->GetFunctor().GetFactor() )
00102 {
00103 return;
00104 }
00105 this->GetFunctor().SetFactor( factor );
00106 this->Modified();
00107 }
00108
00109 #ifdef ITK_USE_CONCEPT_CHECKING
00110
00111 itkConceptMacro(InputConvertibleToDoubleCheck,
00112 (Concept::Convertible<typename TInputImage::PixelType, double>));
00113 itkConceptMacro(DoubleConvertibleToOutputCheck,
00114 (Concept::Convertible<double, typename TOutputImage::PixelType>));
00115
00117 #endif
00118
00119 protected:
00120 ExpNegativeImageFilter() {}
00121 virtual ~ExpNegativeImageFilter() {}
00122
00123 private:
00124 ExpNegativeImageFilter(const Self&);
00125 void operator=(const Self&);
00126
00127 };
00128
00129 }
00130
00131
00132 #endif
00133