ITK
4.2.0
Insight Segmentation and Registration Toolkit
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
ITK
Modules
Core
Common
include
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
47
typedef
typename
NumericTraits< T >::AbsType
ElementAbsType
;
48
typedef
typename
NumericTraits< T >::AccumulateType
ElementAccumulateType
;
49
typedef
typename
NumericTraits< T >::FloatType
ElementFloatType
;
50
typedef
typename
NumericTraits< T >::PrintType
ElementPrintType
;
51
typedef
typename
NumericTraits< T >::RealType
ElementRealType
;
52
public
:
53
55
typedef
T
ValueType
;
56
57
typedef
RGBPixel< T >
Self
;
58
60
typedef
RGBPixel< ElementAbsType >
AbsType
;
61
63
typedef
RGBPixel< ElementAccumulateType >
AccumulateType
;
64
67
typedef
RGBPixel< ElementFloatType >
FloatType
;
68
70
typedef
RGBPixel< ElementPrintType >
PrintType
;
71
73
typedef
RGBPixel< ElementRealType >
RealType
;
74
76
typedef
ElementRealType
ScalarRealType
;
77
79
typedef
Self
MeasurementVectorType
;
80
86
static
const
Self
max
(
const
Self
&)
87
{
88
return
Self
(
NumericTraits< T >::max
() );
89
}
90
91
static
const
Self
min
(
const
Self
&)
92
{
93
return
Self
(
NumericTraits< T >::min
() );
94
}
95
96
static
const
Self
max
()
97
{
98
return
Self
(
NumericTraits< T >::max
() );
99
}
100
101
static
const
Self
min
()
102
{
103
return
Self
(
NumericTraits< T >::min
() );
104
}
105
106
static
const
Self
NonpositiveMin
()
107
{
108
return
Self
(
NumericTraits< ValueType >::NonpositiveMin
() );
109
}
110
111
static
const
Self
ZeroValue
()
112
{
113
return
Self
(
NumericTraits< T >::Zero
);
114
}
115
116
static
const
Self
OneValue
()
117
{
118
return
Self
(
NumericTraits< T >::One
);
119
}
120
121
static
const
Self
NonpositiveMin
(
const
Self
&)
122
{
123
return
NonpositiveMin
();
124
}
125
126
static
const
Self
ZeroValue
(
const
Self
&)
127
{
128
return
ZeroValue
();
129
}
130
131
static
const
Self
OneValue
(
const
Self
&)
132
{
133
return
OneValue
();
134
}
135
139
static
void
SetLength
(
RGBPixel< T >
& m,
const
unsigned
int
s)
140
{
141
if
( s != 3 )
142
{
143
itkGenericExceptionMacro(<<
"Cannot set the size of a RGBPixel to anything other "
144
"than 3."
);
145
}
146
m.
Fill
(
NumericTraits< T >::Zero
);
147
}
149
151
static
unsigned
int
GetLength
(
const
RGBPixel< T >
&)
152
{
153
return
3;
154
}
155
157
static
unsigned
int
GetLength
()
158
{
159
return
3;
160
}
161
162
static
void
AssignToArray
(
const
Self
& v,
MeasurementVectorType
& mv )
163
{
164
mv = v;
165
}
166
167
template
<
class
TArray>
168
static
void
AssignToArray
(
const
Self
& v, TArray & mv )
169
{
170
for
(
unsigned
int
i=0; i<3; i++ )
171
{
172
mv[i] = v[i];
173
}
174
}
175
179
static
const
Self
ITKCommon_EXPORT
Zero
;
180
static
const
Self
ITKCommon_EXPORT
One
;
181
};
182
}
// end namespace itk
183
184
#endif // __itkNumericTraitsRGBPixel_h
185
Generated on Tue Jul 10 2012 23:38:41 for ITK by
1.8.1