Compute Library
 23.11
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 () noexcept
 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 35 of file PixelValue.h.

Constructor & Destructor Documentation

◆ PixelValue() [1/14]

PixelValue ( )
inlinenoexcept

Default constructor: value initialized to 0.

Definition at line 39 of file PixelValue.h.

39  : value{int64_t(0)}
40  {
41  }

◆ 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.

48  : PixelValue()
49  {
50  switch (datatype)
51  {
52  case DataType::U8:
53  value.u8 = static_cast<uint8_t>(v);
54  break;
55  case DataType::S8:
56  value.s8 = static_cast<int8_t>(v);
57  break;
58  case DataType::QASYMM8:
59  value.u8 = quantize_qasymm8(static_cast<float>(v), qinfo);
60  break;
62  value.s8 = quantize_qasymm8_signed(static_cast<float>(v), qinfo);
63  break;
64  case DataType::QSYMM8:
65  value.s8 = quantize_qsymm8(static_cast<float>(v), qinfo);
66  break;
67  case DataType::U16:
68  value.u16 = static_cast<uint16_t>(v);
69  break;
70  case DataType::S16:
71  value.s16 = static_cast<int16_t>(v);
72  break;
73  case DataType::QASYMM16:
74  value.u16 = quantize_qasymm16(static_cast<float>(v), qinfo);
75  break;
76  case DataType::QSYMM16:
77  value.s16 = quantize_qsymm16(static_cast<float>(v), qinfo);
78  break;
79  case DataType::U32:
80  value.u32 = static_cast<uint32_t>(v);
81  break;
82  case DataType::S32:
83  value.s32 = static_cast<int32_t>(v);
84  break;
85  case DataType::U64:
86  value.u64 = static_cast<uint64_t>(v);
87  break;
88  case DataType::S64:
89  value.s64 = static_cast<int64_t>(v);
90  break;
91  case DataType::BFLOAT16:
92  value.bf16 = static_cast<bfloat16>(v);
93  break;
94  case DataType::F16:
95  value.f16 = static_cast<half>(v);
96  break;
97  case DataType::F32:
98  value.f32 = static_cast<float>(v);
99  break;
100  case DataType::F64:
101  default:
102  value.f64 = v;
103  break;
104  }
105  }

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 110 of file PixelValue.h.

110  : PixelValue()
111  {
112  value.s8 = v;
113  }

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 118 of file PixelValue.h.

118  : PixelValue()
119  {
120  value.u8 = v;
121  }

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 126 of file PixelValue.h.

126  : PixelValue()
127  {
128  value.u16 = v;
129  }

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 134 of file PixelValue.h.

134  : PixelValue()
135  {
136  value.s16 = v;
137  }

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 142 of file PixelValue.h.

142  : PixelValue()
143  {
144  value.u32 = v;
145  }

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 150 of file PixelValue.h.

150  : PixelValue()
151  {
152  value.s32 = v;
153  }

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 159 of file PixelValue.h.

159  : PixelValue()
160  {
161  value.u64 = v;
162  }

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 167 of file PixelValue.h.

167  : PixelValue()
168  {
169  value.s64 = v;
170  }

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 175 of file PixelValue.h.

175  : PixelValue()
176  {
177  value.bf16 = v;
178  }

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 183 of file PixelValue.h.

183  : PixelValue()
184  {
185  value.f16 = v;
186  }

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 191 of file PixelValue.h.

191  : PixelValue()
192  {
193  value.f32 = v;
194  }

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 199 of file PixelValue.h.

199  : PixelValue()
200  {
201  value.f64 = v;
202  }

References PixelValue::value.

Member Function Documentation

◆ get() [1/13]

T get ( ) const
inline

Get the pixel value.

Returns
Pixel value

Definition at line 325 of file PixelValue.h.

326  {
327  T val;
328  get(val);
329  return val;
330  }

◆ get() [2/13]

void get ( bfloat16 v) const
inline

Interpret the pixel value as a BFLOAT16.

Parameters
[out]vReturned value

Definition at line 292 of file PixelValue.h.

293  {
294  v = value.bf16;
295  }

References PixelValue::value.

◆ get() [3/13]

void get ( double &  v) const
inline

Interpret the pixel value as a double.

Parameters
[out]vReturned value

Definition at line 316 of file PixelValue.h.

317  {
318  v = value.f64;
319  }

References PixelValue::value.

◆ get() [4/13]

void get ( float &  v) const
inline

Interpret the pixel value as a F32.

Parameters
[out]vReturned value

Definition at line 308 of file PixelValue.h.

309  {
310  v = value.f32;
311  }

References PixelValue::value.

◆ get() [5/13]

void get ( half v) const
inline

Interpret the pixel value as a F16.

Parameters
[out]vReturned value

Definition at line 300 of file PixelValue.h.

301  {
302  v = value.f16;
303  }

References PixelValue::value.

◆ get() [6/13]

void get ( int16_t &  v) const
inline

Interpret the pixel value as a S16.

Parameters
[out]vReturned value

Definition at line 252 of file PixelValue.h.

253  {
254  v = value.s16;
255  }

References PixelValue::value.

◆ get() [7/13]

void get ( int32_t &  v) const
inline

Interpret the pixel value as a S32.

Parameters
[out]vReturned value

Definition at line 268 of file PixelValue.h.

269  {
270  v = value.s32;
271  }

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 284 of file PixelValue.h.

285  {
286  v = value.s64;
287  }

References PixelValue::value.

◆ get() [9/13]

