ITK  6.0.0
Insight Toolkit
itkNumericTraitsRGBAPixel.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 itkNumericTraitsRGBAPixel_h
19 #define itkNumericTraitsRGBAPixel_h
20 
21 #include "itkNumericTraits.h"
22 #include "itkRGBAPixel.h"
23 
24 namespace itk
25 {
42 template <typename T>
44 {
45 private:
51 
52 public:
54  using ValueType = T;
55 
56  using Self = RGBAPixel<T>;
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
98  max()
99  {
100  return MakeFilled<Self>(NumericTraits<T>::max());
101  }
102 
103  static const Self
104  min()
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
134  ZeroValue(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(RGBAPixel<T> & m, const unsigned int s)
182  {
183  if (s != 4)
184  {
185  itkGenericExceptionMacro("Cannot set the size of a RGBAPixel to anything other "
186  "than 4.");
187  }
188  m.Fill(T{});
189  }
193  static unsigned int
195  {
196  return 4;
197  }
198 
200  static unsigned int
202  {
203  return 4;
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 < 4; ++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 // itkNumericTraitsRGBAPixel_h
itk::NumericTraits< RGBAPixel< T > >::NonpositiveMin
static const Self NonpositiveMin(const Self &)
Definition: itkNumericTraitsRGBAPixel.h:128
itk::NumericTraits< RGBAPixel< T > >::AssignToArray
static void AssignToArray(const Self &v, TArray &mv)
Definition: itkNumericTraitsRGBAPixel.h:214
itk::NumericTraits< RGBAPixel< T > >::GetLength
static unsigned int GetLength(const RGBAPixel< T > &)
Definition: itkNumericTraitsRGBAPixel.h:194
itk::NumericTraits< RGBAPixel< T > >::ZeroValue
static const Self ZeroValue()
Definition: itkNumericTraitsRGBAPixel.h:116
itk::NumericTraits::IsPositive
static bool IsPositive(T val)
Definition: itkNumericTraits.h:106
Self
AddImageFilter Self
Definition: itkAddImageFilter.h:89
itk::NumericTraits::NonpositiveMin
static constexpr T NonpositiveMin()
Definition: itkNumericTraits.h:99
itk::NumericTraits< RGBAPixel< T > >::ValueType
T ValueType
Definition: itkNumericTraitsRGBAPixel.h:54
itk::NumericTraits::AccumulateType
double AccumulateType
Definition: itkNumericTraits.h:76
itk::NumericTraits< RGBAPixel< T > >::IsNonpositive
static bool IsNonpositive(Self val)
Definition: itkNumericTraitsRGBAPixel.h:154
itkRGBAPixel.h
itk::NumericTraits< RGBAPixel< T > >::ElementPrintType
typename NumericTraits< T >::PrintType ElementPrintType
Definition: itkNumericTraitsRGBAPixel.h:49
itk::NumericTraits< RGBAPixel< T > >::ElementAbsType
typename NumericTraits< T >::AbsType ElementAbsType
Definition: itkNumericTraitsRGBAPixel.h:46
itk::NumericTraits< RGBAPixel< T > >::IsNegative
static bool IsNegative(Self val)
Definition: itkNumericTraitsRGBAPixel.h:161
itk::NumericTraits< RGBAPixel< T > >::One
static const Self ITKCommon_EXPORT One
Definition: itkNumericTraitsRGBAPixel.h:226
itk::NumericTraits< RGBAPixel< T > >::IsPositive
static bool IsPositive(Self val)
Definition: itkNumericTraitsRGBAPixel.h:147
itk::NumericTraits::IsSigned
static constexpr bool IsSigned
Definition: itkNumericTraits.h:135
itk::NumericTraits< RGBAPixel< T > >::OneValue
static const Self OneValue()
Definition: itkNumericTraitsRGBAPixel.h:122
itk::NumericTraits< RGBAPixel< T > >::AssignToArray
static void AssignToArray(const Self &v, MeasurementVectorType &mv)
Definition: itkNumericTraitsRGBAPixel.h:207
itk::NumericTraits::IsInteger
static constexpr bool IsInteger
Definition: itkNumericTraits.h:140
itk::NumericTraits::OneValue
static T OneValue()
Definition: itkNumericTraits.h:158
itk::NumericTraits::PrintType
T PrintType
Definition: itkNumericTraits.h:70
itk::NumericTraits< RGBAPixel< T > >::ElementRealType
typename NumericTraits< T >::RealType ElementRealType
Definition: itkNumericTraitsRGBAPixel.h:50
itk::NumericTraits< RGBAPixel< T > >::SetLength
static void SetLength(RGBAPixel< T > &m, const unsigned int s)
Definition: itkNumericTraitsRGBAPixel.h:181
itk::NumericTraits< RGBAPixel< T > >::ElementAccumulateType
typename NumericTraits< T >::AccumulateType ElementAccumulateType
Definition: itkNumericTraitsRGBAPixel.h:47
itk::NumericTraits< RGBAPixel< T > >::ZeroValue
static const Self ZeroValue(const Self &)
Definition: itkNumericTraitsRGBAPixel.h:134
itk::NumericTraits< RGBAPixel< T > >::OneValue
static const Self OneValue(const Self &)
Definition: itkNumericTraitsRGBAPixel.h:140
itk::NumericTraits< RGBAPixel< T > >::ElementFloatType
typename NumericTraits< T >::FloatType ElementFloatType
Definition: itkNumericTraitsRGBAPixel.h:48
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:60
itk::NumericTraits< RGBAPixel< T > >::Zero
static const Self ITKCommon_EXPORT Zero
Definition: itkNumericTraitsRGBAPixel.h:225
itk::RGBAPixel::GetLuminance
LuminanceType GetLuminance() const
itk::NumericTraits< RGBAPixel< T > >::min
static const Self min()
Definition: itkNumericTraitsRGBAPixel.h:104
itk::NumericTraits::ZeroValue
static T ZeroValue()
Definition: itkNumericTraits.h:150
itk::RGBAPixel
Represent Red, Green, Blue and Alpha components for color images.
Definition: itkRGBAPixel.h:59
itk::NumericTraits::IsNonnegative
static bool IsNonnegative(T val)
Definition: itkNumericTraits.h:127
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::NumericTraits::IsComplex
static constexpr bool IsComplex
Definition: itkNumericTraits.h:145
itk::NumericTraits::IsNonpositive
static bool IsNonpositive(T val)
Definition: itkNumericTraits.h:113
itk::NumericTraits< RGBAPixel< T > >::NonpositiveMin
static const Self NonpositiveMin()
Definition: itkNumericTraitsRGBAPixel.h:110
itk::NumericTraits< RGBAPixel< T > >::IsNonnegative
static bool IsNonnegative(Self val)
Definition: itkNumericTraitsRGBAPixel.h:168
itkNumericTraits.h
itk::NumericTraits::RealType
double RealType
Definition: itkNumericTraits.h:86
itk::NumericTraits< RGBAPixel< T > >::max
static const Self max(const Self &)
Definition: itkNumericTraitsRGBAPixel.h:86
AddImageFilter
Definition: itkAddImageFilter.h:81
itk::NumericTraits::FloatType
float FloatType
Definition: itkNumericTraits.h:83
itk::NumericTraits< RGBAPixel< T > >::ScalarRealType
ElementRealType ScalarRealType
Definition: itkNumericTraitsRGBAPixel.h:75
itk::NumericTraits< RGBAPixel< T > >::GetLength
static unsigned int GetLength()
Definition: itkNumericTraitsRGBAPixel.h:201
itk::NumericTraits< RGBAPixel< T > >::min
static const Self min(const Self &)
Definition: itkNumericTraitsRGBAPixel.h:92
itk::NumericTraits::AbsType
T AbsType
Definition: itkNumericTraits.h:73
itk::NumericTraits::IsNegative
static bool IsNegative(T val)
Definition: itkNumericTraits.h:120
itk::NumericTraits< RGBAPixel< T > >::max
static const Self max()
Definition: itkNumericTraitsRGBAPixel.h:98
itk::FixedArray< TComponent, 4 >::Fill
void Fill(const ValueType &)