ITK  6.0.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  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 
94 template <typename TInputImage, typename TOutputImage>
96  : public NaryFunctorImageFilter<TInputImage,
97  TOutputImage,
98  Functor::Add1<typename TInputImage::PixelType, typename TInputImage::PixelType>>
99 {
100 public:
101  ITK_DISALLOW_COPY_AND_MOVE(NaryAddImageFilter);
102 
105  using Superclass =
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 
127 protected:
128  NaryAddImageFilter() = default;
129  ~NaryAddImageFilter() override = default;
130 };
131 } // end namespace itk
132 
133 #endif
itk::Concept::HasZero
Definition: itkConceptChecking.h:789
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::operator()
TOutput operator()(const std::vector< TInput > &B) const
Definition: itkNaryAddImageFilter.h:39
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:51
itk::NaryAddImageFilter
Pixel-wise addition of N images.
Definition: itkNaryAddImageFilter.h:95
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:60
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
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