ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkAddImageFilter.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 __itkAddImageFilter_h
19 #define __itkAddImageFilter_h
20 
22 #include "itkNumericTraits.h"
23 
24 namespace itk
25 {
26 namespace Functor
27 {
33 template< class TInput1, class TInput2 = TInput1, class TOutput = TInput1 >
34 class Add2
35 {
36 public:
38  Add2() {}
39  ~Add2() {}
40  bool operator!=(const Add2 &) const
41  {
42  return false;
43  }
45 
46  bool operator==(const Add2 & other) const
47  {
48  return !( *this != other );
49  }
50 
51  inline TOutput operator()(const TInput1 & A, const TInput2 & B) const
52  {
53  const AccumulatorType sum = A;
54 
55  return static_cast< TOutput >( sum + B );
56  }
57 };
58 }
109 template< class TInputImage1, class TInputImage2 = TInputImage1, class TOutputImage = TInputImage1 >
110 class ITK_EXPORT AddImageFilter:
111  public
112  BinaryFunctorImageFilter< TInputImage1, TInputImage2, TOutputImage,
113  Functor::Add2<
114  typename TInputImage1::PixelType,
115  typename TInputImage2::PixelType,
116  typename TOutputImage::PixelType > >
117 
118 {
119 public:
122  typedef BinaryFunctorImageFilter< TInputImage1, TInputImage2, TOutputImage,
124  typename TInputImage1::PixelType,
125  typename TInputImage2::PixelType,
126  typename TOutputImage::PixelType > > Superclass;
127 
130 
132  itkNewMacro(Self);
133 
135  itkTypeMacro(AddImageFilter,
137 
138 #ifdef ITK_USE_CONCEPT_CHECKING
139 
140  itkConceptMacro( Input1Input2OutputAdditiveOperatorsCheck,
141  ( Concept::AdditiveOperators< typename TInputImage1::PixelType,
142  typename TInputImage2::PixelType,
143  typename TOutputImage::PixelType > ) );
144 
146 #endif
147 protected:
149  virtual ~AddImageFilter() {}
150 private:
151  AddImageFilter(const Self &); //purposely not implemented
152  void operator=(const Self &); //purposely not implemented
153 };
154 } // end namespace itk
156 
157 #endif
158