NI Vision for LabVIEW

IMAQ Local Threshold VI

  • Updated2023-02-21
  • 6 minute(s) read
Owning Palette: Processing
Requires: NI Vision Development Module

Thresholds an image into a binary image based on the specified local adaptive thresholding method.

Examples

Supported Image Types

8-bit unsigned grayscale 16-bit unsigned grayscale 16-bit signed grayscale

IMAQ Local Threshold

cu32.gif

Method (Niblack) specifies the local thresholding algorithm the VI uses. The default is Niblack. The following values are valid:

Niblack (0)

Computes thresholds for each pixel based on its local statistics using the Niblack local thresholding algorithm.

Background Correction (1)

Performs background correction to eliminate non-uniform lighting effects and then performs thresholding using the interclass variance thresholding algorithm.

Sauvola (2)

Computes thresholds for each pixel based on its local statistics and also uses the global standard deviation, using the Sauvola local thresholding algorithm.

Modified Sauvola (3)

Computes thresholds for each pixel based on its local statistics and the mean deviation, using the Modified Sauvola local thresholding algorithm.

cu32.gif

Look For (Bright Objects) indicates the type of objects for which you want to look. The following values are valid:

Bright Objects (0)

Looks for objects in the image represented by pixels with values greater than the value computed by the threshold method.

Dark Objects (1)

Looks for objects in the image represented by pixels with values less than the value computed by the threshold method.

cgenclasstagrefflat.gif

Image Src is a reference to the source image.

cgenclasstagrefflat.gif

Image Dst is a reference to the destination image.

cnclst.gif

Window Size (32x32) is a cluster specifying the size of the window the VI uses when calculating a local threshold. The window should be sized as large as possible but small enough that each window contains pixels with consistent levels of contrast. The VI will produce inconsistent results for windows that contain uniform pixel values. A typical window should be about the size of the object you want to segment in the image.

ci32.gif

SizeX is the size of the window in the x dimension. The size must be at least 3 and cannot be larger than the width of Image Src.

ci32.gif

SizeY is the size of the window in the y dimension. The size must be at least 3 and cannot be larger than the height of Image Src.

cerrcodeclst.gif

error in (no error) describes the error status before this VI or function runs. The default is no error. If an error occurred before this VI or function runs, the VI or function passes the error in value to error out. This VI or function runs normally only if no error occurred before this VI or function runs. If an error occurs while this VI or function runs, it runs normally and sets its own error status in error out. Use the Simple Error Handler or General Error Handler VIs to display the description of the error code. Use error in and error out to check errors and to specify execution order by wiring error out from one node to error in of the next node.

cbool.gif

status is TRUE (X) if an error occurred before this VI or function ran or FALSE (checkmark) to indicate a warning or that no error occurred before this VI or function ran. The default is FALSE.

ci32.gif

code is the error or warning code. If status is TRUE, code is a nonzero error code. If status is FALSE, code is 0 or a warning code.

cstr.gif

source describes the origin of the error or warning and is, in most cases, the name of the VI or function that produced the error or warning. The default is an empty string.

cdbl.gif

Niblack/Sauvola Deviation Factor (0.2) specifies the k constant used in the Niblack and Sauvola local thresholding algorithms, which determines the weight applied to the variance calculation. Valid k constants range from 0 to 1. The lower the Deviation Factor, the closer the pixel value must be to the mean value to be selected as part of a particle. Setting the Niblack/Sauvola Deviation Factor to 0 will increase the performance of the VI because the VI will not calculate the variance for any of the pixels. The VI ignores this value if Method is not set to Niblack or Sauvola.

cdbl.gif

Sauvola Deviation Range specifies the R constant used in the Sauvola local thresholding algorithm. The Sauvola Deviation Range and the Niblack/Sauvola Deviation Factor both determine the threshold calculation. The Sauvola Deviation Range is used to obtain better noise control in the thresholded image. The deviation range is equivalent to the dynamic range of the standard deviation of the image. Valid R constants depend on the bit depth of the image. For 8-bit images, the range is 1 to 255. For 16-bit images, the range is 1 to 65535. The VI ignores this value if Method is not set to Sauvola.

csgl.gif

Replace Value (1) specifies the replacement value the VI uses for the pixels of the kept objects in the destination image.

igenclasstagrefflat.gif

Image Dst Out is a reference to the destination image. If Image Dst is connected, Image Dst Out is the same as Image Dst. Otherwise, Image Dst Out refers to the image referenced by Image Src.

ierrcodeclst.gif

error out contains error information. If error in indicates that an error occurred before this VI or function ran, error out contains the same error information. Otherwise, it describes the error status that this VI or function produces. Right-click the error out indicator on the front panel and select Explain Error from the shortcut menu for more information about the error.

ibool.gif

status is TRUE (X) if an error occurred or FALSE (checkmark) to indicate a warning or that no error occurred.

ii32.gif

code is the error or warning code. If status is TRUE, code is a nonzero error code. If status is FALSE, code is 0 or a warning code.

istr.gif

source describes the origin of the error or warning and is, in most cases, the name of the VI or function that produced the error or warning. The default is an empty string.

Examples

Refer to the following for an example that uses this VI.

  • LabVIEW\examples\Vision\Image Processing\Image Threshold.vi