ITK  5.0.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() = default;
39  ~Add1() = default;
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 }
63 
98 template< typename TInputImage, typename TOutputImage >
100  public
101  NaryFunctorImageFilter< TInputImage, TOutputImage,
102  Functor::Add1< typename TInputImage::PixelType, typename TInputImage::PixelType > >
103 {
104 public:
105  ITK_DISALLOW_COPY_AND_ASSIGN(NaryAddImageFilter);
106 
110  TInputImage, TOutputImage,
111  Functor::Add1< typename TInputImage::PixelType,
112  typename TInputImage::PixelType > >;
113 
116 
118  itkNewMacro(Self);
119 
121  itkTypeMacro(NaryAddImageFilter,
123 
124 #ifdef ITK_USE_CONCEPT_CHECKING
125  // Begin concept checking
126  itkConceptMacro( InputConvertibleToOutputCheck,
127  ( Concept::Convertible< typename TInputImage::PixelType,
128  typename TOutputImage::PixelType > ) );
129  itkConceptMacro( InputHasZeroCheck,
131  // End concept checking
132 #endif
133 
134 protected:
135  NaryAddImageFilter() = default;
136  ~NaryAddImageFilter() override = default;
137 };
138 } // end namespace itk
139 
140 #endif
bool operator==(const Add1 &) const
Define numeric traits for std::vector.
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
typename NumericTraits< TInputImage::PixelType >::AccumulateType AccumulatorType
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
~NaryAddImageFilter() override=default
#define itkConceptMacro(name, concept)