Image Encoding

What are the different ways to encode an image?

There are 2 things that I am confused about:

  • How are images stored? How are they encoded? Are these 2 tied strongly together? What is NV12 and NV24?

I talked briefly about this through Peiliang.

Resources

These are Image Resolutions:

These are Image Compression things:

How do these relate to image encodings?

Generally, the image that you get from a camera is bgr8

I got some experience working with different kinds of cameras

Some of the most common encodings:

const std::string RGB8 = "rgb8";
const std::string BGR8 = "bgr8";

8UC1 = 8-bit unsigned, one channel

const std::string TYPE_8UC1="8UC1";
const std::string TYPE_8UC2="8UC2";
const std::string TYPE_8UC3="8UC3";

16-bit signed

const std::string TYPE_16SC1="16SC1";
const std::string TYPE_16SC2="16SC2";
const std::string TYPE_16SC3="16SC3";

32-bit Float (FP32)

const std::string TYPE_32FC1="32FC1";
const std::string TYPE_32FC2="32FC2";
const std::string TYPE_32FC3="32FC3";

64-bit float, a.k.a. double (FP64)

const std::string TYPE_64FC1="64FC1";
const std::string TYPE_64FC2="64FC2";
const std::string TYPE_64FC3="64FC3";

Bayer Encoding (see Bayer Filter)

// Bayer encodings
const std::string BAYER_RGGB8="bayer_rggb8";
const std::string BAYER_BGGR8="bayer_bggr8";
const std::string BAYER_GBRG8="bayer_gbrg8";
const std::string BAYER_GRBG8="bayer_grbg8";
  • Notice that there are two g channels, does that have to do with the fact that there are 50% more green channels?

I also saw in VPI, there was NV12 and NV24.

Other Formats

There is NV12 and NV24 that I saw at NVIDIA. This is equivalent to YUV Image Format.

Converting between Formats

I am running into this issue while working on my VR Headset Logs SLAM project. Since the raw disparity image is encoded in signed 16 format

VPIImageFormat disparity_format = VPI_IMAGE_FORMAT_S16;

However, I want to convert this disparity to depth, which I would store in F32 (float). Therefore, I need to first convert the values to F32. The question is, are those values still the same?