ITK  5.4.0
Insight Toolkit
itkNumericTraitsArrayPixel.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 itkNumericTraitsArrayPixel_h
19#define itkNumericTraitsArrayPixel_h
20
21#include "itkNumericTraits.h"
22#include "itkArray.h"
23
24namespace itk
25{
29template <typename T>
31{
32private:
38
39public:
41 using ValueType = T;
42 using Self = Array<T>;
43
46
49
53
56
59
62
65
71 static const Self
72 max(const Self & a)
73 {
74 Self b(a.Size());
75
77 return b;
78 }
79
80 static const Self
81 min(const Self & a)
82 {
83 Self b(a.Size());
84
86 return b;
87 }
88
89 static const Self
90 ZeroValue(const Self & a)
91 {
92 Self b(a.Size());
93
94 b.Fill(T{});
95 return b;
96 }
97
98 static const Self
99 OneValue(const Self & a)
100 {
101 Self b(a.Size());
102
104 return b;
105 }
106
107 static const Self
109 {
110 Self b(a.Size());
112 return b;
113 }
114
115 static constexpr bool IsSigned = std::is_signed_v<ValueType>;
116 static constexpr bool IsInteger = std::is_integral_v<ValueType>;
118
120 static void
121 SetLength(Array<T> & m, const unsigned int s)
122 {
123 m.SetSize(s);
124 m.Fill(T{});
125 }
129 static size_t
131 {
132 return m.GetSize();
133 }
134
135 static void
137 {
138 mv = v;
139 }
140
141 template <typename TArray>
142 static void
143 AssignToArray(const Self & v, TArray & mv)
144 {
145 for (unsigned int i = 0; i < GetLength(v); ++i)
146 {
147 mv[i] = v[i];
148 }
149 }
150};
151} // end namespace itk
152
153#endif // itkNumericTraitsArrayPixel_h
Pixel-wise addition of two images.
Array class with size defined at construction time.
Definition: itkArray.h:48
SizeValueType Size() const
Definition: itkArray.h:128
SizeValueType GetSize() const
Definition: itkArray.h:158
void Fill(TValue const &v)
Definition: itkArray.h:114
void SetSize(SizeValueType sz)
typename NumericTraits< T >::RealType ElementRealType
static const Self NonpositiveMin(const Self &a)
typename NumericTraits< T >::AbsType ElementAbsType
static void SetLength(Array< T > &m, const unsigned int s)
static vcl_size_t GetLength(const Array< T > &m)
static const Self ZeroValue(const Self &a)
static void AssignToArray(const Self &v, MeasurementVectorType &mv)
typename NumericTraits< T >::PrintType ElementPrintType
static void AssignToArray(const Self &v, TArray &mv)
static const Self max(const Self &a)
typename NumericTraits< T >::FloatType ElementFloatType
static const Self min(const Self &a)
typename NumericTraits< T >::AccumulateType ElementAccumulateType
static const Self OneValue(const Self &a)
Define additional traits for native types such as int or float.
static constexpr bool IsInteger
static constexpr bool IsSigned
static unsigned int GetLength()
static constexpr bool IsComplex
AddImageFilter Self
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....