ITK  5.4.0
Insight Toolkit
itkNaryAddImageFilter.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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
24namespace itk
25{
26namespace Functor
27{
33template <typename TInput, typename TOutput>
34class Add1
35{
36public:
38 inline TOutput
39 operator()(const std::vector<TInput> & B) const
40 {
41 AccumulatorType sum = TOutput{};
42
43 for (unsigned int i = 0; i < B.size(); ++i)
44 {
45 sum += static_cast<AccumulatorType>(B[i]);
46 }
47 return static_cast<TOutput>(sum);
48 }
49
50 bool
51 operator==(const Add1 &) const
52 {
53 return true;
54 }
55
57};
58} // namespace Functor
59
94template <typename TInputImage, typename TOutputImage>
96 : public NaryFunctorImageFilter<TInputImage,
97 TOutputImage,
98 Functor::Add1<typename TInputImage::PixelType, typename TInputImage::PixelType>>
99{
100public:
101 ITK_DISALLOW_COPY_AND_MOVE(NaryAddImageFilter);
102
106 NaryFunctorImageFilter<TInputImage,
107 TOutputImage,
109
112
114 itkNewMacro(Self);
115
117 itkOverrideGetNameOfClassMacro(NaryAddImageFilter);
118
119#ifdef ITK_USE_CONCEPT_CHECKING
120 // Begin concept checking
121 itkConceptMacro(InputConvertibleToOutputCheck,
124 // End concept checking
125#endif
126
127protected:
129 ~NaryAddImageFilter() override = default;
130};
131} // end namespace itk
132
133#endif
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Add1)
TOutput operator()(const std::vector< TInput > &B) const
bool operator==(const Add1 &) const
typename NumericTraits< TInput >::AccumulateType AccumulatorType
Base class for all process objects that output image data.
Pixel-wise addition of N images.
~NaryAddImageFilter() override=default
Perform a generic pixel-wise operation on N images.
Define additional traits for native types such as int or float.
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....