Compute Library
 20.02.1
PixelValue Class Reference

Class describing the value of a pixel for any image format. More...

#include <PixelValue.h>

Public Member Functions

 PixelValue ()
 Default constructor: value initialized to 0. More...
 
 PixelValue (int64_t v, DataType datatype, QuantizationInfo qinfo=QuantizationInfo())
 Initialize the union with a pixel value of chosen datatype. More...
 
 PixelValue (int8_t v)
 Initialize the union with a S8 pixel value. More...
 
 PixelValue (uint8_t v)
 Initialize the union with a U8 pixel value. More...
 
 PixelValue (uint16_t v)
 Initialize the union with a U16 pixel value. More...
 
 PixelValue (int16_t v)
 Initialize the union with a S16 pixel value. More...
 
 PixelValue (uint32_t v)
 Initialize the union with a U32 pixel value. More...
 
 PixelValue (int32_t v)
 Initialize the union with a S32 pixel value. More...
 
 PixelValue (uint64_t v)
 Initialize the union with a U64 pixel value. More...
 
 PixelValue (int64_t v)
 Initialize the union with a S64 pixel value. More...
 
 PixelValue (half v)
 Initialize the union with a F16 pixel value. More...
 
 PixelValue (float v)
 Initialize the union with a F32 pixel value. More...
 
 PixelValue (double v)
 Initialize the union with a F64 pixel value. More...
 
void get (uint8_t &v) const
 Interpret the pixel value as a U8. More...
 
void get (int8_t &v) const
 Interpret the pixel value as a S8. More...
 
void get (uint16_t &v) const
 Interpret the pixel value as a U16. More...
 
void get (int16_t &v) const
 Interpret the pixel value as a S16. More...
 
void get (uint32_t &v) const
 Interpret the pixel value as a U32. More...
 
void get (int32_t &v) const
 Interpret the pixel value as a S32. More...
 
void get (uint64_t &v) const
 Interpret the pixel value as a U64. More...
 
void get (int64_t &v) const
 Interpret the pixel value as a S64. More...
 
void get (half &v) const
 Interpret the pixel value as a F16. More...
 
void get (float &v) const
 Interpret the pixel value as a F32. More...
 
void get (double &v) const
 Interpret the pixel value as a double. More...
 
template<typename T >
get () const
 Get the pixel value. More...
 

Data Fields

union {
   uint64_t   u64
 Single channel U64. More...
 
   int64_t   s64
 Single channel S64. More...
 
   uint8_t   rgb [3]
 3 channels: RGB888 More...
 
   uint8_t   yuv [3]
 3 channels: Any YUV format More...
 
   uint8_t   rgbx [4]
 4 channels: RGBX8888 More...
 
   double   f64
 Single channel double. More...
 
   float   f32
 Single channel float 32. More...
 
   half   f16
 Single channel F16. More...
 
   uint8_t   u8
 Single channel U8. More...
 
   int8_t   s8
 Single channel S8. More...
 
   uint16_t   u16
 Single channel U16. More...
 
   int16_t   s16
 Single channel S16. More...
 
   uint32_t   u32
 Single channel U32. More...
 
