User`s guide

FUNCTIONS
SDK SECTION 11
Page 264
WhiteBalance
unsigned int WINAPI WhiteBalance (WORD* wRed, WORD* wGreen, WORD* wBlue, float * fRelR,
float * fRelB, WhiteBalanceInfo * info)
Description For colour sensors only
Calculates the red and blue relative to green factors to white balance a colour image
using the parameters stored in info.
Before passing the address of an WhiteBalanceInfo structure to the function the iSize
member of the structure should be set to the size of the structure. In C++ this can be
done with the line:
info-> iSize = sizeof(WhiteBalanceInfo);
Below is the WhiteBalanceInfo structure definition and a description of its members:
typedef struct WHITEBALANCEINFO {
int iSize; // Structure size.
int iX; // Number of X pixels. Must be >2.
int iY; // Number of Y pixels. Must be >2.
int iAlgorithm; // Algorithm to used to calculate white balance.
int iROI_left; // Region Of Interest from which white balance is calculated
int iROI_right; // Region Of Interest from which white balance is calculated
int iROI_top; // Region Of Interest from which white balance is calculated
int iROI_bottom; // Region Of Interest from which white balance is calculated
} WhiteBalanceInfo;
iX and iY are the image dimensions. The number of elements of the input, red, green and
blue arrays are iX x iY.
iAlgorithm sets the algorithm to use. The function sums all the colour values per each
colour field within the Region Of Interest (ROI) and calculates the relative to green values
as: 0) _fRelR = GreenSum / RedSum and _fRelB = GreenSum / BlueSum; 1) _fRelR =
2/3 GreenSum / RedSum and _fRelB = 2/3 GreenSum / BlueSum, giving more
importance to the green field.
iROI_left, iROI_right, iROI_top and iROI_bottom define the ROI with the constraints:
0 £ iROI_left < iROI_right £ iX and 0 £ iROI_ bottom < iROI_ top £ iX
Parameters
WORD* wRed: pointer to red field.
WORD* wGreen: pointer to green field.
WORD* wBlue: pointer to blue field.
float* fRelR: pointer to the relative to green red factor.
float* fRelB: pointer to the relative to green blue factor.
WhiteBalanceInfo* info: pointer to white balance information structure
Return
unsigned int
SUCCESS
DRV_P1INVALID
DRV_P2INVALID
DRV_P3INVALID
DRV_P4INVALID
DRV_P5INVALID
DRV_P6INVALID
DRV_DIVIDE_BY_ZERO_ERROR
White balance calculated.
Invalid pointer (i.e. NULL).
Invalid pointer (i.e. NULL).
Invalid pointer (i.e. NULL).
Invalid pointer (i.e. NULL).
Invalid pointer (i.e. NULL).
One or more parameters in info is out of range
The sum of the green field within the ROI is zero. _fRelR and _fRelB
are set to 1
See also
DemosaicImage, GetMostRecentColorImage16