Compute Library
 20.08
PixelValue Class Reference

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

#include <PixelValue.h>

Collaboration diagram for PixelValue:
[legend]

Public Member Functions

 PixelValue ()
 Default constructor: value initialized to 0. More...
 
 PixelValue (double 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 (bfloat16 v)
 Initialize the union with a BFLOAT16 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 (bfloat16 &v) const
 Interpret the pixel value as a BFLOAT16. 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...
 
   bfloat16   bf16
 Single channel brain floating-point number. 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/14]

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/14]

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

Initialize the union with a pixel value of chosen datatype.

Parameters
[in]vvalue.
[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<float>(v), qinfo);
61  break;
63  value.s8 = quantize_qasymm8_signed(static_cast<float>(v), qinfo);
64  break;
65  case DataType::QSYMM8:
66  value.s8 = quantize_qsymm8(static_cast<float>(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<float>(v), qinfo);
76  break;
77  case DataType::QSYMM16:
78  value.s16 = quantize_qsymm16(static_cast<float>(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::BFLOAT16:
93  value.bf16 = static_cast<bfloat16>(v);
94  break;
95  case DataType::F16:
96  value.f16 = static_cast<half>(v);
97  break;
98  case DataType::F32:
99  value.f32 = static_cast<float>(v);
100  break;
101  case DataType::F64:
102  default:
103  value.f64 = v;
104  break;
105  }
106  }
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
16-bit brain floating-point number
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::BFLOAT16, 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/14]

PixelValue ( int8_t  v)
inline

Initialize the union with a S8 pixel value.

Parameters
[in]vS8 value.

Definition at line 111 of file PixelValue.h.

112  : PixelValue()
113  {
114  value.s8 = v;
115  }
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/14]

PixelValue ( uint8_t  v)
inline

Initialize the union with a U8 pixel value.

Parameters
[in]vU8 value.

Definition at line 120 of file PixelValue.h.

121  : PixelValue()
122  {
123  value.u8 = v;
124  }
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/14]

PixelValue ( uint16_t  v)
inline

Initialize the union with a U16 pixel value.

Parameters
[in]vU16 value.

Definition at line 129 of file PixelValue.h.

130  : PixelValue()
131  {
132  value.u16 = v;
133  }
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/14]

PixelValue ( int16_t  v)
inline

Initialize the union with a S16 pixel value.

Parameters
[in]vS16 value.

Definition at line 138 of file PixelValue.h.

139  : PixelValue()
140  {
141  value.s16 = v;
142  }
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/14]

PixelValue ( uint32_t  v)
inline

Initialize the union with a U32 pixel value.

Parameters
[in]vU32 value.

Definition at line 147 of file PixelValue.h.

148  : PixelValue()
149  {
150  value.u32 = v;
151  }
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/14]

PixelValue ( int32_t  v)
inline

Initialize the union with a S32 pixel value.

Parameters
[in]vS32 value.

Definition at line 156 of file PixelValue.h.

157  : PixelValue()
158  {
159  value.s32 = v;
160  }
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/14]

PixelValue ( uint64_t  v)
inline

Initialize the union with a U64 pixel value.

Parameters
[in]vU64 value.

Definition at line 166 of file PixelValue.h.

167  : PixelValue()
168  {
169  value.u64 = v;
170  }
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/14]

PixelValue ( int64_t  v)
inline

Initialize the union with a S64 pixel value.

Parameters
[in]vS64 value.

Definition at line 175 of file PixelValue.h.

176  : PixelValue()
177  {
178  value.s64 = v;
179  }
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/14]

PixelValue ( bfloat16  v)
inline

Initialize the union with a BFLOAT16 pixel value.

Parameters
[in]vF16 value.

Definition at line 184 of file PixelValue.h.

185  : PixelValue()
186  {
187  value.bf16 = v;
188  }
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/14]

PixelValue ( half  v)
inline

Initialize the union with a F16 pixel value.

Parameters
[in]vF16 value.

Definition at line 193 of file PixelValue.h.

194  : PixelValue()
195  {
196  value.f16 = v;
197  }
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/14]

PixelValue ( float  v)
inline

Initialize the union with a F32 pixel value.

Parameters
[in]vF32 value.

Definition at line 202 of file PixelValue.h.

203  : PixelValue()
204  {
205  value.f32 = v;
206  }
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() [14/14]

PixelValue ( double  v)
inline

Initialize the union with a F64 pixel value.

Parameters
[in]vF64 value.

Definition at line 211 of file PixelValue.h.

