ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkExpNegativeImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkExpNegativeImageFilter_h
19 #define __itkExpNegativeImageFilter_h
20 
22 #include "vnl/vnl_math.h"
23 
24 namespace itk
25 {
26 namespace Functor
27 {
33 template< class TInput, class TOutput >
35 {
36 public:
37  ExpNegative() { m_Factor = 1.0; }
40 
41  bool operator!=(const ExpNegative & other) const
42  {
43  if ( m_Factor != other.m_Factor )
44  {
45  return true;
46  }
47  return false;
48  }
49 
50  bool operator==(const ExpNegative & other) const
51  {
52  return !( *this != other );
53  }
54 
55  inline TOutput operator()(const TInput & A) const
56  {
57  return static_cast< TOutput >( vcl_exp( -m_Factor * static_cast< double >( A ) ) );
58  }
59 
61  void SetFactor(double factor)
62  {
63  m_Factor = factor;
64  }
65 
66  double GetFactor() const
67  {
68  return m_Factor;
69  }
70 
71 private:
72  double m_Factor;
73 };
74 }
87 template< class TInputImage, class TOutputImage >
88 class ITK_EXPORT ExpNegativeImageFilter:
89  public
90  UnaryFunctorImageFilter< TInputImage, TOutputImage,
91  Functor::ExpNegative<
92  typename TInputImage::PixelType,
93  typename TOutputImage::PixelType > >
94 {
95 public:
99  TInputImage, TOutputImage,
100  Functor::ExpNegative< typename TInputImage::PixelType,
101  typename TOutputImage::PixelType > > Superclass;
102 
105 
107  itkNewMacro(Self);
108 
110  itkTypeMacro(ExpNegativeImageFilter,
112 
113  void SetFactor(double factor)
114  {
115  if ( factor == this->GetFunctor().GetFactor() )
116  {
117  return;
118  }
119  this->GetFunctor().SetFactor(factor);
120  this->Modified();
121  }
122  double GetFactor() const
123  {
124  return this->GetFunctor().GetFactor();
125  }
126 
127 #ifdef ITK_USE_CONCEPT_CHECKING
128 
129  itkConceptMacro( InputConvertibleToDoubleCheck,
131  itkConceptMacro( DoubleConvertibleToOutputCheck,
133 
135 #endif
136 
137 protected:
140 
141 private:
142  ExpNegativeImageFilter(const Self &); //purposely not implemented
143  void operator=(const Self &); //purposely not implemented
144 };
145 } // end namespace itk
146 
147 #endif
148