ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
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 __itkExpNegativeImageFilter_h 00019 #define __itkExpNegativeImageFilter_h 00020 00021 #include "itkUnaryFunctorImageFilter.h" 00022 #include "vnl/vnl_math.h" 00023 00024 namespace itk 00025 { 00026 namespace Functor 00027 { 00033 template< class TInput, class TOutput > 00034 class ExpNegative 00035 { 00036 public: 00037 ExpNegative() { m_Factor = 1.0; } 00038 ~ExpNegative() {} 00040 00041 bool operator!=(const ExpNegative & other) const 00042 { 00043 if ( m_Factor != other.m_Factor ) 00044 { 00045 return true; 00046 } 00047 return false; 00048 } 00049 00050 bool operator==(const ExpNegative & other) const 00051 { 00052 return !( *this != other ); 00053 } 00054 00055 inline TOutput operator()(const TInput & A) const 00056 { 00057 return static_cast< TOutput >( vcl_exp( -m_Factor * static_cast< double >( A ) ) ); 00058 } 00059 00061 void SetFactor(double factor) 00062 { 00063 m_Factor = factor; 00064 } 00065 00066 double GetFactor() const 00067 { 00068 return m_Factor; 00069 } 00070 00071 private: 00072 double m_Factor; 00073 }; 00074 } 00087 template< class TInputImage, class TOutputImage > 00088 class ITK_EXPORT ExpNegativeImageFilter: 00089 public 00090 UnaryFunctorImageFilter< TInputImage, TOutputImage, 00091 Functor::ExpNegative< 00092 typename TInputImage::PixelType, 00093 typename TOutputImage::PixelType > > 00094 { 00095 public: 00097 typedef ExpNegativeImageFilter Self; 00098 typedef UnaryFunctorImageFilter< 00099 TInputImage, TOutputImage, 00100 Functor::ExpNegative< typename TInputImage::PixelType, 00101 typename TOutputImage::PixelType > > Superclass; 00102 00103 typedef SmartPointer< Self > Pointer; 00104 typedef SmartPointer< const Self > ConstPointer; 00105 00107 itkNewMacro(Self); 00108 00110 itkTypeMacro(ExpNegativeImageFilter, 00111 UnaryFunctorImageFilter); 00112 00113 void SetFactor(double factor) 00114 { 00115 if ( factor == this->GetFunctor().GetFactor() ) 00116 { 00117 return; 00118 } 00119 this->GetFunctor().SetFactor(factor); 00120 this->Modified(); 00121 } 00122 00123 #ifdef ITK_USE_CONCEPT_CHECKING 00124 00125 itkConceptMacro( InputConvertibleToDoubleCheck, 00126 ( Concept::Convertible< typename TInputImage::PixelType, double > ) ); 00127 itkConceptMacro( DoubleConvertibleToOutputCheck, 00128 ( Concept::Convertible< double, typename TOutputImage::PixelType > ) ); 00129 00131 #endif 00132 protected: 00133 ExpNegativeImageFilter() {} 00134 virtual ~ExpNegativeImageFilter() {} 00135 private: 00136 ExpNegativeImageFilter(const Self &); //purposely not implemented 00137 void operator=(const Self &); //purposely not implemented 00138 }; 00139 } // end namespace itk 00141 00142 #endif 00143