ITK  5.4.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 
24 namespace itk
25 {
42 template <typename T>
44 {
45 private:
51 
52 public:
54  using ValueType = T;
55 
56  using Self = RGBPixel<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(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
itk::NumericTraits< RGBPixel< T > >::ElementRealType
typename NumericTraits< T >::RealType ElementRealType
Definition: itkNumericTraitsRGBPixel.h:50
itk::NumericTraits< RGBPixel< T > >::max
static const Self max(const Self &)
Definition: itkNumericTraitsRGBPixel.h:86
itk::RGBPixel
Represent Red, Green and Blue components for color images.
Definition: itkRGBPixel.h:58
itk::NumericTraits::IsPositive
static bool IsPositive(T val)
Definition: itkNumericTraits.h:105
itkRGBPixel.h
itk::NumericTraits< RGBPixel< T > >::ZeroValue
static const Self ZeroValue(const Self &)
Definition: itkNumericTraitsRGBPixel.h:134
Self
AddImageFilter Self
Definition: itkAddImageFilter.h:89
itk::NumericTraits::NonpositiveMin
static constexpr T NonpositiveMin()
Definition: itkNumericTraits.h:98
itk::NumericTraits::AccumulateType
double AccumulateType
Definition: itkNumericTraits.h:75
itk::NumericTraits< RGBPixel< T > >::min
static const Self min(const Self &)
Definition: itkNumericTraitsRGBPixel.h:92
itk::NumericTraits< RGBPixel< T > >::NonpositiveMin
static const Self NonpositiveMin(const Self &)
Definition: itkNumericTraitsRGBPixel.h:128
itk::NumericTraits< RGBPixel< T > >::ElementPrintType
typename NumericTraits< T >::PrintType ElementPrintType
Definition: itkNumericTraitsRGBPixel.h:49
itk::NumericTraits< RGBPixel< T > >::ElementAbsType
typename NumericTraits< T >::AbsType ElementAbsType
Definition: itkNumericTraitsRGBPixel.h:46
itk::NumericTraits< RGBPixel< T > >::Zero
static const Self ITKCommon_EXPORT Zero
Definition: itkNumericTraitsRGBPixel.h:225
itk::NumericTraits< RGBPixel< T > >::IsNonnegative
static bool IsNonnegative(Self val)
Definition: itkNumericTraitsRGBPixel.h:168
itk::NumericTraits::IsSigned
static constexpr bool IsSigned
Definition: itkNumericTraits.h:134
itk::NumericTraits< RGBPixel< T > >::NonpositiveMin
static const Self NonpositiveMin()
Definition: itkNumericTraitsRGBPixel.h:110
itk::NumericTraits< RGBPixel< T > >::max
static const Self max()
Definition: itkNumericTraitsRGBPixel.h:98
itk::NumericTraits::IsInteger
static constexpr bool IsInteger
Definition: itkNumericTraits.h:139
itk::NumericTraits::OneValue
static T OneValue()
Definition: itkNumericTraits.h:157
itk::NumericTraits< RGBPixel< T > >::GetLength
static unsigned int GetLength(const RGBPixel< T > &)
Definition: itkNumericTraitsRGBPixel.h:194
itk::NumericTraits::PrintType
T PrintType
Definition: itkNumericTraits.h:69
itk::NumericTraits< RGBPixel< T > >::One
static const Self ITKCommon_EXPORT One
Definition: itkNumericTraitsRGBPixel.h:226
itk::NumericTraits< RGBPixel< T > >::OneValue
static const Self OneValue(const Self &)
Definition: itkNumericTraitsRGBPixel.h:140
itk::RGBPixel::GetLuminance
LuminanceType GetLuminance() const
itk::NumericTraits< RGBPixel< T > >::IsNonpositive
static bool IsNonpositive(Self val)
Definition: itkNumericTraitsRGBPixel.h:154
itk::NumericTraits< RGBPixel< T > >::ValueType
T ValueType
Definition: itkNumericTraitsRGBPixel.h:54
itk::NumericTraits< RGBPixel< T > >::SetLength
static void SetLength(RGBPixel< T > &m, const unsigned int s)
Definition: itkNumericTraitsRGBPixel.h:181
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:59
itk::NumericTraits< RGBPixel< T > >::AssignToArray
static void AssignToArray(const Self &v, MeasurementVectorType &mv)
Definition: itkNumericTraitsRGBPixel.h:207
itk::NumericTraits::ZeroValue
static T ZeroValue()
Definition: itkNumericTraits.h:149
itk::NumericTraits< RGBPixel< T > >::GetLength
static unsigned int GetLength()
Definition: itkNumericTraitsRGBPixel.h:201
itk::NumericTraits< RGBPixel< T > >::ElementFloatType
typename NumericTraits< T >::FloatType ElementFloatType
Definition: itkNumericTraitsRGBPixel.h:48
itk::NumericTraits::IsNonnegative
static bool IsNonnegative(T val)
Definition: itkNumericTraits.h:126
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::NumericTraits::IsComplex
static constexpr bool IsComplex
Definition: itkNumericTraits.h:144
itk::NumericTraits< RGBPixel< T > >::ScalarRealType
ElementRealType ScalarRealType
Definition: itkNumericTraitsRGBPixel.h:75
itk::NumericTraits< RGBPixel< T > >::ElementAccumulateType
typename NumericTraits< T >::AccumulateType ElementAccumulateType
Definition: itkNumericTraitsRGBPixel.h:47
itk::NumericTraits::IsNonpositive
static bool IsNonpositive(T val)
Definition: itkNumericTraits.h:112
itkNumericTraits.h
itk::NumericTraits< RGBPixel< T > >::AssignToArray
static void AssignToArray(const Self &v, TArray &mv)
Definition: itkNumericTraitsRGBPixel.h:214
itk::NumericTraits< RGBPixel< T > >::OneValue
static const Self OneValue()
Definition: itkNumericTraitsRGBPixel.h:122
itk::NumericTraits::RealType
double RealType
Definition: itkNumericTraits.h:85
AddImageFilter
Definition: itkAddImageFilter.h:81
itk::NumericTraits::FloatType
float FloatType
Definition: itkNumericTraits.h:82
itk::NumericTraits< RGBPixel< T > >::ZeroValue
static const Self ZeroValue()
Definition: itkNumericTraitsRGBPixel.h:116
itk::NumericTraits< RGBPixel< T > >::IsNegative
static bool IsNegative(Self val)
Definition: itkNumericTraitsRGBPixel.h:161
itk::NumericTraits< RGBPixel< T > >::min
static const Self min()
Definition: itkNumericTraitsRGBPixel.h:104
itk::NumericTraits::AbsType
T AbsType
Definition: itkNumericTraits.h:72
itk::NumericTraits::IsNegative
static bool IsNegative(T val)
Definition: itkNumericTraits.h:119
itk::FixedArray< TComponent, 3 >::Fill
void Fill(const ValueType &)
itk::NumericTraits< RGBPixel< T > >::IsPositive
static bool IsPositive(Self val)
Definition: itkNumericTraitsRGBPixel.h:147