ITK  6.0.0
Insight Toolkit
itkNumericTraitsRGBPixel.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 itkNumericTraitsRGBPixel_h
19#define itkNumericTraitsRGBPixel_h
20
21#include "itkNumericTraits.h"
22#include "itkRGBPixel.h"
23
24namespace itk
25{
42template <typename T>
44{
45private:
51
52public:
54 using ValueType = T;
55
57
60
63
67
70
73
76
79
85 static const Self
86 max(const Self &)
87 {
88 return MakeFilled<Self>(NumericTraits<T>::max());
89 }
90
91 static const Self
92 min(const Self &)
93 {
94 return MakeFilled<Self>(NumericTraits<T>::min());
95 }
96
97 static const Self
99 {
100 return MakeFilled<Self>(NumericTraits<T>::max());
101 }
102
103 static const Self
105 {
106 return MakeFilled<Self>(NumericTraits<T>::min());
107 }
108
109 static const Self
111 {
112 return MakeFilled<Self>(NumericTraits<T>::NonpositiveMin());
113 }
114
115 static const Self
117 {
118 return Self{};
119 }
120
121 static const Self
123 {
124 return MakeFilled<Self>(NumericTraits<T>::OneValue());
125 }
126
127 static const Self
129 {
130 return NonpositiveMin();
131 }
132
133 static const Self
135 {
136 return ZeroValue();
137 }
138
139 static const Self
140 OneValue(const Self &)
141 {
142 return OneValue();
143 }
144
146 static bool
148 {
150 }
151
153 static bool
155 {
157 }
158
160 static bool
162 {
164 }
165
167 static bool
169 {
171 }
172
173 static constexpr bool IsSigned = std::is_signed_v<ValueType>;
174 static constexpr bool IsInteger = std::is_integral_v<ValueType>;
176
180 static void
181 SetLength(RGBPixel<T> & m, const unsigned int s)
182 {
183 if (s != 3)
184 {
185 itkGenericExceptionMacro("Cannot set the size of a RGBPixel to anything other "
186 "than 3.");
187 }
188 m.Fill(T{});
189 }
193 static unsigned int
195 {
196 return 3;
197 }
198
200 static unsigned int
202 {
203 return 3;
204 }
205
206 static void
208 {
209 mv = v;
210 }
211
212 template <typename TArray>
213 static void
214 AssignToArray(const Self & v, TArray & mv)
215 {
216 for (unsigned int i = 0; i < 3; ++i)
217 {
218 mv[i] = v[i];
219 }
220 }
221
225 static const Self ITKCommon_EXPORT Zero;
226 static const Self ITKCommon_EXPORT One;
227};
228} // end namespace itk
229
230#endif // itkNumericTraitsRGBPixel_h
Pixel-wise addition of two images.
void Fill(const ValueType &)
static void AssignToArray(const Self &v, MeasurementVectorType &mv)
typename NumericTraits< T >::FloatType ElementFloatType
typename NumericTraits< T >::PrintType ElementPrintType
static const Self max(const Self &)
typename NumericTraits< T >::RealType ElementRealType
static void AssignToArray(const Self &v, TArray &mv)
typename NumericTraits< T >::AbsType ElementAbsType
static const Self ITKCommon_EXPORT Zero
static void SetLength(RGBPixel< T > &m, const unsigned int s)
static const Self ZeroValue(const Self &)
typename NumericTraits< T >::AccumulateType ElementAccumulateType
static const Self OneValue(const Self &)
static const Self min(const Self &)
static const Self ITKCommon_EXPORT One
static unsigned int GetLength(const RGBPixel< T > &)
static const Self NonpositiveMin(const Self &)
Define additional traits for native types such as int or float.
static constexpr bool IsInteger
static constexpr bool IsSigned
static bool IsNegative(T val)
static constexpr T NonpositiveMin()
static bool IsPositive(T val)
static bool IsNonpositive(T val)
static bool IsNonnegative(T val)
static constexpr bool IsComplex
Represent Red, Green and Blue components for color images.
Definition: itkRGBPixel.h:59
LuminanceType GetLuminance() const
AddImageFilter Self
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....