RGBToYUV

Converts an RGB image to the YUV color model.

Syntax

Case 1: Operation on pixel-order data

IppStatus ippiRGBToYUV_<mod>(const Ipp8u* pSrc, int srcStep, Ipp8u* pDst, int dstStep, IppiSize roiSize);

Supported values for mod:

8u_C3R 8u_AC4R

Case 2: Operation on planar data

IppStatus ippiRGBToYUV_8u_P3R(const Ipp8u* const pSrc[3], int srcStep, Ipp8u* pDst[3], int dstStep, IppiSize roiSize);

Case 3: Conversion from pixel-order to planar data

IppStatus ippiRGBToYUV_8u_C3P3R(const Ipp8u* pSrc, int srcStep, Ipp8u* pDst[3],int dstStep, IppiSize roiSize);

IppStatus ippiRGBToYUV_8u_AC4P4R(const Ipp8u* pSrc, int srcStep, Ipp8u* pDst[4], int dstStep, IppiSize roiSize);

Parameters

pSrc

Pointer to the source image ROI for pixel-order data. An array of pointers to the source image ROI in separate color planes in case of planar data.

srcStep

Distance in bytes between starts of consecutive lines in the source image.

pDst

Pointer to the destination ROI for pixel-order data. An array of pointers to destination buffers in separate color planes in case of planar data.

dstStep

Distance in bytes between starts of consecutive lines in the destination image.

roiSize

Size of the source and destination ROI in pixels.

Description

The function ippiRGBToYUV is declared in the ippcc.h file. It operates with ROI (see Regions of Interest in Intel IPP).

This function converts the gamma-corrected R'G'B' image pSrc to the Y'U'V' image pDst (see Figure Converting an RGB image to YUV) according to the following formulas:

Y' = 0.299*R' + 0.587*G' + 0.114*B'

U' = -0.147*R' - 0.289*G' + 0.436*B' = 0.492*(B'-Y')

V' = 0.615*R' - 0.515*G' - 0.100*B' = 0.877*(R'-Y')

For digital RGB values in the range [0..255], Y' has the range [0..255], U varies in the range [-112..+112], and V in the range [-157..+157]. To fit in the range of [0..255], a constant value 128 is added to computed U and V values, and V is then saturated.

Example “Using the Function ippiRGBToYUV” shows how to use the function ippiRGBToYUV_8u_C3R.

Converting an RGB image to YUV



Return Values

ippStsNoErr

Indicates no error. Any other value indicates an error or a warning.

ippStsNullPtrErr

Indicates an error condition if pSrc or pDst pointer is NULL.

ippStsSizeErr

Indicates an error condition if roiSize has a field with a zero or negative value.

Using the Function ippiRGBToYUV

Ipp8u src[9*3] = {255, 0, 0, 255, 0, 0, 255, 0, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 0, 255, 0, 0, 255, 0, 0, 255}; Ipp8u dst[9*3]; IppiSize roiSize = { 9, 3 }; ippiRGBToYUV_8u_C3R ( src, 9, dst, 9, roiSize );

Result:

255 0 0 255 0 0 255 0 0 0 255 0 0 255 0 0 255 0 src 0 0 255 0 0 255 0 0 255 77 122 130 0 127 127 17 194 113 0 255 0 0 255 0 0 255 0 "gamma-corrected" src 0 0 255 0 0 255 0 0 255 76 90 255 76 90 255 76 90 255 149 54 0 149 54 0 149 54 0 dst 29 239 102 29 239 102 29 239 102