void get ( int8_t &  v) const
inline

Interpret the pixel value as a S8.

Parameters
[out]vReturned value

Definition at line 236 of file PixelValue.h.

237  {
238  v = value.s8;
239  }

References PixelValue::value.

◆ get() [10/13]

void get ( uint16_t &  v) const
inline

Interpret the pixel value as a U16.

Parameters
[out]vReturned value

Definition at line 244 of file PixelValue.h.

245  {
246  v = value.u16;
247  }

References PixelValue::value.

◆ get() [11/13]

void get ( uint32_t &  v) const
inline

Interpret the pixel value as a U32.

Parameters
[out]vReturned value

Definition at line 260 of file PixelValue.h.

261  {
262  v = value.u32;
263  }

References PixelValue::value.

◆ get() [12/13]

void get ( uint64_t &  v) const
inline

Interpret the pixel value as a U64.

Parameters
[out]vReturned value

Definition at line 276 of file PixelValue.h.

277  {
278  v = value.u64;
279  }

References PixelValue::value.

◆ get() [13/13]

Field Documentation

◆ bf16

bfloat16 bf16

Single channel brain floating-point number.

Definition at line 216 of file PixelValue.h.

◆ f16

half f16

Single channel F16.

Definition at line 215 of file PixelValue.h.

◆ f32

float f32

Single channel float 32.

Definition at line 214 of file PixelValue.h.

◆ f64

double f64

Single channel double.

Definition at line 213 of file PixelValue.h.

◆ rgb

uint8_t rgb[3]

3 channels: RGB888

Definition at line 210 of file PixelValue.h.

◆ rgbx

uint8_t rgbx[4]

4 channels: RGBX8888

Definition at line 212 of file PixelValue.h.

◆ s16

int16_t s16

Single channel S16.

Definition at line 220 of file PixelValue.h.

◆ s32

int32_t s32

Single channel S32.

Definition at line 222 of file PixelValue.h.

◆ s64

int64_t s64

Single channel S64.

Definition at line 209 of file PixelValue.h.

◆ s8

int8_t s8

Single channel S8.

Definition at line 218 of file PixelValue.h.

◆ u16

uint16_t u16

Single channel U16.

Definition at line 219 of file PixelValue.h.

◆ u32

uint32_t u32

Single channel U32.

Definition at line 221 of file PixelValue.h.

◆ u64

uint64_t u64

Single channel U64.

Definition at line 208 of file PixelValue.h.

◆ u8

uint8_t u8

Single channel U8.

Definition at line 217 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 CpuFillKernel::run_op().

◆ yuv

uint8_t yuv[3]

3 channels: Any YUV format

Definition at line 211 of file PixelValue.h.


The documentation for this class was generated from the following file:
arm_compute::DataType::QASYMM16
@ QASYMM16
quantized, asymmetric fixed-point 16-bit number
arm_compute::DataType::U64
@ U64
unsigned 64-bit number
arm_compute::DataType::BFLOAT16
@ BFLOAT16
16-bit brain floating-point number
arm_compute::DataType::F64
@ F64
64-bit floating-point number
arm_compute::quantize_qsymm16
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.
Definition: QuantizationInfo.h:441
arm_compute::DataType::QASYMM8
@ QASYMM8
quantized, asymmetric fixed-point 8-bit number unsigned
arm_compute::DataType::U16
@ U16
unsigned 16-bit number
arm_compute::quantize_qsymm8
int8_t quantize_qsymm8(float value, const QuantizationInfo &qinfo)
Quantize a value given a 8-bit symmetric quantization scheme.
Definition: QuantizationInfo.h:323
arm_compute::DataType::QSYMM8
@ QSYMM8
quantized, symmetric fixed-point 8-bit number
arm_compute::quantize_qasymm8
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.
Definition: QuantizationInfo.h:295
arm_compute::DataType::S8
@ S8
signed 8-bit number
arm_compute::DataType::QSYMM16
@ QSYMM16
quantized, symmetric fixed-point 16-bit number
arm_compute::half
half_float::half half
16-bit floating point type
Definition: CoreTypes.h:36
arm_compute::PixelValue::PixelValue
PixelValue() noexcept
Default constructor: value initialized to 0.
Definition: PixelValue.h:39
arm_compute::DataType::U32
@ U32
unsigned 32-bit number
arm_compute::quantize_qasymm8_signed
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.
Definition: QuantizationInfo.h:309
arm_compute::DataType::U8
@ U8
unsigned 8-bit number
arm_compute::DataType::S16
@ S16
signed 16-bit number
arm_compute::DataType::QASYMM8_SIGNED
@ QASYMM8_SIGNED
quantized, asymmetric fixed-point 8-bit number signed
arm_gemm::bfloat16
arm_compute::bfloat16 bfloat16
Definition: bfloat.hpp:30
arm_compute::PixelValue::get
T get() const
Get the pixel value.
Definition: PixelValue.h:325
arm_compute::DataType::S64
@ S64
signed 64-bit number
arm_compute::DataType::F16
@ F16
16-bit floating-point number
arm_compute::DataType::S32
@ S32
signed 32-bit number
arm_compute::PixelValue::value
union arm_compute::PixelValue::@0 value
Union which describes the value of a pixel for any image format.
arm_compute::quantize_qasymm16
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.
Definition: QuantizationInfo.h:494
arm_compute::DataType::F32
@ F32
32-bit floating-point number
arm_compute::test::validation::qinfo
const QuantizationInfo qinfo
Definition: Im2Col.cpp:155