ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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 itkConceptMacro(InputConvertibleToOutputCheck,
122
123protected:
125 ~NaryAddImageFilter() override = default;
126};
127} // end namespace itk
128
129#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
NaryFunctorImageFilter< TInputImage, TOutputImage, Functor::Add1< typename TInputImage::PixelType, typename TInputImage::PixelType > > Superclass
SmartPointer< const Self > ConstPointer
~NaryAddImageFilter() override=default
Implements transparent reference counting.
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....