212  : PixelValue()
213  {
214  value.f64 = v;
215  }
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/13]

void get ( uint8_t &  v) const
inline

Interpret the pixel value as a U8.

Parameters
[out]vReturned value

Definition at line 241 of file PixelValue.h.

242  {
243  v = value.u8;
244  }
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/13]

void get ( int8_t &  v) const
inline

Interpret the pixel value as a S8.

Parameters
[out]vReturned value

Definition at line 249 of file PixelValue.h.

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

References PixelValue::value.

◆ get() [3/13]

void get ( uint16_t &  v) const
inline

Interpret the pixel value as a U16.

Parameters
[out]vReturned value

Definition at line 257 of file PixelValue.h.

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

References PixelValue::value.

◆ get() [4/13]

void get ( int16_t &  v) const
inline

Interpret the pixel value as a S16.

Parameters
[out]vReturned value

Definition at line 265 of file PixelValue.h.

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

References PixelValue::value.

◆ get() [5/13]

void get ( uint32_t &  v) const
inline

Interpret the pixel value as a U32.

Parameters
[out]vReturned value

Definition at line 273 of file PixelValue.h.

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

References PixelValue::value.

◆ get() [6/13]

void get ( int32_t &  v) const
inline

Interpret the pixel value as a S32.

Parameters
[out]vReturned value

Definition at line 281 of file PixelValue.h.

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

References PixelValue::value.

◆ get() [7/13]

void get ( uint64_t &  v) const
inline

Interpret the pixel value as a U64.

Parameters
[out]vReturned value

Definition at line 289 of file PixelValue.h.

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

References PixelValue::value.

◆ get() [8/13]

void get ( int64_t &  v) const
inline

Interpret the pixel value as a S64.

Parameters
[out]vReturned value

Definition at line 297 of file PixelValue.h.

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

References PixelValue::value.

◆ get() [9/13]

void get ( bfloat16 v) const
inline

Interpret the pixel value as a BFLOAT16.

Parameters
[out]vReturned value

Definition at line 305 of file PixelValue.h.

306  {
307  v = value.bf16;
308  }
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.

References PixelValue::value.

◆ get() [10/13]

void get ( half v) const
inline

Interpret the pixel value as a F16.

Parameters
[out]vReturned value

Definition at line 313 of file PixelValue.h.

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

References PixelValue::value.

◆ get() [11/13]

void get ( float &  v) const
inline

Interpret the pixel value as a F32.

Parameters
[out]vReturned value

Definition at line 321 of file PixelValue.h.

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

References PixelValue::value.

◆ get() [12/13]

void get ( double &  v) const
inline

Interpret the pixel value as a double.

Parameters
[out]vReturned value

Definition at line 329 of file PixelValue.h.

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

References PixelValue::value.

◆ get() [13/13]

T get ( ) const
inline

Get the pixel value.

Returns
Pixel value

Definition at line 338 of file PixelValue.h.

339  {
340  T val;
341  get(val);
342  return val;
343  }
T get() const
Get the pixel value.
Definition: PixelValue.h:338

Field Documentation

◆ bf16

bfloat16 bf16

Single channel brain floating-point number.

Definition at line 229 of file PixelValue.h.

◆ f16

half f16

Single channel F16.

Definition at line 228 of file PixelValue.h.

◆ f32

float f32

Single channel float 32.

Definition at line 227 of file PixelValue.h.

◆ f64

double f64

Single channel double.

Definition at line 226 of file PixelValue.h.

◆ rgb

uint8_t rgb[3]

3 channels: RGB888

Definition at line 223 of file PixelValue.h.

◆ rgbx

uint8_t rgbx[4]

4 channels: RGBX8888

Definition at line 225 of file PixelValue.h.

◆ s16

int16_t s16

Single channel S16.

Definition at line 233 of file PixelValue.h.

◆ s32

int32_t s32

Single channel S32.

Definition at line 235 of file PixelValue.h.

◆ s64

int64_t s64

Single channel S64.

Definition at line 222 of file PixelValue.h.

◆ s8

int8_t s8

Single channel S8.

Definition at line 231 of file PixelValue.h.

◆ u16

uint16_t u16

Single channel U16.

Definition at line 232 of file PixelValue.h.

◆ u32

uint32_t u32

Single channel U32.

Definition at line 234 of file PixelValue.h.

◆ u64

uint64_t u64

Single channel U64.

Definition at line 221 of file PixelValue.h.

◆ u8

uint8_t u8

Single channel U8.

Definition at line 230 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 224 of file PixelValue.h.


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