F_VN_WhiteBalance

F_VN_WhiteBalance 1:

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:

FUNCTION F_VN_WhiteBalance : HRESULT
VAR_INPUT
    ipSrcImage  : ITcVnImage;
    ipDestImage : Reference To ITcVnImage;
    fRatioRed   : Reference To REAL;
    fRatioBlue  : Reference To REAL;
    nMaxValue   : UDINT;
    hrPrev      : HRESULT;
END_VAR

F_VN_WhiteBalance 2: Inputs

Name

Type

Description

ipSrcImage

ITcVnImage

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

ipDestImage

Reference To ITcVnImage

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

fRatioRed

Reference To REAL

Returns the ratio for the red channel

fRatioBlue

Reference To REAL

Returns the ratio for the blue channel

nMaxValue

UDINT

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

hrPrev

HRESULT

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

F_VN_WhiteBalance 3: 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