Visible to Intel only — GUID: GUID-917746F2-8C8A-4D5A-86E0-EF57F358F16C
Visible to Intel only — GUID: GUID-917746F2-8C8A-4D5A-86E0-EF57F358F16C
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* 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);
Include Files
ippcc.h
Domain Dependencies
Headers: ippcore.h, ippvm.h, ipps.h, ippi.h
Libraries: ippcore.lib, ippvm.lib, ipps.lib, ippi.lib
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
This function 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.
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. |
Example
The code example below shows how to use the function ippiRGBToYUV_8u_C3R.
# define nChannels 3 int main () { Ipp 8 u src [3*3* nChannels ] = { 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}; Ipp 8 u dst [3*3* nChannels ]; IppiSize roiSize = { 3, 3 }; IppStatus st = ippStsNoErr ; int srcStep = 3* nChannels ; int dstStep = 3* nChannels ; st = ippiRGBToYUV _8 u _ C 3 R ( src , srcStep , dst , dstStep , roiSize ); if ( st == ippStsNoErr){ printf("\n ************* passed ****************\n"); }else{ printf("\n ************* failed ****************\t"); } return 0; }
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 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