Pixel format
The EPixelFormat enumeration contains the list of all the pixel formats that can be used by Image objects.
Each pixel format has an underlying data type, expressed by the EPixelDepth enumeration. The pixel format Mono8 has a depth of Uint8, meaning that each pixel will be represented by a single byte. The pixel format Mono16 has a depth of Uint16, meaning that each pixel will be represented by two bytes.
Some ot the pixel formats are equivalent but are used on different situations, and sometimes cannot be used interchangeably. For example, the pixel formats Confidence32f and Data32f are both based on the Float32 data type, but are used in different situations. The pixel format Confidence32f is used to express a confidence value between 0 and 1, and some functions will take into account this range. The pixel format Data32f can express any Float32 value, and is used for any data.
Main pixel formats
The following are the most common pixel formats used in OneVision. For a complete list of all pixel formats, see the EPixelFormat enumeration.
Mono8
A single channel image (monochromatic) with 8 bits per pixel. This is the most common pixel format used in OneVision.
- Min value - 0
- Max value - 255
- Pixel depth - Uint8
Mono16
A single channel image (monochromatic) with 16 bits per pixel. This pixel format is used when higher dynamic range for the image data is needed. For example, it is common to use this pixel format with thermal cameras or 3D cameras to express depth information.
- Min value - 0
- Max value - 65535
- Pixel depth - Uint16
BGR8
A three channel image (color) with 8 bits per channel. This pixel format is used to represent color images in the BGR color space. This is the standard color format used in OneVision, instead of RGB8.
- Min value - 0
- Max value - 255
- Pixel depth - Uint8
- Number of channels - 3
Confidence32f
A single channel image with a floating-point 32 bits value per pixel. This pixel format is used to represent a confidence value between 0 and 1. This pixel format is widely used as segmentation output of deep learning models in OneVision.
- Min value - 0.0
- Max value - 1.0
- Pixel depth - Float32
Data32f
A single channel image with a floating-point 32 bits value per pixel. This pixel format is used to represent any data that can be expressed as a 32 bits floating-point value. This pixel format and its variants are widely used for 3D data manipulation. This pixel format is considered range infinite because the limit of the numeric values are the limits of the floating-point representation.
- Min value - -∞
- Max value - +∞
- Pixel depth - Float32
- Range infinite - Yes
Functions
pixelformatToString()
This function returns a string representation of the pixel format. For example, for Mono8 will return the string "Mono8".
function pixelformatToString(format: EPixelFormat): string;
pixelformatFromString()
This function returns the pixel format from a string representation. For example, for the string "Mono8" will return the pixel format Mono8. If the string is not a valid pixel format, it will throw an error.
function function pixelformatFromString(formatStr: string): EPixelFormat;
pixelformatGetDescription()
This function returns a description in english of the pixel format. For example, for Mono8 will return the string "Monochrome 8-bit".
function pixelformatGetDescription(format: EPixelFormat): string;
pixelformatGetChannelCount()
This function returns the number of channels of the pixel format. For example, for BGR8 will return 3, and for Mono8 will return 1.
function pixelformatGetChannelCount(format: EPixelFormat): number;
pixelformatGetBitsPerChannel()
This function returns the number of bits per channel of the pixel format. For example, for Mono8 and BGR8 will return 8, and for Mono16 will return 16.
function pixelformatGetBitsPerChannel(format: EPixelFormat): number;
pixelformatGetBitsPerPixel()
This function returns the number of bits per pixel of the pixel format. For example, for Mono8 will return 8, and for BGR8 will return 24.
function pixelformatGetBitsPerPixel(format: EPixelFormat): number;
pixelformatGetBytesPerChannel()
This function returns the number of bytes per channel of the pixel format. For example, for Mono8 and BGR8 will return 1, and for Mono16 will return 2.
function pixelformatGetBytesPerChannel(format: EPixelFormat): number;
pixelformatGetBytesPerPixel()
This function returns the number of bytes per pixel of the pixel format. For example, for Mono8 will return 1, for Mono16 will return 2, and for BGR8 will return 3.
function pixelformatGetBytesPerPixel(format: EPixelFormat): number;
pixelformatGetBitsPerChannel()
This function returns the number of bits per channel of the pixel format. For example, for Mono8 will return 8, and for Mono16 will return 16.
function pixelformatGetBitsPerChannel(format: EPixelFormat): number;
pixelformatGetMinValue()
This function returns the minimum value that can be represented by the pixel format. For example, for Mono8 will return 0, and for Mono16 will return 0.
function pixelformatGetMinValue(format: EPixelFormat): number;
pixelformatGetMaxValue()
This function returns the maximum value that can be represented by the pixel format. For example, for Mono8 will return 255, and for Mono16 will return 65535.
function pixelformatGetMaxValue(format: EPixelFormat): number;
pixelformatGetDepth()
This function returns the pixel depth corresponding to the pixel format. The pixel depth represents the underlying data type of the pixel format.
function pixelformatGetDepth(format: EPixelFormat): EPixelDepth;
pixelformatIsRangeInfinite()
This function returns if the pixel format has an infinite range. For example, for Data32f will return true, and for Mono8 and Confidence32f will return false.
function pixelformatIsRangeInfinite(format: EPixelFormat): boolean;
pixelDepthMinValue()
Returns the minimum value for a pixel depth, possibly different from the pixel format min value.
function pixelDepthMinValue(depth: EPixelDepth): number;
pixelDepthMaxValue()
Returns the maximum value for a pixel depth, possibly different from the pixel format max value.
function pixelDepthMaxValue(depth: EPixelDepth): number;
Types
EPixelFormat
This is the enumeration of all possible pixel formats. The hexadecimal value (0x) assigned to each pixel format is the convention established by the EMVA (European Machine Vision Association) in its PNFC standard (Pixel Format Naming Convention).
- InvalidPixelFormat - Invalid pixel format, used to represent an unknown pixel format
- Mono8 - Monochrome 8-bit
- Mono10 - Monochrome 10-bit unpacked
- Mono16 - Monochrome 16-bit
- BGR8 - Blue-Green-Red 8-bit
- BGRa8 - Blue-Green-Red-alpha 8-bit
- RGB8 - Red-Green-Blue 8-bit
- RGBa8 - Red-Green-Blue-alpha 8-bit
- Data32f - Data 32-bit float
- Coord3D_A32f - 3D coordinate A 32-bit floating point
- Coord3D_B32f - 3D coordinate B 32-bit floating point
- Coord3D_C32f - 3D coordinate C 32-bit floating point
- Coord3D_AC8 - 3D coordinate A-C 8-bit
- Coord3D_ABC32f - 3D coordinate A-B-C 32-bit floating point
- Confidence8 - Confidence 8-bit integer, as a Mono8 [0, 255]
- Confidence32f - Confidence 32-bit float, as Data32f normalized [0., 1.]
- BayerBG8 - Bayer Blue-Green 8-bit
- BayerGB8 - Bayer Green-Blue 8-bit
- BayerGR8 - Bayer Green-Red 8-bit
- BayerRG8 - Bayer Red-Green 8-bit
EPixelDepth
This is the enumeration of all possible pixel depths. Pixel depths represent the underlying data type of a pixel format.
- InvalidDataType - Invalid data type
- Uint8 - Unsigned 8-bit integer
- Uint16 - Unsigned 16-bit integer
- Float32 - 32-bit floating point