46 Chapter 4: Matrox Rapixo CXP hardware reference
• Flipping. Images can be flipped horizontally or vertically, using the MIL-Lite
function MdigControl() with M_GRAB_DIRECTION_X/Y or when calling
MimFlip() from on-board buffer to Host.
• Color space conversion. The color space converter and image formatter formats
an image based on its type and the bit-depth and color format of the destination
buffer. You can set the bit depth and color format of the destination buffer when
you allocate it using the MIL-Lite function MbufAlloc...(). The format of the
source image is established in the DCF.
Image data can be converted as follows:
The equations for the YUV16 conversion are described in the following table. The
value of depth is either 8 or 16 when converting BGR24 or BGR48 data,
respectively. Note that while performing BGR48-to-YUV color space conversion,
the operations are carried out on 16-bit data; then, each resulting YUV component
is bit-shifted right by 8 bits (>> (depth - 8) where the value of depth is 16).
Bayer color decoder
As data exits the color space converter and image formatter, it can pass through
the Bayer color decoder. The Bayer color decoder converts Bayer color encoded
images (GB, BG, GR, and RG pattern support) to multi-band RGB images using
a 2x2 average demosaicing algorithm.
Input format Output format
8-bit
monochrome
16-bit
monochrome
24-bit
packed
BGR
32-bit
packed
BGRa
48-bit
packed
BGR
16-bit
YUV
(YUYV)
24-bit
RGB
planar
48-bit
RGB
planar
8-bit monochrome yes yes yes yes yes
16-bit monochrome yes yes yes yes yes yes yes yes
24-bit packed BGR yes yes yes yes yes
48-bit packed BGR yes yes yes yes yes yes yes yes
Color space conversion Equations
BGR-to-YUV • Y = (0.114B + 0.587G +0.299R) >>(depth - 8)
• U = (0.500B - 0.331G - 0.169R + 2
(depth-1)
) >>(depth - 8)
• V = (-0.081B - 0.419G + 0.500R + 2
(depth-1)
) >>(depth - 8)