ITK  5.3.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 
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
41  operator()(const std::vector<TInput> & B) const
42  {
46  for (unsigned int i = 0; i < B.size(); ++i)
47  {
48  sum += static_cast<AccumulatorType>(B[i]);
49  }
50  return static_cast<TOutput>(sum);
51  }
52 
53  bool
54  operator==(const Add1 &) const
55  {
56  return true;
57  }
58 
60 };
61 } // namespace Functor
62 
97 template <typename TInputImage, typename TOutputImage>
99  : public NaryFunctorImageFilter<TInputImage,
100  TOutputImage,
101  Functor::Add1<typename TInputImage::PixelType, typename TInputImage::PixelType>>
102 {
103 public:
104  ITK_DISALLOW_COPY_AND_MOVE(NaryAddImageFilter);
105 
108  using Superclass =
109  NaryFunctorImageFilter<TInputImage,
110  TOutputImage,
112 
115 
117  itkNewMacro(Self);
118 
121 
122 #ifdef ITK_USE_CONCEPT_CHECKING
123  // Begin concept checking
124  itkConceptMacro(InputConvertibleToOutputCheck,
127  // End concept checking
128 #endif
129 
130 protected:
131  NaryAddImageFilter() = default;
132  ~NaryAddImageFilter() override = default;
133 };
134 } // end namespace itk
135 
136 #endif
itk::Concept::HasZero
Definition: itkConceptChecking.h:787
itk::NaryFunctorImageFilter
Perform a generic pixel-wise operation on N images.
Definition: itkNaryFunctorImageFilter.h:42
itk::Functor::Add1
Definition: itkNaryAddImageFilter.h:34
itk::Functor::Add1< TInputImage::PixelType, TInputImage::PixelType >::AccumulatorType
typename NumericTraits< TInputImage::PixelType >::AccumulateType AccumulatorType
Definition: itkNaryAddImageFilter.h:37
itk::SmartPointer< Self >
itk::Functor::Add1::Add1
Add1()=default
itk::Functor::Add1::operator()
TOutput operator()(const std::vector< TInput > &B) const
Definition: itkNaryAddImageFilter.h:41
itk::NaryAddImageFilter::NaryAddImageFilter
NaryAddImageFilter()=default
itk::Functor::Add1::ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Add1)
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::Functor::Add1::operator==
bool operator==(const Add1 &) const
Definition: itkNaryAddImageFilter.h:54
itk::NaryAddImageFilter
Pixel-wise addition of N images.
Definition: itkNaryAddImageFilter.h:98
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:58
itk::NumericTraits::ZeroValue
static T ZeroValue()
Definition: itkNumericTraits.h:148
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::NaryAddImageFilter::~NaryAddImageFilter
~NaryAddImageFilter() override=default
itk::Concept::Convertible
Definition: itkConceptChecking.h:216
itkNumericTraits.h
itkNaryFunctorImageFilter.h
itk::Functor::Add1::~Add1
~Add1()=default