Skip to main content

Pixel formats and plane layout

This section will discuss some examples of important pixel formats and explain their differences as well as their similarities.

Format: RGB24

An image with pixel format RGB24 is composed of one plane and the plane has three channels (for red, green, and blue color values). The image memory is based on elements with data type uint8_t, with three elements representing a pixel so that each pixel needs 24 bits in memory. The image width in pixels is identical to the plane width in pixels. The plane width in elements is three times the width in pixels. The plane may contain padding elements at the end of each row which then increases the plane’s stride accordingly.

Image: The pixel format FORMAT_RGB24

Format: Y8

An image with format Y8 is very similar to RGB24 but the plane has only one channel. Therefore, the width of the image in pixels is identical to the plane's width in elements.

Image: The pixel format FORMAT_Y8

Format: Y_UV12

A common pixel format with two planes is e.g., Y_UV12. In Ocean, the underscore (_) between Y and UV is used to denote that the image information is separated into two planes. The first plane contains the luminance channel of the image, while the second plane contains the two chrominance channels of the image. As a way to reduce bandwidth, the second plane does not define chrominance values for each pixel in the first plane. Instead it defines one for every second pixel only. Thus, the height of the first plane is two times the height of the second plane. In average, the image data is stored with 12 bits per pixels. It's important to note that due to the 2x2 downsampling of the second plane, this pixel format does not allow image dimensions with odd values.

Image: The pixel format FORMAT_Y_UV12

Format: Y_U_V24

Images with the format Y_U_V24 are composed of three planes. Each plane holds one image channel without any sub-sampling.

Image: The pixel format FORMAT_Y_U_V24

Pre-defined pixel formats

Below, you will find all currently defined pixel formats in Ocean (some formats are left out). Please refer to the accompanying documentation for detailed information about memory layout and value ranges. The most common pixel formats are highlighted for easy reference.

TypeNameElement TypeAlphaComment
Color (RGB)FORMAT_RGB24uint8_tStandard RGB format with 8 bits per channel
FORMAT_RGBA32uint8_tYesStandard RGB format with 8 bits and alpha
FORMAT_RGB32uint8_tIncludes 8 unused bits
FORMAT_RGB48uint16_t16 bits per channel
FORMAT_RGBA64uint16_tYes
FORMAT_ARGB32uint8_tYesFirst alpha channel, then color channels
FORMAT_RGB4444uint16_t4 bits per channels, includes 4 unused bits
FORMAT_RGBA4444uint16_tYes
FORMAT_RGB5551uint16_t5 bits per channel, includes 1 unused bit
FORMAT_RGB565uint16_t5 bits for red/blue, 6 bits for green
FORMAT_RGBT32uint8_tContains a custom texture channel
FORMAT_RGGB10_PACKEDuint8_tPacked Bayer, 10 bits per channel
Color (BGR)FORMAT_BGR24uint8_tas RGB24 but with reverse channel order
FORMAT_BGRA32uint8_tYes
FORMAT_BGR32uint8_t
FORMAT_BGR4444uint16_t
FORMAT_BGRA4444uint8_tYes
FORMAT_BGR5551uint16
FORMAT_BGR565uint16_t
FORMAT_ABGR32uint8_tYesFirst alpha channel, then color channels
FORMAT_BGGR10_PACKEDuint8_tPacked Bayer, 10 bits per channel
Y (Gray)FORMAT_Y8uint8_tGrayscale image with 8 bits
FORMAT_Y16uint16_tGrayscale image with 16 bits
FORMAT_Y32uint32_t
FORMAT_Y64uint64_t
FORMAT_YA16uint8_tYesGrayscale image with 8 bits and alpha
FORMAT_Y10uint16_tGrayscale image, 10 bits, 6 bits unused
FORMAT_Y10_PACKEDuint8_tPacked Bayer, 10 bits per pixel
Color (YUV)FORMAT_YUV24uint8_tLuminance (Y), Chrominance Blue (U, V)
FORMAT_YVU24uint8_tFlipped chrominance channels
FORMAT_YUVA32uint8_tYes
FORMAT_YUVT32uint8_tContains a custom texture channel
FORMAT_YUYV16uint8_t16 bits per pixel, U/V every second pixel, aka YUY2
FORMAT_UYVY16uint8_tKnown as UYVY
FORMAT_Y_UV12uint8_tOne gray, one chrominance plane, aka NV12
FORMAT_Y_VU12uint8_tKnown as NV21
FORMAT_Y_U_V24uint8_tKnown as I444
FORMAT_Y_U_V12uint8_tKnown as I420
FORMAT_Y_V_U12uint8_tKnown as YV12
DepthFORMAT_F32floatFloats with 32 bit precision, e.g., for depth
FORMAT_F64doubleFloats with 64 bit precision

Custom pixel formats

In addition to the predefined pixel formats, Ocean allows the definition of custom pixel formats both at runtime and compile time. Below are examples demonstrating how to easily define such generic pixel formats:

Pixel format for single-plane images with two channels, each represented by a float:

FrameType::genericPixelFormat<float, 2u>();

Pixel format for single-plane images with three channels, each represented by a uint32_t:

FrameType::genericPixelFormat<uint32_t, 3u>();