Intel® Integrated Performance Primitives (Intel® IPP) Developer Guide and Reference

ID 790148
Date 3/22/2024
Public
Document Table of Contents

CFAToRGB

Restores the RGB image from the gray-scale CFA image.

Syntax

IppStatus ippiCFAToRGB_8u_C1C3R(const Ipp8u* pSrc, IppiRect srcRoi, IppiSize srcSize, int srcStep, Ipp8u* pDst, int dstStep, IppiBayerGrid grid, int interpolation);

IppStatus ippiCFAToRGB_16u_C1C3R(const Ipp16u* pSrc, IppiRect srcRoi, IppiSize srcSize, int srcStep, Ipp16u* pDst, int dstStep, IppiBayerGrid grid, int interpolation);

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 origin.

srcSize

Size of the source image.

srcRoi

Region of interest in the source image (of the IppiRect type).

srcStep

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

pDst

Pointer to the destination image.

dstStep

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

grid

Specifies the configuration of the Bayer grid in the source image. The following values are possible:

ippiBayerBGGR

ippiBayerRGGB

ippiBayerGBRG

ippiBayerGRBG

interpolation

Interpolation method, reserved, must be 0.

Description

This function operates with ROI (see Regions of Interest in Intel IPP).

This function transforms the one-channel gray-scale image pSrc that is produced by applying the color filter array (CFA) - an array of Bayer filters, to 24-bit three-channel RGB image. The order of the color component in the source image - Bayer grid - is specified by the parameter grid. Four possible values of this parameter correspond to the allowed variants of the Bayer grid (see Figure below).

Possible Configurations of the Bayer Grids



Each element of the source image contains an intensity value for only one color component, two others are interpolated using neighbor elements. R and B values are interpolated linearly from the nearest neighbors of the same color. When interpolating R and B values on green pixel, the average values of the two nearest neighbors (above and below, or left and right) of the same colors are used. When interpolating R or B values on the blue or red pixel respectively, the average values of the four nearest blue (red) pixels cornering the red (blue) pixel are used. G values are interpolated using an adaptive interpolation [Sak98] from a pair of nearest neighbors (vertical or horizontal) and taking into account the correlation in the red (or blue) component. The pair is chosen depending on the values of the difference between the red (blue) pixels in the vertical and horizontal directions. If the difference is smaller in the vertical direction - a vertical pair of green pixels is used, if it is smaller in the horizontal direction - a horizontal pair is used. If the difference is the same, all four neighbors are used.

This interpolation requires border pixels for the input pixels near the horizontal or vertical edge of the image. The function uses the mirrored border of two edge rows or columns of the input image. In this case the G values is calculated as the average of four nearest green pixels.

Return Values

ippStsNoErr

Indicates no error. Any other value indicates an error.

ippStsNullPtrErr

Indicates an error condition if one of the specified pointer is NULL.

ippStsSizeErr

Indicates an error condition if the srcSize has a field that is less than 2, or if the roiSize has a field with negative or zero value.

ippStsBadArgErr

Indicates an error condition if grid has an illegal value.