ColorThreshold Method

NI Vision for Visual Basic

ColorThreshold Method

Syntax

CWIMAQVision.ColorThreshold SourceImage, DestImage, ColorFormat [, NewValue = 1] [, Plane1Min = 0] [, Plane1Max = 255] [, Plane2Min = 0] [, Plane2Max = 255] [, Plane3Min = 0] [, Plane3Max = 255]

Return Type

Long

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

Purpose

Thresholds a color image. The method selects a pixel if all three color components fall within the specified range. The method replaces the value of selected pixels with the given replacement value and sets the value of unselected pixels to 0.

Remarks

Use this method with image types RGB32 and HSL32.

Parameters

SourceImage As CWIMAQImage

The color image to threshold.

DestImage As CWIMAQImage

The resulting image. This image must be a U8 image except when it is the same image passed to SourceImage. In the case where the same image is passed to SourceImage and DestImage, the image is converted to a U8 image and the result is stored in this image.

ColorFormat As CWIMAQColorFormats

The color space in which to perform the threshold operation.

NewValue As Variant

[Optional] The value to which the method sets selected pixels.

This parameter has a default value of 1.

Plane1Min As Variant

[Optional] The lower limit of the range in the red or the hue plane.

This parameter has a default value of 0.

Plane1Max As Variant

[Optional] The upper limit of the range in the red or the hue plane.

This parameter has a default value of 255.

Plane2Min As Variant

[Optional] The lower limit of the range in the green or the saturation plane.

This parameter has a default value of 0.

Plane2Max As Variant

[Optional] The upper limit of the range in the green or the saturation plane.

This parameter has a default value of 255.

Plane3Min As Variant

[Optional] The lower limit of the range in the blue, the luminance, the value, or the intensity plane.

This parameter has a default value of 0.

Plane3Max As Variant

[Optional] The upper limit of the range in the blue, the luminance, the value, or the intensity plane.

This parameter has a default value of 255.

Example

Dim i As New CWIMAQImage

'Perform a color threshold on the image in Viewer1 and
'store the results in i
CWIMAQVision1.ColorThreshold CWIMAQViewer1.Image, i, _
                             cwimaqColorFormatHSL, 255, , , , , _
                             128, 255

Color Threshold Example