   int32_t   s32
 Single channel S32. More...
 
value
 Union which describes the value of a pixel for any image format. More...
 

Detailed Description

Class describing the value of a pixel for any image format.

Definition at line 34 of file PixelValue.h.

Constructor & Destructor Documentation

◆ PixelValue() [1/13]

PixelValue ( )
inline

Default constructor: value initialized to 0.

Definition at line 38 of file PixelValue.h.

39  : value{ int64_t(0) }
40  {
41  }
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.

◆ PixelValue() [2/13]

PixelValue ( int64_t  v,
DataType  datatype,
QuantizationInfo  qinfo = QuantizationInfo() 
)
inline

Initialize the union with a pixel value of chosen datatype.

Parameters
[in]vint value.
[in]datatypeDataType that v have to be stored
[in]qinfo(Optional) QuantizationInfo to apply in case of quantized data types to v

Definition at line 48 of file PixelValue.h.

49  : PixelValue()
50  {
51  switch(datatype)
52  {
53  case DataType::U8:
54  value.u8 = static_cast<uint8_t>(v);
55  break;
56  case DataType::S8:
57  value.s8 = static_cast<int8_t>(v);
58  break;
59  case DataType::QASYMM8:
60  value.u8 = quantize_qasymm8(static_cast<uint8_t>(v), qinfo);
61  break;
63  value.s8 = quantize_qasymm8_signed(static_cast<int8_t>(v), qinfo);
64  break;
65  case DataType::QSYMM8:
66  value.s8 = quantize_qsymm8(static_cast<int8_t>(v), qinfo);
67  break;
68  case DataType::U16:
69  value.u16 = static_cast<uint16_t>(v);
70  break;
71  case DataType::S16:
72  value.s16 = static_cast<int16_t>(v);
73  break;
74  case DataType::QASYMM16:
75  value.u16 = quantize_qasymm16(static_cast<uint16_t>(v), qinfo);
76  break;
77  case DataType::QSYMM16:
78  value.s16 = quantize_qsymm16(static_cast<int16_t>(v), qinfo);
79  break;
80  case DataType::U32:
81  value.u32 = static_cast<uint32_t>(v);
82  break;
83  case DataType::S32:
84  value.s32 = static_cast<int32_t>(v);
85  break;
86  case DataType::U64:
87  value.u64 = static_cast<uint64_t>(v);
88  break;
89  case DataType::S64:
90  value.s64 = static_cast<int64_t>(v);
91  break;
92  case DataType::F16:
93  value.f16 = static_cast<half>(v);
94  break;
95  case DataType::F32:
96  value.f32 = static_cast<float>(v);
97  break;
98  case DataType::F64:
99  value.f64 = static_cast<double>(v);
100  break;
101  default:
102  value.s64 = v;
103  break;
104  }
105  }
PixelValue()
Default constructor: value initialized to 0.
Definition: PixelValue.h:38
int8_t quantize_qsymm8(float value, const QuantizationInfo &qinfo)
Quantize a value given a 8-bit symmetric quantization scheme.
int16_t quantize_qsymm16(float value, const UniformQuantizationInfo &qinfo, RoundingPolicy rounding_policy=RoundingPolicy::TO_NEAREST_UP)
Quantize a value given a 16-bit symmetric quantization scheme.
quantized, symmetric fixed-point 16-bit number
uint8_t quantize_qasymm8(float value, const INFO_TYPE &qinfo, RoundingPolicy rounding_policy=RoundingPolicy::TO_NEAREST_UP)
Quantize a value given an unsigned 8-bit asymmetric quantization scheme.
1 channel, 1 U8 per channel
1 channel, 1 F32 per channel
quantized, asymmetric fixed-point 16-bit number
1 channel, 1 U16 per channel
1 channel, 1 F16 per channel
1 channel, 1 S32 per channel
signed 64-bit number
1 channel, 1 U32 per channel
int8_t quantize_qasymm8_signed(float value, const INFO_TYPE &qinfo, RoundingPolicy rounding_policy=RoundingPolicy::TO_NEAREST_UP)
Quantize a value given a signed 8-bit asymmetric quantization scheme.
quantized, asymmetric fixed-point 8-bit number unsigned
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.
1 channel, 1 S16 per channel
quantized, symmetric fixed-point 8-bit number
const QuantizationInfo qinfo
Definition: Im2Col.cpp:150
quantized, asymmetric fixed-point 8-bit number signed
64-bit floating-point number
unsigned 64-bit number
signed 8-bit number
uint16_t quantize_qasymm16(float value, const UniformQuantizationInfo &qinfo, RoundingPolicy rounding_policy=RoundingPolicy::TO_NEAREST_UP)
Quantize a value given a 16-bit asymmetric quantization scheme.

References arm_compute::F16, arm_compute::F32, arm_compute::F64, arm_compute::QASYMM16, arm_compute::QASYMM8, arm_compute::QASYMM8_SIGNED, arm_compute::test::validation::qinfo, arm_compute::QSYMM16, arm_compute::QSYMM8, arm_compute::quantize_qasymm16(), arm_compute::quantize_qasymm8(), arm_compute::quantize_qasymm8_signed(), arm_compute::quantize_qsymm16(), arm_compute::quantize_qsymm8(), arm_compute::S16, arm_compute::S32, arm_compute::S64, arm_compute::S8, arm_compute::U16, arm_compute::U32, arm_compute::U64, arm_compute::U8, and PixelValue::value.

◆ PixelValue() [3/13]

PixelValue ( int8_t  v)
inline

Initialize the union with a S8 pixel value.

Parameters
[in]vS8 value.

Definition at line 110 of file PixelValue.h.

111  : PixelValue()
112  {
113  value.s8 = v;
114  }
PixelValue()
Default constructor: value initialized to 0.
Definition: PixelValue.h:38
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.

References PixelValue::value.

◆ PixelValue() [4/13]

PixelValue ( uint8_t  v)
inline

Initialize the union with a U8 pixel value.

Parameters
[in]vU8 value.

Definition at line 119 of file PixelValue.h.

120  : PixelValue()
121  {
122  value.u8 = v;
123  }
PixelValue()
Default constructor: value initialized to 0.
Definition: PixelValue.h:38
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.

References PixelValue::value.

◆ PixelValue() [5/13]

PixelValue ( uint16_t  v)
inline

Initialize the union with a U16 pixel value.

Parameters
[in]vU16 value.

Definition at line 128 of file PixelValue.h.

129  : PixelValue()
130  {
131  value.u16 = v;
132  }
PixelValue()
Default constructor: value initialized to 0.
Definition: PixelValue.h:38
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.

References PixelValue::value.

◆ PixelValue() [6/13]

PixelValue ( int16_t  v)
inline

Initialize the union with a S16 pixel value.

Parameters
[in]vS16 value.

Definition at line 137 of file PixelValue.h.

138  : PixelValue()
139  {
140  value.s16 = v;
141  }
PixelValue()
Default constructor: value initialized to 0.
Definition: PixelValue.h:38
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.

References PixelValue::value.

◆ PixelValue() [7/13]

PixelValue ( uint32_t  v)
inline

Initialize the union with a U32 pixel value.

Parameters
[in]vU32 value.

Definition at line 146 of file PixelValue.h.

147  : PixelValue()
148  {
149  value.u32 = v;
150  }
PixelValue()
Default constructor: value initialized to 0.
Definition: PixelValue.h:38
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.

References PixelValue::value.

◆ PixelValue() [8/13]

PixelValue ( int32_t  v)
inline

Initialize the union with a S32 pixel value.

Parameters
[in]vS32 value.

Definition at line 155 of file PixelValue.h.

156  : PixelValue()
157  {
158  value.s32 = v;
159  }
PixelValue()
Default constructor: value initialized to 0.
Definition: PixelValue.h:38
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.

References PixelValue::value.

◆ PixelValue() [9/13]

PixelValue ( uint64_t  v)
inline

Initialize the union with a U64 pixel value.

Parameters
[in]vU64 value.

Definition at line 165 of file PixelValue.h.

166  : PixelValue()
167  {
168  value.u64 = v;
169  }
PixelValue()
Default constructor: value initialized to 0.
Definition: PixelValue.h:38
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.

References PixelValue::value.

◆ PixelValue() [10/13]

PixelValue ( int64_t  v)
inline

Initialize the union with a S64 pixel value.

Parameters
[in]vS64 value.

Definition at line 174 of file PixelValue.h.

175  : PixelValue()
176  {
177  value.s64 = v;
178  }
PixelValue()
Default constructor: value initialized to 0.
Definition: PixelValue.h:38
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.

References PixelValue::value.

◆ PixelValue() [11/13]

PixelValue ( half  v)
inline

Initialize the union with a F16 pixel value.

Parameters
[in]vF16 value.

Definition at line 183 of file PixelValue.h.

184  : PixelValue()
185  {
186  value.f16 = v;
187  }
PixelValue()
Default constructor: value initialized to 0.
Definition: PixelValue.h:38
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.

References PixelValue::value.

◆ PixelValue() [12/13]

PixelValue ( float  v)
inline

Initialize the union with a F32 pixel value.

Parameters
[in]vF32 value.

Definition at line 192 of file PixelValue.h.

193  : PixelValue()
194  {
195  value.f32 = v;
196  }
PixelValue()
Default constructor: value initialized to 0.
Definition: PixelValue.h:38
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.

References PixelValue::value.

◆ PixelValue() [13/13]

PixelValue ( double  v)
inline

Initialize the union with a F64 pixel value.

Parameters
[in]vF64 value.

Definition at line 201 of file PixelValue.h.

202  : PixelValue()
203  {
204  value.f64 = v;
205  }
PixelValue()
Default constructor: value initialized to 0.
Definition: PixelValue.h:38
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.

References PixelValue::value.

Member Function Documentation

◆ get() [1/12]

void get ( uint8_t &  v) const
inline

Interpret the pixel value as a U8.

Parameters
[out]vReturned value

Definition at line 230 of file PixelValue.h.

231  {
232  v = value.u8;
233  }
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.

References PixelValue::value.

Referenced by RandomAccessor::access_tensor(), and arm_compute::test::validation::reference::pad_layer().

◆ get() [2/12]

void get ( int8_t &  v) const
inline

Interpret the pixel value as a S8.

Parameters
[out]vReturned value

Definition at line 238 of file PixelValue.h.

239  {
240  v = value.s8;
241  }
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.

References PixelValue::value.

◆ get() [3/12]

void get ( uint16_t &  v) const
inline

Interpret the pixel value as a U16.

Parameters
[out]vReturned value

Definition at line 246 of file PixelValue.h.

247  {
248  v = value.u16;
249  }
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.

References PixelValue::value.

◆ get() [4/12]

void get ( int16_t &  v) const
inline

Interpret the pixel value as a S16.

Parameters
[out]vReturned value

Definition at line 254 of file PixelValue.h.

255  {
256  v = value.s16;
257  }
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.

References PixelValue::value.

◆ get() [5/12]

void get ( uint32_t &  v) const
inline

Interpret the pixel value as a U32.

Parameters
[out]vReturned value

Definition at line 262 of file PixelValue.h.

263  {
264  v = value.u32;
265  }
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.

References PixelValue::value.

◆ get() [6/12]

void get ( int32_t &  v) const
inline

Interpret the pixel value as a S32.

Parameters
[out]vReturned value

Definition at line 270 of file PixelValue.h.

271  {
272  v = value.s32;
273  }
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.

References PixelValue::value.

◆ get() [7/12]

void get ( uint64_t &  v) const
inline

Interpret the pixel value as a U64.

Parameters
[out]vReturned value

Definition at line 278 of file PixelValue.h.

279  {
280  v = value.u64;
281  }
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.

References PixelValue::value.

◆ get() [8/12]

void get ( int64_t &  v) const
inline

Interpret the pixel value as a S64.

Parameters
[out]vReturned value

Definition at line 286 of file PixelValue.h.

287  {
288  v = value.s64;
289  }
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.

References PixelValue::value.

◆ get() [9/12]

void get ( half v) const
inline

Interpret the pixel value as a F16.

Parameters
[out]vReturned value

Definition at line 294 of file PixelValue.h.

295  {
296  v = value.f16;
297  }
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.

References PixelValue::value.

◆ get() [10/12]

void get ( float &  v) const
inline

Interpret the pixel value as a F32.

Parameters
[out]vReturned value

Definition at line 302 of file PixelValue.h.

303  {
304  v = value.f32;
305  }
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.

References PixelValue::value.

◆ get() [11/12]

void get ( double &  v) const
inline

Interpret the pixel value as a double.

Parameters
[out]vReturned value

Definition at line 310 of file PixelValue.h.

311  {
312  v = value.f64;
313  }
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.

References PixelValue::value.

◆ get() [12/12]

T get ( ) const
inline

Get the pixel value.

Returns
Pixel value

Definition at line 319 of file PixelValue.h.

320  {
321  T val;
322  get(val);
323  return val;
324  }
T get() const
Get the pixel value.
Definition: PixelValue.h:319

Field Documentation

◆ f16

half f16

Single channel F16.

Definition at line 218 of file PixelValue.h.

◆ f32

float f32

Single channel float 32.

Definition at line 217 of file PixelValue.h.

◆ f64

double f64

Single channel double.

Definition at line 216 of file PixelValue.h.

◆ rgb

uint8_t rgb[3]

3 channels: RGB888

Definition at line 213 of file PixelValue.h.

◆ rgbx

uint8_t rgbx[4]

4 channels: RGBX8888

Definition at line 215 of file PixelValue.h.

◆ s16

int16_t s16

Single channel S16.

Definition at line 222 of file PixelValue.h.

◆ s32

int32_t s32

Single channel S32.

Definition at line 224 of file PixelValue.h.

◆ s64

int64_t s64

Single channel S64.

Definition at line 212 of file PixelValue.h.

◆ s8

int8_t s8

Single channel S8.

Definition at line 220 of file PixelValue.h.

◆ u16

uint16_t u16

Single channel U16.

Definition at line 221 of file PixelValue.h.

◆ u32

uint32_t u32

Single channel U32.

Definition at line 223 of file PixelValue.h.

◆ u64

uint64_t u64

Single channel U64.

Definition at line 211 of file PixelValue.h.

◆ u8

uint8_t u8

Single channel U8.

Definition at line 219 of file PixelValue.h.

◆ value

union { ... } value

Union which describes the value of a pixel for any image format.

Use the field corresponding to the image format

Referenced by PixelValue::get(), PixelValue::PixelValue(), and NEMemsetKernel::run().

◆ yuv

uint8_t yuv[3]

3 channels: Any YUV format

Definition at line 214 of file PixelValue.h.


The documentation for this class was generated from the following file: