imaqLocalThreshold

NI Vision for LabWindows/CVI Function

imaqLocalThreshold

Usage

int imaqLocalThreshold(Image* dest, const Image* source, unsigned int windowWidth, unsigned int windowHeight, LocalThresholdMethod method, double deviationWeight, ObjectType type, float replaceValue);

Purpose

Automatically thresholds an image into a binary image based on the requested local adaptive thresholding method.

Image Types Supported

IMAQ_IMAGE_U8, IMAQ_IMAGE_I16

Parameters

Name

Type

Description

dest Image* The destination image.
source const Image* The image to threshold.
windowWidth unsigned int The width of the rectangular window around the pixel on which the function performs the local threshold. This number must be at least 3 and cannot be larger than the width of source.
windowHeight unsigned int The height of the rectangular window around the pixel on which the function performs the local threshold. This number must be at least 3 and cannot be larger than the height of source.
method LocalThresholdMethod Specifies the local thresholding method the function uses.
deviationWeight double Specifies the k constant used in the Niblack local thresholding algorithm, which determines the weight applied to the variance calculation. Valid k constants range from 0 to 1. Settings this value to 0 will increase the performance of the function because the function will not calculate the variance for any of the pixels. The function ignores this value if method is not set to IMAQ_NIBLACK.
type ObjectType Specifies the type of objects for which you want to look.
replaceValue float Specifies the replacement value the function uses for the pixels of the kept objects in the destination image.

Return Value

Type

Description

int On success, this function returns a non-zero value. On failure, this function returns 0. To get extended error information, call imaqGetLastError().

Parameter Discussion

windowWidth, windowHeight—The window should be sized as large as possible but small enough that each window contains pixels under similar lighting conditions. The function will produce inconsistent results for windows that contain uniform pixel values.