ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkNumericTraitsRGBPixel.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 itkNumericTraitsRGBPixel_h
19 #define itkNumericTraitsRGBPixel_h
20 
21 #include "itkNumericTraits.h"
22 #include "itkRGBPixel.h"
23 
24 namespace itk
25 {
42 template< typename T >
43 class NumericTraits< RGBPixel< T > >
44 {
45 private:
46 
52 
53 public:
54 
56  typedef T ValueType;
57 
59 
62 
65 
69 
72 
75 
78 
81 
87  static const Self max(const Self &)
88  {
89  return Self( NumericTraits< T >::max() );
90  }
91 
92  static const Self min(const Self &)
93  {
94  return Self( NumericTraits< T >::min() );
95  }
96 
97  static const Self max()
98  {
99  return Self( NumericTraits< T >::max() );
100  }
101 
102  static const Self min()
103  {
104  return Self( NumericTraits< T >::min() );
105  }
106 
107  static const Self NonpositiveMin()
108  {
110  }
111 
112  static const Self ZeroValue()
113  {
115  }
116 
117  static const Self OneValue()
118  {
120  }
121 
122  static const Self NonpositiveMin(const Self &)
123  {
124  return NonpositiveMin();
125  }
126 
127  static const Self ZeroValue(const Self &)
128  {
129  return ZeroValue();
130  }
131 
132  static const Self OneValue(const Self &)
133  {
134  return OneValue();
135  }
136 
137  static ITK_CONSTEXPR_VAR bool IsSigned = NumericTraits< ValueType >::IsSigned;
138  static ITK_CONSTEXPR_VAR bool IsInteger = NumericTraits< ValueType >::IsInteger;
139  static ITK_CONSTEXPR_VAR bool IsComplex = NumericTraits< ValueType >::IsComplex;
140 
144  static void SetLength(RGBPixel< T > & m, const unsigned int s)
145  {
146  if ( s != 3 )
147  {
148  itkGenericExceptionMacro(<< "Cannot set the size of a RGBPixel to anything other "
149  "than 3.");
150  }
152  }
154 
156  static unsigned int GetLength(const RGBPixel< T > &)
157  {
158  return 3;
159  }
160 
162  static unsigned int GetLength()
163  {
164  return 3;
165  }
166 
167  static void AssignToArray( const Self & v, MeasurementVectorType & mv )
168  {
169  mv = v;
170  }
171 
172  template<typename TArray>
173  static void AssignToArray( const Self & v, TArray & mv )
174  {
175  for( unsigned int i=0; i<3; i++ )
176  {
177  mv[i] = v[i];
178  }
179  }
180 
184  static const Self ITKCommon_EXPORT Zero;
185  static const Self ITKCommon_EXPORT One;
186 };
187 } // end namespace itk
188 
189 #endif // itkNumericTraitsRGBPixel_h
NumericTraits< T >::AbsType ElementAbsType
NumericTraits< T >::AccumulateType ElementAccumulateType
static ITK_CONSTEXPR_VAR bool IsComplex
static const Self ITKCommon_EXPORT One
static const Self OneValue(const Self &)
static void AssignToArray(const Self &v, TArray &mv)
static const Self ZeroValue(const Self &)
static ITK_CONSTEXPR_VAR bool IsInteger
RGBPixel< ElementAccumulateType > AccumulateType
void Fill(const ValueType &)
NumericTraits< T >::RealType ElementRealType
static void SetLength(RGBPixel< T > &m, const unsigned int s)
static const Self ITKCommon_EXPORT Zero
static const Self max(const Self &)
static const Self min(const Self &)
Represent Red, Green and Blue components for color images.
Definition: itkRGBPixel.h:58
static ITK_CONSTEXPR_FUNC T NonpositiveMin()
static void AssignToArray(const Self &v, MeasurementVectorType &mv)
static ITK_CONSTEXPR_VAR bool IsSigned
NumericTraits< T >::PrintType ElementPrintType
RGBPixel< ElementFloatType > FloatType
Define additional traits for native types such as int or float.
static const Self NonpositiveMin(const Self &)
RGBPixel< ElementPrintType > PrintType
static unsigned int GetLength(const RGBPixel< T > &)
NumericTraits< T >::FloatType ElementFloatType