ITK  5.2.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  * 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
41  operator()(const std::vector<TInput> & B) const
42  {
45 
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 
59  bool
60  operator!=(const Add1 &) const
61  {
62  return false;
63  }
64 };
65 } // namespace Functor
66 
101 template <typename TInputImage, typename TOutputImage>
103  : public NaryFunctorImageFilter<TInputImage,
104  TOutputImage,
105  Functor::Add1<typename TInputImage::PixelType, typename TInputImage::PixelType>>
106 {
107 public:
108  ITK_DISALLOW_COPY_AND_MOVE(NaryAddImageFilter);
109 
112  using Superclass =
113  NaryFunctorImageFilter<TInputImage,
114  TOutputImage,
116 
119 
121  itkNewMacro(Self);
122 
125 
126 #ifdef ITK_USE_CONCEPT_CHECKING
127  // Begin concept checking
128  itkConceptMacro(InputConvertibleToOutputCheck,
131  // End concept checking
132 #endif
133 
134 protected:
135  NaryAddImageFilter() = default;
136  ~NaryAddImageFilter() override = default;
137 };
138 } // end namespace itk
139 
140 #endif
itk::Concept::HasZero
Definition: itkConceptChecking.h:786
itk::Functor::Add1::operator!=
bool operator!=(const Add1 &) const
Definition: itkNaryAddImageFilter.h:60
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::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:102
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:64
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:138
itk::NaryAddImageFilter::~NaryAddImageFilter
~NaryAddImageFilter() override=default
itk::Concept::Convertible
Definition: itkConceptChecking.h:214
itkNumericTraits.h
itkNaryFunctorImageFilter.h
itk::Functor::Add1::~Add1
~Add1()=default