Label Method

NI Vision for Visual Basic

Label Method

Syntax

CWIMAQVision.Label SourceImage, DestImage, NumParticles [, Connectivity8 = True]

Return Type

Long

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

Purpose

Obsolete—Use Label2 instead. Labels the particles in a binary image by applying a unique value to all pixels within a particle. This value is encoded in 8 or 16 bits, depending on the image type. The method can label 255 particles in an 8-bit image and 65,535 particles in a 16-bit image.

Remarks

This method modifies the source image. If you need the original source image, create a copy of the image using the CWIMAQVision.Copy method before using this method.

Use this method with U8, I16, and floating point images.

The border must be at least one pixel wide if you use connectivity-4 or two pixels wide if you use connectivity-8.

Parameters

SourceImage As CWIMAQImage

The source image. The labeling process modifies the border of the source image.

DestImage As CWIMAQImage

The resulting image.

NumParticles As Variant

On return, the number of particles that the method detected.

Connectivity8 As Variant

[Optional] Set this parameter to True to use connectivity-8 to determine whether particles are touching. Set this parameter to False to use connectivity-4 to determine whether particles are touching. For more information about connectivity, refer to the NI Vision Concepts Manual.

This parameter has a default value of True.

Example

Dim numParticles
Dim i As New CWIMAQImage

' Threshold the image in Viewer1
CWIMAQVision1.Threshold CWIMAQViewer1.Image, CWIMAQViewer1.Image, _
                        128, 255, , 255

' Label the image in Viewer1 and store the result in i
CWIMAQVision1.Label CWIMAQViewer1.Image, i, numParticles

' Label the image in Viewer1 using connectivity-4
' and store the result in the image in Viewer2.
' View the results in Viewer2 using a binary palette
CWIMAQVision1.Label CWIMAQViewer1.Image, CWIMAQViewer2.Image, _
                    numParticles, False
CWIMAQViewer2.Palette.Type = cwimaqPaletteBinary

Label Example

See Also

Label2