Orfeo Toolbox  3.16
itkWeightedAddImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkWeightedAddImageFilter.h,v $
5  Language: C++
6  Date: $Date: 2009-04-01 14:36:37 $
7  Version: $Revision: 1.7 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkWeightedAddImageFilter_h
18 #define __itkWeightedAddImageFilter_h
19 
21 #include "itkNumericTraits.h"
22 
23 
24 namespace itk
25 {
26 
54 namespace Functor {
55 
56 template< class TInput1, class TInput2, class TOutput >
58 {
59 public:
60  typedef typename NumericTraits< TInput1 >::AccumulateType AccumulatorType;
61  typedef typename NumericTraits< TInput1 >::RealType RealType;
64  bool operator!=( const WeightedAdd2 & other ) const
65  {
66  if( m_Alpha != other.m_Alpha)
67  {
68  return true;
69  }
70  return false;
71  }
72  bool operator==( const WeightedAdd2 & other ) const
73  {
74  return !(*this != other);
75  }
76 
77  inline TOutput operator()( const TInput1 & A, const TInput2 & B) const
78  {
79  const RealType sum1 = A * m_Alpha;
80  const RealType sum2 = B * m_Beta;
81  return static_cast<TOutput>( sum1 + sum2 );
82  }
83  void SetAlpha( RealType alpha )
84  {
85  m_Alpha = alpha;
86  m_Beta = NumericTraits< RealType >::One - m_Alpha;
87  }
89  {
90  return m_Alpha;
91  }
92 private:
94  RealType m_Beta; // auxiliary var to avoid a subtraction at every pixel
95 };
96 
97 }
98 template <class TInputImage1, class TInputImage2, class TOutputImage>
100  public
101 BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage,
102  Functor::WeightedAdd2<
103  typename TInputImage1::PixelType,
104  typename TInputImage2::PixelType,
105  typename TOutputImage::PixelType> >
106 
107 
108 {
109 public:
112  typedef BinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage,
114  typename TInputImage1::PixelType,
115  typename TInputImage2::PixelType,
116  typename TOutputImage::PixelType>
120 
122  typedef typename FunctorType::RealType RealType;
123 
125  itkNewMacro(Self);
126 
128  itkTypeMacro(WeightedAddImageFilter,
130 
132  void SetAlpha( RealType alpha )
133  {
134  this->GetFunctor().SetAlpha( alpha );
135  this->Modified();
136  }
137 
138 #ifdef ITK_USE_CONCEPT_CHECKING
139 
140  itkConceptMacro(Input1HasNumericTraitsCheck,
142  itkConceptMacro(Input1RealTypeMultiplyCheck,
143  (Concept::MultiplyOperator<typename TInputImage1::PixelType,
144  RealType, RealType>));
145  itkConceptMacro(Input2RealTypeMultiplyCheck,
146  (Concept::MultiplyOperator<typename TInputImage2::PixelType,
147  RealType, RealType>));
149 #endif
150 
151 protected:
154 
155 private:
156  WeightedAddImageFilter(const Self&); //purposely not implemented
157  void operator=(const Self&); //purposely not implemented
158 
159 };
160 
161 } // end namespace itk
162 
163 
164 #endif

Generated at Sun Feb 3 2013 00:14:59 for Orfeo Toolbox with doxygen 1.8.1.1