ITK  4.8.0
Insight Segmentation and Registration Toolkit
itkNaryAddImageFilter.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 itkNaryAddImageFilter_h
19 #define itkNaryAddImageFilter_h
20 
22 #include "itkNumericTraits.h"
23 
24 namespace itk
25 {
26 namespace Functor
27 {
33 template< typename TInput, typename TOutput >
34 class Add1
35 {
36 public:
38  Add1() {}
39  ~Add1() {}
40  inline TOutput operator()(const std::vector< TInput > & B) const
41  {
44 
45  for ( unsigned int i = 0; i < B.size(); i++ )
46  {
47  sum += static_cast< AccumulatorType >( B[i] );
48  }
49  return static_cast< TOutput >( sum );
50  }
51 
52  bool operator==(const Add1 &) const
53  {
54  return true;
55  }
56 
57  bool operator!=(const Add1 &) const
58  {
59  return false;
60  }
61 };
62 }
97 template< typename TInputImage, typename TOutputImage >
99  public
100  NaryFunctorImageFilter< TInputImage, TOutputImage,
101  Functor::Add1< typename TInputImage::PixelType, typename TInputImage::PixelType > >
102 {
103 public:
106  typedef NaryFunctorImageFilter<
107  TInputImage, TOutputImage,
108  Functor::Add1< typename TInputImage::PixelType,
109  typename TInputImage::PixelType > > Superclass;
110 
113 
115  itkNewMacro(Self);
116 
118  itkTypeMacro(NaryAddImageFilter,
120 
121 #ifdef ITK_USE_CONCEPT_CHECKING
122  // Begin concept checking
123  itkConceptMacro( InputConvertibleToOutputCheck,
124  ( Concept::Convertible< typename TInputImage::PixelType,
125  typename TOutputImage::PixelType > ) );
126  itkConceptMacro( InputHasZeroCheck,
128  // End concept checking
129 #endif
130 
131 protected:
133  virtual ~NaryAddImageFilter() {}
134 
135 private:
136  NaryAddImageFilter(const Self &); //purposely not implemented
137  void operator=(const Self &); //purposely not implemented
138 };
139 } // end namespace itk
140 
141 #endif
bool operator==(const Add1 &) const
NumericTraits< TInput >::AccumulateType AccumulatorType
Base class for all process objects that output image data.
SmartPointer< const Self > ConstPointer
NaryFunctorImageFilter< TInputImage, TOutputImage, Functor::Add1< typename TInputImage::PixelType, typename TInputImage::PixelType > > Superclass
Pixel-wise addition of N images.
Perform a generic pixel-wise operation on N images.
bool operator!=(const Add1 &) const
TOutput operator()(const std::vector< TInput > &B) const
SmartPointer< Self > Pointer
void operator=(const Self &)
Define additional traits for native types such as int or float.
#define itkConceptMacro(name, concept)