AdaptiveThreshold

Apply an adaptive threshold to a gray level image.
Can return partial results when canceled by Watchdog.

Syntax

Definition:

HRESULT AdaptiveThreshold(
    HRESULT                      hrPrev,
    ITcVnImage*                  ipSrcImage,
    ITcVnImage*&                 ipDestImage,
    double                       fMaxValue,
    ETcVnAdaptiveThresholdMethod eAdaptiveMethod = ATM_MEAN,
    ETcVnThresholdType           eThresholdType = TT_BINARY,
    ULONG                        nBlockSize = 3,
    double                       fConstant = 5
)

Parameters

Name

Type

Default

Description

hrPrev

HRESULT

 

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

ipSrcImage

ITcVnImage*

 

Source image (1 channel, elements of type USINT)

ipDestImage

ITcVnImage*&

 

Destination image (An appropriate destination image will be created if required.)

fMaxValue

double

 

Value assigned to pixels for which the threshold condition is true

eAdaptiveMethod

ETcVnAdaptiveThresholdMethod

ATM_MEAN

Adaptive threshold method to be applied (MEAN: threshold value will be calculated as a mean of the nBlockSize x nBlockSize neighborhood of (x,y) minus fConstant. GAUSSIAN: threshold value is a weighted sum (cross-correlation with a Gaussian window) of the nBlockSize x nBlockSize neighborhood of (x,y) minus fConstant.

eThresholdType

ETcVnThresholdType

TT_BINARY

Threshold type to be applied (only BINARY and BINARY_INV are supported)

nBlockSize

ULONG

3

Size of the pixel neighborhood to calculate the local threshold (3, 5, 7, ...)

fConstant

double

5

Constant that is subtracted from the weighted mean of the pixel neighborhood, which leads to the local threshold

AdaptiveThreshold 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