Understanding Pixel Formats
Not all formats are supported on all cameras. To see what pixel formats are supported by your model, consult the Specifications and Frame Rates section of the camera's Camera Reference or Technical Reference, or connect your camera and query the PixelFormat feature.
To choose a pixel format, use the PixelFormat feature to select from a list of supported formats. Once a format is selected, the following values are derived:
- PixelSize provides the total size in bits of the image's pixel.
- PixelColorFilter is the type of color filter that is applied to the image. This only applies to bayer formats. The value is None for other formats.
- PixelDynamicRangeMin is the minimum value that can be returned during the digitization process. This corresponds to the darkest value of the camera. For color cameras, this returns the smallest value that each color component can take.
- PixelDynamicRangeMax is the maximum value that can be returned during the digitization process. This corresponds to the brightest value of the camera. For color cameras, this returns the largest value that each color component can take.
Note: For color cameras, the bayer pixel format is updated if Reverse X and Reverse Y are changed. For example, if the original pixel format is BayerRG8 and Reverse X is switched from Disabled to Enabled, then the pixel format is updated to BayerGR8.
Single Channel 8-bit and 16-bit Formats
8-bit Formats | Mono8 | 8-bit monochrome packed format |
BayerGR8 | 8-bit bayer green red packed format | |
BayerRG8 | 8-bit bayer red green packed format | |
BayerGB8 | 8-bit bayer green blue packed format | |
BayerBG8 | 8-bit bayer blue green packed format | |
16-bit Formats | Mono16 | 16-bit monochrome packed format |
BayerGR16 | 16-bit bayer green red packed format | |
BayerRG16 | 16-bit bayer red green packed format | |
BayerGB16 | 16-bit bayer green blue packed format | |
BayerBG16 | 16-bit bayer blue green packed format |
Single Channel 10-bit Formats
10-bit pixel formats have two different packing formats as defined by USB3 Vision and GigE Vision.
Note: the packing format is not related to the interface of the camera. Both may be available on USB3 or GigE devices.
The USB3 Vision method is designated with a p. It is a 10-bit format with its bit-stream following the bit packing method illustrated in Figure 1. The first byte of the packed stream contains the eight least significant bits (lsb) of the first pixel. The two lsb of the second byte contain two msb of the first pixel, and the rest of the second byte is packed with the six lsb of the second pixel. The four msb of the second pixels fill into the four lsb of the third byte. The lsb of the third pixel fill in the rest of the third byte, and the remaining bits of the third pixel fill in the lsb of the fourth byte. The bytes are packed following this pattern. In general, pixels are packed into bytes in sequence from lsb, and four pixels pack into five bytes.
This packing format is applied to: Mono10p, BayerGR10p, BayerRG10p, BayerGB10p and BayerBG10p.
Figure 1. Packing two 10-bit pixels into three bytes.
The GigE Vision method is designated with Packed. It is a 10-bit format with its bit-stream following the bit packing method illustrated in Figure 2. The first byte of the packed stream contains the eight msb of the first pixel. The third byte contains the eight msb of the second pixel. The two lsb of the second byte contains two lsb of the first pixel, and the fifth and the sixth bits of the second byte are packed with the two lsb of the second pixel. The remaining bits in the second bytes are set to null.
This packing format is applied to: Mono10Packed, BayerGR10Packed, BayerRG10Packed, BayerGB10Packed and BayerBG10Packed.
Figure 2. Packing two 10-bit pixels into three bytes.
Single Channel 12-bit Formats
12-bit pixel formats have two different packing formats as defined by USB3 Vision and GigE Vision.
Note: the packing format is not related to the interface of the camera. Both may be available on USB3 or GigE devices.
The USB3 Vision method is designated with a p. It is a 12-bit format with its bit-stream following the bit packing method illustrated in Figure 3. The first byte of the packed stream contains the eight least significant bits (lsb) of the first pixel. The third byte contains the eight most significant bits (msb) of the second pixel. The four lsb of the second byte contains four msb of the first pixel, and the rest of the second byte is packed with the four lsb of the second pixel.
This packing format is applied to: Mono12p, BayerGR12p, BayerRG12p, BayerGB12p and BayerBG12p.
Figure 3. Packing two 12-bit pixels into three bytes.
The GigE Vision method is designated with Packed. It is a 12-bit format with its bit-stream following the bit packing method illustrated in Figure 4. The first byte of the packed stream contains the eight msb of the first pixel. The third byte contains the eight msb of the second pixel. The four lsb of the second byte contains four lsb of the first pixel, and the rest of the second byte is packed with the four lsb of the second pixel.
This packing format is applied to: Mono12Packed, BayerGR12Packed, BayerRG12Packed, BayerGB12Packed and BayerBG12Packed.
Figure 4. Packing two 12-bit pixels into three bytes.
Multi-Channel Formats - Color Models
For the following pixel formats, the color channels are packed in the order indicated:
RGB8Packed | 8-bit red-green-blue packed format |
BGR8 | 8-bit blue-green-red packed format |
BGRa8 | 8-bit blue-green-red-alpha packed format |
For YCbCr and YUV pixel formats, the RGB to YCbCr transformation follows Equation 1 below:
Y' | = | 0.299 R' | + | 0.587 G' | + | 0.114 B' | ||
Cb | = | -0.16874 R' | – | 0.33126 G' | + | 0.5000 B' | + | 128 |
Cr | = | 0.5000 R' | – | 0.41869 G' | – | 0.08131 B' | + | 128 |
YCbCr8 / YUV444Packed
8-bit Y-Cb-Cr 4:4:4 format (Figure 5). No sub-sampling on Y, Cb or Cr. The values of Y, Cb and Cr cover the full range from 0 to 255 if the input R, G and B values are in the range of [0, 255].
Figure 5. Y-Cb-Cr 4:4:4 format.
Figure 6. Packing format for YCbCr8.
Figure 7. Packing format for YUV444Packed.
YCbCr422_8 / YUV422Packed
8-bit Y-Cb-Cr 4:2:2 format (Figure 8). No sub-sampling on Y. Cb and Cr are sub-sampled by a factor of 2 in the horizontal direction, but no sub-sampling in the vertical direction. The values of Y, Cb and Cr cover the full range from 0 to 255 if the input R, G and B values are in the range of [0, 255].
Figure 8. Y-Cb-Cr 4:2:2 format.
Figure 9. Packing format for YCbCr422_8.
Figure 10. Packing format for YUV422Packed.
YCbCr411_8 / YUV411Packed
8-bit Y-Cb-Cr 4:1:1 format (Figure 11). No sub-sampling on Y. Cb and Cr are sub-sampled by a factor of 4 in the horizontal direction, but no sub-sampling in the vertical direction. The values of Y, Cb and Cr cover the full range from 0 to 255 if the input R, G and B values are in the range of [0, 255].
Figure 11. Y-Cb-Cr 4:1:1 format.
Figure 12. Packing format for YCbCr411_8.
Figure 13. Packing format for YUV411Packed.
Polarized Cameras
For polarized sensor cameras, the polarization orientation per pixel square is defined below.
For polarized color cameras, the orientation of polarizing filters per color super pixel are defined below.