WhiteBalance

Calculates the white balance ratios for a RGB image. Uses the green channel as a reference and computes the relative ratios for the red and blue channels. Requires a non-reflecting, not overexposed white colored object (e.g. a sheet of paper) in at least 100 pixels of the image to provide reasonable results. The resulting ratios can then be set on the camera (multiply with existing ratios), or applied in the PLC via MultiplyImageWithVector.

Syntax

Definition:

HRESULT WhiteBalance(
    HRESULT      hrPrev,
    ITcVnImage*  ipSrcImage,
    ITcVnImage** ppDestImage,
    float&       fRatioRed,
    float&       fRatioBlue,
    ULONG        nMaxValue
)

Parameters

Name

Type

Description

hrPrev

HRESULT

HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.)

ipSrcImage

ITcVnImage*

Source image (3 channels (RGB), USINT or UINT)

ppDestImage

ITcVnImage**

Destination image with white balance applied (optional, set to 0 if not required. An appropriate image will be created if required.)

fRatioRed

float&

Returns the ratio for the red channel

fRatioBlue

float&

Returns the ratio for the blue channel

nMaxValue

ULONG

Specify the maximum pixel value that would be achieved by overexposure (usually 255 for 8 bit or 4095 for 12 bit data)

WhiteBalance 1: Return value

HRESULT

Required License

TC3 Vision Base

System Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT V3.1.4024.54 or later

PC or CX (x64) with PL50, e.g. Intel 4-core Atom CPU

Tc3_Vision