AutoThreshold2 Method

NI Vision for Visual Basic

AutoThreshold2 Method

Syntax

CWIMAQVision.AutoThreshold2 SourceImage, DestImage, NumberOfClasses [, Method] [, MultiThresholdData] [, MaskImage]

Return Type

Long

On success, this method returns 0. On failure, this method returns a negative number.

Purpose

Automatically thresholds an image into multiple classes.

Remarks

Use this method with U8 images.

Parameters

SourceImage As CWIMAQImage

The image to process.

DestImage As CWIMAQImage

The resulting U8 image.

NumberOfClasses As Long

The number of classes into which to threshold the image. Valid values range from 2 to 256.

Method As Variant

[Optional] A CWIMAQAutoThresholdMethods value that specifies the threshold method to use if NumberOfClasses is 2. The method ignores this parameter if NumberOfClasses is not 2.

MultiThresholdData As Variant

[Optional] On return, a CWIMAQMultiThresholdData object containing NumClasses elements that is compatible with CWIMAQVision.MultiThreshold2.

MaskImage As Variant

[Optional] A CWIMAQImage object that specifies the region in which the method computes the MultiThresholdData. The method processes only those pixels in the image whose corresponding pixels in the mask are non-zero. Do not set this parameter if you want to calculate the MultiThresholdData for the entire image.

Example

Dim i As New CWIMAQImage
Dim thresholdData As New CWIMAQMultiThresholdData
 
'AutoThreshold2 the image in Viewer1 into 3 classes and store the 
'result in i
CWIMAQVision1.AutoThreshold2 CWIMAQViewer1.Image, i, 3, _
                             cwimaqATMethodCluster, _
                             thresholdData
    
'Use thresholdData result to MultiThreshold the Viewer inplace
CWIMAQVision1.MultiThreshold2 CWIMAQViewer1.Image, _
                              CWIMAQViewer1.Image, _
                              thresholdData

See Also

CWIMAQAutoThresholdMethods

CWIMAQMultiThresholdData

MultiThreshold2