ITK  4.12.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< typename TInput1, typename TInput2 = TInput1, typename TOutput = TInput1 >
34 class ITK_TEMPLATE_EXPORT Add2
35 {
36 public:
37  Add2() {}
38  ~Add2() {}
39  bool operator!=(const Add2 &) const
40  {
41  return false;
42  }
44 
45  bool operator==(const Add2 & other) const
46  {
47  return !( *this != other );
48  }
49 
50  inline TOutput operator()(const TInput1 & A, const TInput2 & B) const
51  {
52  return static_cast< TOutput >( A + B );
53  }
54 };
55 }
106 template< typename TInputImage1, typename TInputImage2 = TInputImage1, typename TOutputImage = TInputImage1 >
107 class ITK_TEMPLATE_EXPORT AddImageFilter:
108  public
109  BinaryFunctorImageFilter< TInputImage1, TInputImage2, TOutputImage,
110  Functor::Add2<
111  typename TInputImage1::PixelType,
112  typename TInputImage2::PixelType,
113  typename TOutputImage::PixelType > >
114 
115 {
116 public:
119  typedef BinaryFunctorImageFilter< TInputImage1, TInputImage2, TOutputImage,
121  typename TInputImage1::PixelType,
122  typename TInputImage2::PixelType,
123  typename TOutputImage::PixelType > > Superclass;
124 
127 
129  itkNewMacro(Self);
130 
132  itkTypeMacro(AddImageFilter,
134 
135 #ifdef ITK_USE_CONCEPT_CHECKING
136  // Begin concept checking
137  itkConceptMacro( Input1Input2OutputAdditiveOperatorsCheck,
138  ( Concept::AdditiveOperators< typename TInputImage1::PixelType,
139  typename TInputImage2::PixelType,
140  typename TOutputImage::PixelType > ) );
141  // End concept checking
142 #endif
143 
144 protected:
146  virtual ~AddImageFilter() {}
147 
148 private:
149  ITK_DISALLOW_COPY_AND_ASSIGN(AddImageFilter);
150 };
151 } // end namespace itk
152 
153 #endif
Pixel-wise addition of two images.
SmartPointer< const Self > ConstPointer
bool operator==(const Add2 &other) const
Base class for all process objects that output image data.
BinaryFunctorImageFilter< TInputImage1, TInputImage2, TOutputImage, Functor::Add2< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType > > Superclass
SmartPointer< Self > Pointer
TOutput operator()(const TInput1 &A, const TInput2 &B) const
bool operator!=(const Add2 &) const
#define itkConceptMacro(name, concept)
Implements pixel-wise generic operation of two images, or of an image and a constant.