ITK  4.6.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 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< typename TInputImage1, typename TInputImage2 = TInputImage1, typename TOutputImage = TInputImage1 >
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  // Begin concept checking
140  itkConceptMacro( Input1Input2OutputAdditiveOperatorsCheck,
141  ( Concept::AdditiveOperators< typename TInputImage1::PixelType,
142  typename TInputImage2::PixelType,
143  typename TOutputImage::PixelType > ) );
144  // End concept checking
145 #endif
146 
147 protected:
149  virtual ~AddImageFilter() {}
150 
151 private:
152  AddImageFilter(const Self &); //purposely not implemented
153  void operator=(const Self &); //purposely not implemented
154 };
155 } // end namespace itk
156 
157 #endif
Pixel-wise addition of two images.
SmartPointer< const Self > ConstPointer
bool operator==(const Add2 &other) const
NumericTraits< TInput1 >::AccumulateType AccumulatorType
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
void operator=(const Self &)
bool operator!=(const Add2 &) const
Define additional traits for native types such as int or float.
#define itkConceptMacro(name, concept)
Implements pixel-wise generic operation of two images, or of an image and a constant.