Orfeo Toolbox  4.0
itkWeightedAddImageFilter.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 __itkWeightedAddImageFilter_h
19 #define __itkWeightedAddImageFilter_h
20 
22 #include "itkNumericTraits.h"
23 
24 namespace itk
25 {
26 namespace Functor
27 {
33 template< typename TInput1, typename TInput2, typename TOutput >
35 {
36 public:
41  bool operator!=(const WeightedAdd2 & other) const
42  {
43  if ( m_Alpha != other.m_Alpha )
44  {
45  return true;
46  }
47  return false;
48  }
49 
50  bool operator==(const WeightedAdd2 & other) const
51  {
52  return !( *this != other );
53  }
54 
55  inline TOutput operator()(const TInput1 & A, const TInput2 & B) const
56  {
57  const RealType sum1 = A * m_Alpha;
58  const RealType sum2 = B * m_Beta;
59 
60  return static_cast< TOutput >( sum1 + sum2 );
61  }
62 
63  void SetAlpha(RealType alpha)
64  {
65  m_Alpha = alpha;
67  }
68 
70  {
71  return m_Alpha;
72  }
73 
74 private:
76  RealType m_Beta; // auxiliary var to avoid a subtraction at every pixel
77 };
78 }
112 template< typename TInputImage1, typename TInputImage2, typename TOutputImage >
114  public
115  BinaryFunctorImageFilter< TInputImage1, TInputImage2, TOutputImage,
116  Functor::WeightedAdd2<
117  typename TInputImage1::PixelType,
118  typename TInputImage2::PixelType,
119  typename TOutputImage::PixelType > >
120 
121 {
122 public:
125  typedef BinaryFunctorImageFilter< TInputImage1, TInputImage2, TOutputImage,
127  typename TInputImage1::PixelType,
128  typename TInputImage2::PixelType,
129  typename TOutputImage::PixelType >
131 
134 
136  typedef typename FunctorType::RealType RealType;
137 
139  itkNewMacro(Self);
140 
142  itkTypeMacro(WeightedAddImageFilter,
144 
146  void SetAlpha(RealType alpha)
147  {
148  this->GetFunctor().SetAlpha(alpha);
149  this->Modified();
150  }
151 
154  {
155  return this->GetFunctor().GetAlpha();
156  }
157 
158 #ifdef ITK_USE_CONCEPT_CHECKING
159  // Begin concept checking
160  itkConceptMacro( Input1HasNumericTraitsCheck,
162  itkConceptMacro( Input1RealTypeMultiplyCheck,
163  ( Concept::MultiplyOperator< typename TInputImage1::PixelType,
164  RealType, RealType > ) );
165  itkConceptMacro( Input2RealTypeMultiplyCheck,
166  ( Concept::MultiplyOperator< typename TInputImage2::PixelType,
167  RealType, RealType > ) );
168  // End concept checking
169 #endif
170 
171 protected:
174 
175 private:
176  WeightedAddImageFilter(const Self &); //purposely not implemented
177  void operator=(const Self &); //purposely not implemented
178 };
179 } // end namespace itk
180 
181 #endif

Generated at Sat Mar 8 2014 15:47:07 for Orfeo Toolbox with doxygen 1.8.3.1